π¬ A browser extension and desktop app that turns your clicks into step-by-step guides with annotated screenshots π
TypeScript browser-extensionchrome-extensiondocumentationfirefox-extensionguide-generatorlocal-firstmanifest-v3privacy-firstproductivityreactscreenshotstep-by-step-guidetutorialtypescriptworkflowwxt
refactor(ui): share the switch from the AI settings card
Luis Ortiz252ac20bd20c
diff --git a/packages/ui/src/ai/components/AiSettings.tsx b/packages/ui/src/ai/components/AiSettings.tsxindex f3980ac..e98d2b4 100644--- a/packages/ui/src/ai/components/AiSettings.tsx+++ b/packages/ui/src/ai/components/AiSettings.tsx@@ -2,6 +2,7 @@ import { AI_PROVIDERS, type AIProviderKey, CUSTOM_MODEL_VALUE } from '@mimik/corimport { AI_LANGUAGES, type AILanguageCode } from '@mimik/core/capture/ai/prompts';import { i18n } from '@mimik/core/env';import { Globe, Sparkles, TriangleAlert } from 'lucide-react';+import { Switch } from '../../common/components/Switch';import { Button } from '../../components/ui/button';import { Input } from '../../components/ui/input';import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '../../components/ui/select';@@ -136,22 +137,7 @@ export function AiSettings({ keyCheck: aiKeyCheck, onChange }: AiSettingsProps)<Globe size={11} className="-mt-px" />{i18n.t('settings.useOwnServer')}</span>- <button- type="button"- role="switch"- aria-checked={ownServer}- aria-label={i18n.t('settings.useOwnServer')}- onClick={handleOwnServerToggle}- className={`w-9 h-5 rounded-full transition-colors relative shrink-0 ${- ownServer ? 'bg-accent' : 'bg-border'- }`}- >- <span- className={`absolute top-0.5 left-0.5 w-4 h-4 rounded-full bg-white shadow-sm transition-transform ${- ownServer ? 'translate-x-4' : 'translate-x-0'- }`}- />- </button>+ <Switch checked={ownServer} label={i18n.t('settings.useOwnServer')} onChange={handleOwnServerToggle} /></div>{ownServer && (<div className="mt-2 space-y-1.5">diff --git a/packages/ui/src/common/components/Switch.tsx b/packages/ui/src/common/components/Switch.tsxnew file mode 100644index 0000000..c66eafd--- /dev/null+++ b/packages/ui/src/common/components/Switch.tsx@@ -0,0 +1,28 @@+interface SwitchProps {+ checked: boolean;+ label: string;+ disabled?: boolean;+ onChange: (next: boolean) => void;+}++export function Switch({ checked, label, disabled, onChange }: SwitchProps) {+ return (+ <button+ type="button"+ role="switch"+ aria-checked={checked}+ aria-label={label}+ disabled={disabled}+ onClick={() => onChange(!checked)}+ className={`relative h-5 w-9 shrink-0 rounded-full transition-colors disabled:cursor-not-allowed disabled:opacity-50 ${+ checked ? 'bg-accent' : 'bg-border'+ }`}+ >+ <span+ className={`absolute top-0.5 left-0.5 h-4 w-4 rounded-full bg-white shadow-sm transition-transform ${+ checked ? 'translate-x-4' : 'translate-x-0'+ }`}+ />+ </button>+ );+}diff --git a/packages/ui/src/index.ts b/packages/ui/src/index.tsindex 231d0df..593e3f8 100644--- a/packages/ui/src/index.ts+++ b/packages/ui/src/index.ts@@ -8,6 +8,7 @@ export { useKeyCheck } from './ai/hooks/use-key-check';export { ColorPicker } from './annotation/components/ColorPicker';export { CameraMascot } from './common/components/CameraMascot';export { FaviconImg } from './common/components/FaviconImg';+export { Switch } from './common/components/Switch';export { getDomainInitial } from './common/lib/domain-initial';export { formatRelativeTime } from './common/lib/format-relative-time';export {