Skip to content

Commit 8f162bb

Browse files
committed
feat: actionlist sorting via switch
1 parent 8e2a59c commit 8f162bb

2 files changed

Lines changed: 8 additions & 14 deletions

File tree

src/components/cards/ActionCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export function ActionCard({ action, locale }: { action: ActionItem; locale: App
1313
<Link href={`/${locale}/actions/${action.slug}`} className="block aspect-square w-full">
1414
<Card size="lg" variant="light" className="@container size-full p-4! transition-colors hover:bg-white/10">
1515
<div className="relative z-10 flex h-full min-w-0 flex-col items-center justify-center gap-4 text-center">
16-
{action.icon && <ActionIcon icon={action.icon} size="clamp(3rem, 22cqi, 4rem)" />}
16+
{action.icon && <ActionIcon icon={action.icon} size="clamp(4rem, 22cqi, 4rem)" />}
1717
<h2 className="max-w-full whitespace-nowrap font-semibold leading-tight text-white" style={{ fontSize: `clamp(0.625rem, calc((100cqi - 2rem) / ${titleScale}), 1.25rem)` }}>
1818
{action.title}
1919
</h2>

src/components/sections/ActionListSection.tsx

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { cn } from "@/lib/utils"
66
import { Button, Menu, MenuContent, MenuItem, MenuTrigger, TextInput } from "@code0-tech/pictor"
77
import { IconChevronDown, IconSearch } from "@tabler/icons-react"
88
import { Section } from "@/components/ui/Section"
9+
import { Switch, type SwitchOption } from "@/components/ui/Switch"
910
import type { ChangeEvent } from "react"
1011
import { useMemo, useState } from "react"
1112

@@ -64,6 +65,10 @@ export function ActionListSection({ actions, locale, content }: { actions: Actio
6465
const allCategoriesLabel = content.allCategoriesLabel || "All Categories"
6566
const selectedCategory = CATEGORY_LABEL_KEYS.find(({ tag }) => tag === selectedTag)
6667
const selectedCategoryLabel = selectedCategory ? content.categoryLabels?.[selectedCategory.label] || selectedCategory.tag : allCategoriesLabel
68+
const sortOptions: SwitchOption<SortOrder>[] = [
69+
{ value: "newest", label: content.sortNewestLabel },
70+
{ value: "oldest", label: content.sortOldestLabel },
71+
]
6772
const filteredActions = useMemo(() => {
6873
const term = search.trim().toLowerCase()
6974
return actions
@@ -88,7 +93,7 @@ export function ActionListSection({ actions, locale, content }: { actions: Actio
8893
headingLevel={1}
8994
>
9095
<div className="flex flex-col gap-4">
91-
<div className="flex flex-col gap-2 sm:gap-4 sm:flex-row">
96+
<div className="flex flex-row gap-2 sm:gap-4">
9297
<div className="min-w-0 flex-1">
9398
<TextInput
9499
value={search}
@@ -99,18 +104,7 @@ export function ActionListSection({ actions, locale, content }: { actions: Actio
99104
className="w-full! text-white!"
100105
/>
101106
</div>
102-
<Menu modal={false}>
103-
<MenuTrigger asChild>
104-
<Button className="w-full! justify-between sm:w-auto! sm:min-w-36">
105-
{sortOrder === "newest" ? content.sortNewestLabel : content.sortOldestLabel}
106-
<IconChevronDown size={16} />
107-
</Button>
108-
</MenuTrigger>
109-
<MenuContent className="w-(--radix-dropdown-menu-trigger-width)">
110-
<MenuItem onClick={() => setSortOrder("newest")}>{content.sortNewestLabel}</MenuItem>
111-
<MenuItem onClick={() => setSortOrder("oldest")}>{content.sortOldestLabel}</MenuItem>
112-
</MenuContent>
113-
</Menu>
107+
<Switch value={sortOrder} options={sortOptions} onChange={setSortOrder} className="w-auto shrink-0 [&>div]:h-10.5 [&>div>button]:py-0" fitContent />
114108
</div>
115109
</div>
116110
<div className="grid items-start gap-6 md:grid-cols-[13rem_minmax(0,1fr)]">

0 commit comments

Comments
 (0)