diff --git a/client/hooks/useURLUpdate.ts b/client/hooks/useURLUpdate.ts index dbacdee9..7ab37b38 100644 --- a/client/hooks/useURLUpdate.ts +++ b/client/hooks/useURLUpdate.ts @@ -33,7 +33,7 @@ export function useURLUpdate() { url.searchParams.set("page", "1"); - self.history.pushState({}, "", url.toString()); + // self.history.pushState({}, "", url.toString()); self.dispatchEvent( new CustomEvent("urlChanged", { detail: url.toString() }), ); diff --git a/components/shared/Button.tsx b/components/shared/Button.tsx index d9ddfcff..e58d85fe 100644 --- a/components/shared/Button.tsx +++ b/components/shared/Button.tsx @@ -1,7 +1,14 @@ import { JSX } from "preact"; import { IS_BROWSER } from "$fresh/runtime.ts"; -type ButtonVariant = "default" | "mint" | "wallet" | "cancel" | "submit"; +type ButtonVariant = + | "default" + | "unselected-filter" + | "selected" + | "mint" + | "wallet" + | "cancel" + | "submit"; interface ButtonProps extends JSX.HTMLAttributes { variant?: ButtonVariant; @@ -13,6 +20,10 @@ interface ButtonProps extends JSX.HTMLAttributes { const VARIANT_STYLES = { default: "inline-flex items-center justify-center bg-stamp-purple border-2 border-stamp-purple rounded-md text-sm mobileLg:text-base font-extrabold text-black tracking-[0.05em] h-[42px] mobileLg:h-[48px] px-4 mobileLg:px-5 hover:border-stamp-purple-highlight hover:bg-stamp-purple-highlight transition-colors", + "unselected-filter": + "inline-flex items-center justify-center bg-stamp-purple border-2 border-stamp-purple rounded-md text-sm mobileLg:text-base font-extrabold text-black tracking-[0.05em] h-[34px] mobileLg:h-[34px] px-4 mobileLg:px-5 hover:border-stamp-purple-highlight hover:bg-stamp-purple-highlight transition-colors", + selected: + "inline-flex items-center justify-center bg-stamp-purple-highlight border-2 border-stamp-purple rounded-md text-sm mobileLg:text-base font-extrabold text-black tracking-[0.05em] h-[34px] mobileLg:h-[34px] px-4 mobileLg:px-5", mint: "inline-flex items-center justify-center bg-stamp-purple border-2 border-stamp-purple rounded-md text-xs mobileLg:text-sm font-extrabold text-black tracking-[0.05em] h-[36px] mobileLg:h-[42px] px-3 mobileLg:px-4 hover:border-stamp-purple-highlight hover:bg-stamp-purple-highlight transition-colors", wallet: "flex items-center justify-center w-8 h-8 cursor-pointer", diff --git a/islands/src20/SRC20Header.tsx b/islands/src20/SRC20Header.tsx index 7ae964eb..e1ba1e59 100644 --- a/islands/src20/SRC20Header.tsx +++ b/islands/src20/SRC20Header.tsx @@ -1,11 +1,125 @@ import { useState } from "preact/hooks"; - +import { Button } from "$components/shared/Button.tsx"; import { SRC20_FILTER_TYPES } from "$globals"; +import { useURLUpdate } from "$client/hooks/useURLUpdate.ts"; -import { Filter } from "$islands/datacontrol/Filter.tsx"; import { Sort } from "$islands/datacontrol/Sort.tsx"; import { SRC20SearchClient } from "$islands/src20/SRC20Search.tsx"; +type FilterTypes = SRC20_FILTER_TYPES; + +const FilterRow = ({ + initialFilter, +}: { + initialFilter: SRC20_FILTER_TYPES[]; +}) => { + const [filterValue, setFilterValue] = useState( + initialFilter, + ); + const [loading, setLoading] = useState(false); + const { updateURL } = useURLUpdate(); + + const handleFilterChange = (value: FilterTypes) => () => { + setFilterValue((prevValue) => { + const newFilters = prevValue.includes(value) + ? prevValue.filter((f) => f !== value) + : [...prevValue, value]; + updateURL({ filterBy: newFilters }); + setLoading(true); + return newFilters; + }); + }; + + const clearAll = () => { + setFilterValue([]); + updateURL({ filterBy: [] }); + }; + + return ( +
+ + + + + + + + + +
+ ); +}; + export const SRC20Header = ( { filterBy, sortBy }: { filterBy: SRC20_FILTER_TYPES | SRC20_FILTER_TYPES[]; @@ -25,7 +139,7 @@ export const SRC20Header = ( }; return ( -
+

SRC-20 TOKENS @@ -35,21 +149,6 @@ export const SRC20Header = (

- { /*
+
); };