diff --git a/front/packages/primitives/src/menu.web.tsx b/front/packages/primitives/src/menu.web.tsx index 6ab2855c..e062a942 100644 --- a/front/packages/primitives/src/menu.web.tsx +++ b/front/packages/primitives/src/menu.web.tsx @@ -28,6 +28,7 @@ import { P } from "./text"; import { ContrastArea } from "./themes"; import { Icon } from "./icons"; import Dot from "@material-symbols/svg-400/rounded/fiber_manual_record-fill.svg"; +import { focusReset } from "./utils"; type YoshikiFunc = (props: ReturnType) => T; const YoshikiProvider = ({ children }: { children: YoshikiFunc }) => { @@ -138,17 +139,13 @@ const MenuItem = ({ onSelect={onSelect} href={href} {...css( - [ - { - display: "flex", - alignItems: "center", - padding: "8px", - height: "32px", - focus: { - boxShadow: "none", - }, - }, - ], + { + display: "flex", + alignItems: "center", + padding: "8px", + height: "32px", + focus: focusReset as any, + }, props as any, )} > diff --git a/front/packages/primitives/src/tooltip.tsx b/front/packages/primitives/src/tooltip.tsx index bbfbe1ca..f83a1892 100644 --- a/front/packages/primitives/src/tooltip.tsx +++ b/front/packages/primitives/src/tooltip.tsx @@ -53,6 +53,9 @@ export const WebTooltip = ({ theme }: { theme: Theme }) => { transform: translate(-50%); z-index: 999; + width: max-content; + max-width: 300%; + margin-top: 8px; border-radius: 5px; padding: 6px; diff --git a/front/packages/ui/src/browse/header.tsx b/front/packages/ui/src/browse/header.tsx index 3211daf1..157996cc 100644 --- a/front/packages/ui/src/browse/header.tsx +++ b/front/packages/ui/src/browse/header.tsx @@ -18,13 +18,15 @@ * along with Kyoo. If not, see . */ -import { IconButton, tooltip, ts } from "@kyoo/primitives"; -import { View } from "moti"; +import { HR, Icon, IconButton, Menu, P, PressableFeedback, tooltip, ts } from "@kyoo/primitives"; import { useTranslation } from "react-i18next"; import { useYoshiki } from "yoshiki/native"; import GridView from "@material-symbols/svg-400/rounded/grid_view.svg"; import ViewList from "@material-symbols/svg-400/rounded/view_list.svg"; +import Sort from "@material-symbols/svg-400/rounded/sort.svg"; import { Layout, SortBy, SortOrd } from "./types"; +import { forwardRef } from "react"; +import { View, PressableProps } from "react-native"; // const SortByMenu = ({ // sortKey, @@ -98,6 +100,25 @@ import { Layout, SortBy, SortOrd } from "./types"; // ); // }; +const SortTrigger = forwardRef(function _SortTrigger( + { sortKey, ...props }, + ref, +) { + const { css } = useYoshiki(); + const { t } = useTranslation(); + + return ( + + +

{t(`browse.sortkey.${sortKey}`)}

+
+ ); +}); + export const BrowseSettings = ({ sortKey, setSort, @@ -114,23 +135,42 @@ export const BrowseSettings = ({ setLayout: (layout: Layout) => void; }) => { // const [sortAnchor, setSortAnchor] = useState(null); - const { css } = useYoshiki(); + const { css, theme } = useYoshiki(); const { t } = useTranslation(); return ( - - setLayout(Layout.Grid)} - {...tooltip(t("browse.switchToGrid"))} - {...css({ paddingX: ts(.5) })} - /> - setLayout(Layout.List)} - {...tooltip(t("browse.switchToList"))} - {...css({ paddingX: ts(.5) })} - /> + + + + + {Object.values(SortBy).map((x) => ( + setSort(x)} + // component={Link} + // to={{ query: { ...router.query, sortBy: `${sortKey}-${sortOrd}` } }} + // TODO: Set query param for sort. + /> + ))} + +
+ setLayout(Layout.Grid)} + color={layout == Layout.Grid ? theme.accent : undefined} + {...tooltip(t("browse.switchToGrid"))} + {...css({ paddingX: ts(0.5) })} + /> + setLayout(Layout.List)} + color={layout == Layout.List ? theme.accent : undefined} + {...tooltip(t("browse.switchToList"))} + {...css({ paddingX: ts(0.5) })} + /> +
);