diff --git a/app/(home-pages)/home/HomeLayout.tsx b/app/(home-pages)/home/HomeLayout.tsx index aa6e5d63..4db862dc 100644 --- a/app/(home-pages)/home/HomeLayout.tsx +++ b/app/(home-pages)/home/HomeLayout.tsx @@ -14,12 +14,12 @@ import type { Attribute } from "src/replicache/attributes"; import { callRPC } from "app/api/rpc/client"; import { StaticLeafletDataContext } from "components/PageSWRDataProvider"; import { - PageSearch, DashboardLayout, DashboardState, useDashboardState, } from "components/PageLayouts/DashboardLayout"; import { DashboardPageLayout } from "components/PageLayouts/DashboardPageLayout"; +import { PageSearch } from "components/PageLayouts/PageSearch"; import { Actions } from "./Actions/Actions"; import { GetLeafletDataReturnType } from "app/api/rpc/[command]/get_leaflet_data"; import { useState } from "react"; diff --git a/app/lish/[did]/[publication]/dashboard/PublicationDashboard.tsx b/app/lish/[did]/[publication]/dashboard/PublicationDashboard.tsx index 42d6a113..6c6fad74 100644 --- a/app/lish/[did]/[publication]/dashboard/PublicationDashboard.tsx +++ b/app/lish/[did]/[publication]/dashboard/PublicationDashboard.tsx @@ -6,11 +6,9 @@ import { Actions } from "./Actions"; import React, { useState } from "react"; import { PublishedPostsList } from "./PublishedPostsLists"; import { PublicationSubscribers } from "./PublicationSubscribers"; -import { - DashboardLayout, - PageSearch, -} from "components/PageLayouts/DashboardLayout"; +import { DashboardLayout } from "components/PageLayouts/DashboardLayout"; import { DashboardPageLayout } from "components/PageLayouts/DashboardPageLayout"; +import { PageSearch } from "components/PageLayouts/PageSearch"; import { useDebouncedEffect } from "src/hooks/useDebouncedEffect"; import { type NormalizedPublication } from "src/utils/normalizeRecords"; import { PublicationAnalytics } from "./PublicationAnalytics"; diff --git a/components/PageHeader.tsx b/components/PageHeader.tsx index 19b32faf..34bc78e3 100644 --- a/components/PageHeader.tsx +++ b/components/PageHeader.tsx @@ -2,6 +2,10 @@ import { useState, useEffect } from "react"; import { useCardBorderHidden } from "./Pages/useCardBorderHidden"; import { MediaContents } from "./Media"; +import { SearchSmall } from "./Icons/SearchSmall"; +import { MenuSmall } from "./Icons/MenuSmall"; +import { Separator } from "./Layout"; +import { CloseTiny } from "./Icons/CloseTiny"; export const DesktopHeader = (props: { children: React.ReactNode }) => { let cardBorderHidden = useCardBorderHidden(); @@ -81,17 +85,39 @@ export const MobileHeader = (props: { controls?: React.ReactNode; actions: React.ReactNode; }) => { + let [state, setState] = useState<"search" | "default">("default"); return ( - {props.controls ? ( -
{props.controls}
+ {props.controls && state === "search" ? ( + <> + {props.controls} + + + ) : ( -
+ <> + Home +
+ +
{props.actions}
+ )} -
{props.actions}
); }; diff --git a/components/PageLayouts/DashboardLayout.tsx b/components/PageLayouts/DashboardLayout.tsx index 59e26789..8242583b 100644 --- a/components/PageLayouts/DashboardLayout.tsx +++ b/components/PageLayouts/DashboardLayout.tsx @@ -6,13 +6,6 @@ import { MobileNavigation } from "components/ActionBar/MobileNavigation"; import { navPages } from "components/ActionBar/NavigationButtons"; import { DesktopNavigation } from "components/ActionBar/DesktopNavigation"; import { create } from "zustand"; -import { Popover } from "components/Popover"; -import { Checkbox } from "components/Checkbox"; -import { Separator } from "components/Layout"; -import { CloseTiny } from "components/Icons/CloseTiny"; -import { MoreOptionsTiny } from "components/Icons/MoreOptionsTiny"; -import { Input } from "components/Input"; -import { SearchTiny } from "components/Icons/SearchTiny"; import { InterfaceState, useIdentityData } from "components/IdentityProvider"; import { updateIdentityInterfaceState } from "actions/updateIdentityInterfaceState"; export { MobileHeader } from "../PageHeader"; @@ -180,319 +173,3 @@ export function DashboardLayout< ); } -export const PageSearch = (props: { - searchValue: string; - setSearchValueAction: (searchValue: string) => void; - hasBackgroundImage: boolean; - defaultDisplay: Exclude; - hasPubs?: boolean; - hasArchived?: boolean; -}) => { - let { display, sort } = useDashboardState(); - display = display || props.defaultDisplay; - let setState = useSetDashboardState(); - let { identity } = useIdentityData(); - - return ( -
- {identity && ( - - )} -
- - - {(props.hasPubs || props.hasArchived) ? ( - <> - - {" "} - - ) : null} - -
-
- -
-
- ); -}; - -const SortToggle = (props: { - setState: (partial: Partial) => Promise; - sort: string | undefined; -}) => { - return ( - - ); -}; - -const DisplayToggle = (props: { - setState: (partial: Partial) => Promise; - display: string | undefined; -}) => { - return ( - - ); -}; - -const FilterOptions = (props: { hasPubs: boolean; hasArchived: boolean }) => { - let { filter } = useDashboardState(); - let setState = useSetDashboardState(); - let filterCount = Object.values(filter).filter(Boolean).length; - - return ( - Filter {filterCount > 0 && `(${filterCount})`}
} - > - {props.hasPubs && ( - <> - - setState({ - filter: { ...filter, drafts: !!e.target.checked }, - }) - } - > - Drafts - - - setState({ - filter: { ...filter, published: !!e.target.checked }, - }) - } - > - Published - - - )} - - {props.hasArchived && ( - - setState({ - filter: { ...filter, archived: !!e.target.checked }, - }) - } - > - Archived - - )} - - setState({ - filter: { ...filter, docs: !!e.target.checked }, - }) - } - > - Docs - -
- - - ); -}; - -const MobileControlsPopover = (props: { - display: string; - sort: string | undefined; - setState: (partial: Partial) => Promise; - hasPubs?: boolean; - hasArchived?: boolean; -}) => { - let { filter } = useDashboardState(); - let filterCount = Object.values(filter).filter(Boolean).length; - - return ( - - - {filterCount > 0 && ( - - {filterCount} - - )} -
- } - > - - - {(props.hasPubs || props.hasArchived) && ( - <> -
- {props.hasPubs && ( - <> - - props.setState({ - filter: { ...filter, drafts: !!e.target.checked }, - }) - } - > - Drafts - - - props.setState({ - filter: { ...filter, published: !!e.target.checked }, - }) - } - > - Published - - - )} - {props.hasArchived && ( - - props.setState({ - filter: { ...filter, archived: !!e.target.checked }, - }) - } - > - Archived - - )} - - props.setState({ - filter: { ...filter, docs: !!e.target.checked }, - }) - } - > - Docs - - {filterCount > 0 && ( - <> -
- - - )} - - )} - - ); -}; - -const SearchInput = (props: { - searchValue: string; - setSearchValue: (searchValue: string) => void; - hasBackgroundImage: boolean; -}) => { - return ( -
- { - props.setSearchValue(e.currentTarget.value); - }} - /> -
- -
-
- ); -}; diff --git a/components/PageLayouts/PageSearch.tsx b/components/PageLayouts/PageSearch.tsx new file mode 100644 index 00000000..22b474c4 --- /dev/null +++ b/components/PageLayouts/PageSearch.tsx @@ -0,0 +1,277 @@ +"use client"; +import { Popover } from "components/Popover"; +import { Checkbox } from "components/Checkbox"; +import { Separator } from "components/Layout"; +import { CloseTiny } from "components/Icons/CloseTiny"; +import { Input } from "components/Input"; +import { SearchTiny } from "components/Icons/SearchTiny"; +import { useIdentityData } from "components/IdentityProvider"; +import { SortSmall } from "components/Icons/SortSmall"; +import { + DashboardState, + useDashboardState, + useSetDashboardState, +} from "./DashboardLayout"; + +export const PageSearch = (props: { + searchValue: string; + setSearchValueAction: (searchValue: string) => void; + hasBackgroundImage: boolean; + defaultDisplay: Exclude; + hasPubs?: boolean; + hasArchived?: boolean; +}) => { + let { display, sort } = useDashboardState(); + display = display || props.defaultDisplay; + let setState = useSetDashboardState(); + let { identity } = useIdentityData(); + + return ( +
+ {identity && ( + + )} +
+ + + {props.hasPubs || props.hasArchived ? ( + <> + + {" "} + + ) : null} + +
+
+ +
+
+ ); +}; + +const SortToggle = (props: { + setState: (partial: Partial) => Promise; + sort: string | undefined; +}) => { + return ( + + ); +}; + +const DisplayToggle = (props: { + setState: (partial: Partial) => Promise; + display: string | undefined; +}) => { + return ( + + ); +}; + +const FilterCheckboxes = (props: { + hasPubs: boolean; + hasArchived: boolean; +}) => { + let { filter } = useDashboardState(); + let setState = useSetDashboardState(); + let filterCount = Object.values(filter).filter(Boolean).length; + + return ( + <> + {props.hasPubs && ( + <> + + setState({ filter: { ...filter, drafts: !!e.target.checked } }) + } + > + Drafts + + + setState({ + filter: { ...filter, published: !!e.target.checked }, + }) + } + > + Published + + + )} + {props.hasArchived && ( + + setState({ filter: { ...filter, archived: !!e.target.checked } }) + } + > + Archived + + )} + + setState({ filter: { ...filter, docs: !!e.target.checked } }) + } + > + Docs + + +
+ + + ); +}; + +const FilterOptions = (props: { hasPubs: boolean; hasArchived: boolean }) => { + let { filter } = useDashboardState(); + let filterCount = Object.values(filter).filter(Boolean).length; + + return ( + Filter {filterCount > 0 && `(${filterCount})`}} + > + + + ); +}; + +const MobileSearchControls = (props: { + display: string; + sort: string | undefined; + setState: (partial: Partial) => Promise; + hasPubs?: boolean; + hasArchived?: boolean; +}) => { + let { filter } = useDashboardState(); + let filterCount = Object.values(filter).filter(Boolean).length; + + return ( + 0 ? "text-accent-contrast" : ""} /> + } + > + +
+ + {(props.hasPubs || props.hasArchived) && ( + <> +
+
+ Filter +
+ + + )} +
+ ); +}; + +const SearchInput = (props: { + searchValue: string; + setSearchValue: (searchValue: string) => void; + hasBackgroundImage: boolean; +}) => { + return ( +
+ { + props.setSearchValue(e.currentTarget.value); + }} + /> +
+ +
+
+ ); +};