A one-of-a-kind resume builder that keeps your privacy in mind. Completely secure, customizable, portable, open-source and free forever. Try it out today!
TypeScript agent-skillsaidsh-pluginhacktoberfestjavascriptmcp-serverreactresume-builderself-hostedtypescript
fix: implement fuzzy search with locale switcher and settings page
Amruth Pillaie9d888b07c1c
diff --git a/apps/client/src/components/locale-combobox.tsx b/apps/client/src/components/locale-combobox.tsxnew file mode 100644index 000000000..e9d6de141--- /dev/null+++ b/apps/client/src/components/locale-combobox.tsx@@ -0,0 +1,71 @@+import { t } from "@lingui/macro";+import { Check } from "@phosphor-icons/react";+import {+ Command,+ CommandEmpty,+ CommandGroup,+ CommandInput,+ CommandItem,+ ScrollArea,+} from "@reactive-resume/ui";+import { cn } from "@reactive-resume/utils";+import fuzzy from "fuzzy";+import { useMemo, useState } from "react";++import { useLanguages } from "../services/resume/translation";++type Props = {+ value: string;+ onValueChange: (locale: string) => void;+};++export const LocaleCombobox = ({ value, onValueChange }: Props) => {+ const { languages } = useLanguages();+ const [search, setSearch] = useState("");++ const options = useMemo(() => {+ return fuzzy.filter(search, languages, {+ extract: (lang) => `${lang.name} ${lang.locale}`,+ });+ }, [search, languages]);++ return (+ <Command shouldFilter={false}>+ <CommandInput+ value={search}+ onValueChange={setSearch}+ placeholder={t`Search for a language`}+ />+ <CommandEmpty>{t`No results found`}</CommandEmpty>+ <CommandGroup>+ <ScrollArea orientation="vertical">+ <div className="max-h-60">+ {options.map(({ original }) => (+ <CommandItem+ key={original.locale}+ value={original.locale.trim().toLowerCase()}+ onSelect={async (selectedValue) => {+ const result = options.find(+ ({ original }) => original.locale.trim().toLowerCase() === selectedValue,+ );++ if (!result) return null;++ onValueChange(result.original.locale);+ }}+ >+ <Check+ className={cn(+ "mr-2 h-4 w-4 opacity-0",+ value === original.locale && "opacity-100",+ )}+ />+ {original.name} <span className="ml-1 text-xs opacity-50">({original.locale})</span>+ </CommandItem>+ ))}+ </div>+ </ScrollArea>+ </CommandGroup>+ </Command>+ );+};diff --git a/apps/client/src/components/locale-switch.tsx b/apps/client/src/components/locale-switch.tsxindex d8afc3246..58d3e6846 100644--- a/apps/client/src/components/locale-switch.tsx+++ b/apps/client/src/components/locale-switch.tsx@@ -1,35 +1,15 @@-import { t } from "@lingui/macro";import { useLingui } from "@lingui/react";-import { Check, Translate } from "@phosphor-icons/react";-import {- Button,- Command,- CommandEmpty,- CommandGroup,- CommandInput,- CommandItem,- Popover,- PopoverContent,- PopoverTrigger,- ScrollArea,-} from "@reactive-resume/ui";-import { cn } from "@reactive-resume/utils";+import { Translate } from "@phosphor-icons/react";+import { Button, Popover, PopoverContent, PopoverTrigger } from "@reactive-resume/ui";import { useState } from "react";import { changeLanguage } from "../providers/locale";-import { useLanguages } from "../services/resume/translation";+import { LocaleCombobox } from "./locale-combobox";export const LocaleSwitch = () => {const { i18n } = useLingui();- const { languages } = useLanguages();-const [open, setOpen] = useState(false);- const options = languages.map((language) => ({- label: language.name,- value: language.locale,- }));-return (<Popover open={open} onOpenChange={setOpen}><PopoverTrigger asChild>@@ -38,40 +18,13 @@ export const LocaleSwitch = () => {</Button></PopoverTrigger><PopoverContent align="end" className="p-0">- <Command>- <CommandInput placeholder={t`Search for a language`} />- <CommandEmpty>{t`No results found`}</CommandEmpty>- <CommandGroup>- <ScrollArea orientation="vertical">- <div className="max-h-60">- {options.map((option) => (- <CommandItem- key={option.value}- value={option.value.toLowerCase().trim()}- onSelect={async (selectedValue) => {- const option = options.find(- (option) => option.value.toLowerCase().trim() === selectedValue,- );-- if (!option) return null;-- await changeLanguage(option.value);- setOpen(false);- }}- >- <Check- className={cn(- "mr-2 h-4 w-4 opacity-0",- i18n.locale === option.value && "opacity-100",- )}- />- {option.label} <span className="ml-1 text-xs opacity-50">({option.value})</span>- </CommandItem>- ))}- </div>- </ScrollArea>- </CommandGroup>- </Command>+ <LocaleCombobox+ value={i18n.locale}+ onValueChange={async (locale) => {+ await changeLanguage(locale);+ setOpen(false);+ }}+ /></PopoverContent></Popover>);diff --git a/apps/client/src/pages/dashboard/settings/_sections/profile.tsx b/apps/client/src/pages/dashboard/settings/_sections/profile.tsxindex dce3785fe..5a7de999c 100644--- a/apps/client/src/pages/dashboard/settings/_sections/profile.tsx+++ b/apps/client/src/pages/dashboard/settings/_sections/profile.tsx@@ -9,7 +9,7 @@ import { useEffect } from "react";import { useForm } from "react-hook-form";import { z } from "zod";-import { useLanguages } from "@/client/services/resume/translation";+import { LocaleCombobox } from "@/client/components/locale-combobox";import { useUpdateUser, useUser } from "@/client/services/user";const formSchema = z.object({@@ -21,7 +21,6 @@ type FormValues = z.infer<typeof formSchema>;export const ProfileSettings = () => {const { user } = useUser();- const { languages } = useLanguages();const { theme, setTheme } = useTheme();const { updateUser, loading } = useUpdateUser();@@ -95,19 +94,7 @@ export const ProfileSettings = () => {<FormItem><FormLabel>{t`Language`}</FormLabel><div className="w-full">- <Combobox- {...field}- value={field.value}- onValueChange={field.onChange}- options={languages.map(({ locale, name }) => ({- label: (- <>- {name} <span className="ml-1 text-xs opacity-50">({locale})</span>- </>- ),- value: locale,- }))}- />+ <LocaleCombobox value={field.value} onValueChange={field.onChange} /></div><FormDescription><span>diff --git a/apps/client/src/pages/home/sections/faq/index.tsx b/apps/client/src/pages/home/sections/faq/index.tsxindex f70eb773d..924ce1515 100644--- a/apps/client/src/pages/home/sections/faq/index.tsx+++ b/apps/client/src/pages/home/sections/faq/index.tsx@@ -160,10 +160,10 @@ const Question4 = () => {className="no-underline"href={`https://crowdin.com/translate/reactive-resume/all/en-${language.editorCode}`}>- <div className="relative bg-secondary-accent font-medium">+ <div className="relative bg-secondary-accent font-medium transition-colors hover:bg-primary hover:text-background"><span className="px-2 py-1">{language.name}</span>- {language.progress && (+ {language.progress !== undefined && (<spanclassName={cn("inset-0 bg-warning px-1.5 py-1 text-xs text-white",diff --git a/package.json b/package.jsonindex 5d46cff15..4a5a6ad7b 100644--- a/package.json+++ b/package.json@@ -1,7 +1,7 @@{"name": "@reactive-resume/source","description": "A free and open-source resume builder that simplifies the process of creating, updating, and sharing your resume.",- "version": "4.0.0",+ "version": "4.0.1","license": "MIT","private": true,"author": {@@ -187,6 +187,7 @@"deepmerge": "^4.3.1","file-saver": "^2.0.5","framer-motion": "^10.16.5",+ "fuzzy": "^0.1.3","helmet": "^7.1.0","immer": "^10.0.3","ioredis": "^5.3.2",diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex fbf35f18f..870c8e691 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -227,6 +227,9 @@ dependencies:framer-motion:specifier: ^10.16.5version: 10.16.5([email protected])([email protected])+ fuzzy:+ specifier: ^0.1.3+ version: 0.1.3helmet:specifier: ^7.1.0version: 7.1.0@@ -11300,6 +11303,11 @@ packages:resolution: {integrity: sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ==}dev: true+ resolution: {integrity: sha512-/gZffu4ykarLrCiP3Ygsa86UAo1E5vEVlvTrpkKywXSbP9Xhln3oSp9QSV57gEq3JFFpGJ4GZ+5zdEp3FcUh4w==}+ engines: {node: '>= 0.6.0'}+ dev: false+resolution: {integrity: sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==}engines: {node: '>=6.9.0'}