diff --git a/bun.lockb b/bun.lockb index 6c3130b0..0d70c10d 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/cspell.config.yaml b/cspell.config.yaml index 2a4927f6..02cb5277 100644 --- a/cspell.config.yaml +++ b/cspell.config.yaml @@ -54,3 +54,4 @@ words: - Upstash - healthcheck - timeago + - usehooks diff --git a/package.json b/package.json index 93a3b678..0acfc3da 100644 --- a/package.json +++ b/package.json @@ -102,6 +102,7 @@ "tailwind-merge": "^2.5.2", "timeago.js": "^4.0.2", "use-resize-observer": "^9.1.0", + "usehooks-ts": "^3.1.0", "zod": "^3.23.8" }, "devDependencies": { diff --git a/src/app/(dashboard)/app/_components/create-module-popover.tsx b/src/app/(dashboard)/app/_components/create-module-popover.tsx index e6d70245..a3562524 100644 --- a/src/app/(dashboard)/app/_components/create-module-popover.tsx +++ b/src/app/(dashboard)/app/_components/create-module-popover.tsx @@ -28,7 +28,7 @@ import { api } from '@/lib/trpc/react'; import { useRouter } from 'next/navigation'; import { toast } from 'sonner'; import { Textarea } from '@/primitives/textarea'; - +import { useDebounceValue } from 'usehooks-ts'; interface StepHeadingProps { title: string; description: string; @@ -46,6 +46,48 @@ const StepHeading = ({ title, description }: StepHeadingProps) => { ); }; +interface IconPickerProps { + iconOnClickHandler: (icon: IconNames) => void; +} + +export function IconPicker({ iconOnClickHandler }: IconPickerProps) { + const [iconSearchTerm, setIconSearchTerm] = useDebounceValue('', 200); + + return ( + <> + { + setIconSearchTerm(e.target.value); + }} + /> + +
+ {iconNames + .filter((icon) => + iconSearchTerm === '' + ? true + : icon.toLowerCase().includes(iconSearchTerm.toLowerCase()), + ) + .map((icon) => ( + + ))} +
+
+ + ); +} + const formSchema = z.object({ name: z.string().min(2), description: z.string().optional(), @@ -286,23 +328,12 @@ export function CreateModulePopover() { title="Select an icon" description="You can select an icon for your module to make it easier to identify." /> - -
- {iconNames.map((icon) => ( - - ))} -
-
+ { + form.setValue('icon', icon); + setStep(1); + }} + /> )}