π¬ 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
feat: give the options page a section list, one section at a time
Luis Ortizd73b10e29414
diff --git a/src/ui/options/App.tsx b/src/ui/options/App.tsxindex 0e68073..daad784 100644--- a/src/ui/options/App.tsx+++ b/src/ui/options/App.tsx@@ -1,30 +1,5 @@import { SettingsView } from '@/ui/shared/SettingsView';export function App() {- return (- <div- style={{- display: 'flex',- alignItems: 'center',- justifyContent: 'center',- minHeight: '100vh',- width: '100%',- background: 'radial-gradient(ellipse at center, #fafafc 0%, #f0f2fa 60%, #e5e8f4 100%)',- }}- >- <div- style={{- width: '100%',- maxWidth: '28rem',- background: 'white',- borderRadius: '16px',- border: '1px solid var(--color-border)',- boxShadow: '0 8px 40px rgba(30,27,75,0.08)',- overflow: 'hidden',- }}- >- <SettingsView />- </div>- </div>- );+ return <SettingsView layout="sections" />;}diff --git a/src/ui/options/index.css b/src/ui/options/index.cssindex f03ac8b..7c27b5c 100644--- a/src/ui/options/index.css+++ b/src/ui/options/index.css@@ -1,16 +1,8 @@@import "../../../packages/ui/src/global.css";-html, body, #root {+html, body {margin: 0;padding: 0;- height: 100%;- width: 100%;-}--#root {- display: flex;- align-items: center;- justify-content: center;- background: radial-gradient(ellipse at center, #fafafc 0%, #f0f2fa 60%, #e5e8f4 100%);- min-height: 100vh;+ min-height: 100%;+ background: var(--color-secondary);}diff --git a/src/ui/shared/SettingsView.tsx b/src/ui/shared/SettingsView.tsxindex 35f0874..17225a8 100644--- a/src/ui/shared/SettingsView.tsx+++ b/src/ui/shared/SettingsView.tsx@@ -16,19 +16,22 @@ import {VoiceoverSettings,} from '@mimik/ui';import { ArrowLeft, Bug, Check, ChevronRight, EyeOff, Mic, Shield, Star } from 'lucide-react';-import { useCallback, useEffect, useState } from 'react';+import { type ReactNode, useCallback, useEffect, useState } from 'react';import { localStorage } from '@/lib/browser-api/local-storage';import { sendMessage } from '@/lib/messaging';import { useSettingsAutosave } from '@/ui/shared/hooks/use-settings-autosave';import { API_KEYS_ID, openApiKeys } from '@/ui/shared/lib/open-api-keys';import { requestMicrophoneAccess } from '@/ui/shared/lib/request-microphone-access';+import { SETTINGS_SECTIONS, type SettingsSection, settingsSection } from '@/ui/shared/lib/settings-section';import { validateApiKey } from '@/ui/shared/lib/validate-api-key';interface SettingsViewProps {onBack?: () => void;+ layout?: 'column' | 'sections';}-export function SettingsView({ onBack }: SettingsViewProps) {+export function SettingsView({ onBack, layout = 'column' }: SettingsViewProps) {+ const [section, setSection] = useState<SettingsSection>(() => settingsSection(window.location.hash));const [loaded, setLoaded] = useState(false);const [voiceProvider, setVoiceProvider] = useState<VoiceProvider>('openai');const [voiceMicrophoneId, setVoiceMicrophoneId] = useState('');@@ -53,6 +56,12 @@ export function SettingsView({ onBack }: SettingsViewProps) {const { saved, queue } = useSettingsAutosave({ blurPresets, voiceProvider, voiceMicrophoneId }, loaded);const keys = useApiKeys({ onChange: queue });+ const showSection = (next: SettingsSection) => {+ setSection(next);+ window.history.replaceState(null, '', `#${next}`);+ };+ const openKeys = layout === 'sections' ? () => showSection('api-keys') : openApiKeys;+const listVoices = useCallback((provider: VoiceoverProviderKey, apiKey: string) =>sendMessage('listVoices', { provider, apiKey }).then((result) => result.voices),@@ -68,6 +77,116 @@ export function SettingsView({ onBack }: SettingsViewProps) {macAddress: 'blurPresets.macAddress',};+ const savedBadge = (+ <span+ aria-live="polite"+ className={`ml-auto flex items-center gap-1 text-[11px] font-semibold transition-opacity duration-300 ${+ saved ? 'opacity-100' : 'opacity-0'+ }`}+ style={{ color: 'var(--color-success)' }}+ >+ <Check size={12} />+ {i18n.t('settings.saved')}+ </span>+ );++ const sections: Record<SettingsSection, ReactNode> = {+ ai: <AiSettings keys={keys} onOpenKeys={openKeys} onChange={queue} />,+ narration: (+ <SettingsCard icon={Mic} title={i18n.t('settings.voiceNarration')} hint={i18n.t('settings.voiceNarrationHint')}>+ <div>+ <label className="block text-[11px] font-semibold text-foreground mb-1">{i18n.t('settings.provider')}</label>+ <ProviderSelect+ value={voiceProvider}+ onChange={setVoiceProvider}+ onOpenKeys={openKeys}+ options={(['openai', 'groq'] as const).map((key) => ({+ value: key,+ label: KEY_PROVIDER_LABELS[key],+ logo: key,+ available: Boolean(keys.keys[key]),+ }))}+ />+ {!keys.keys[voiceProvider] && (+ <MissingKeyNote+ text={i18n.t('settings.noKeyFor', [KEY_PROVIDER_LABELS[voiceProvider]])}+ onOpenKeys={openKeys}+ />+ )}+ </div>++ {import.meta.env.BROWSER !== 'firefox' && (+ <MicrophonePicker+ value={voiceMicrophoneId}+ onChange={setVoiceMicrophoneId}+ onRequestAccess={requestMicrophoneAccess}+ triggerClassName="h-8"+ />+ )}+ </SettingsCard>+ ),+ 'voice-over': <VoiceoverSettings keys={keys.keys} listVoices={listVoices} onOpenKeys={openKeys} onChange={queue} />,+ branding: <BrandingSettings onChange={queue} />,+ 'smart-blur': (+ <SettingsCard icon={EyeOff} title={i18n.t('settings.smartBlur')} className="space-y-1 [&>*:first-child]:mb-2">+ {(Object.keys(PRESET_LABELS) as PresetKey[]).map((key, i, arr) => (+ <div+ key={key}+ className={`flex items-center justify-between py-2 ${i < arr.length - 1 ? 'border-b border-secondary' : ''}`}+ >+ <span className="text-[11px] font-semibold text-foreground">{i18n.t(BLUR_PRESET_I18N[key])}</span>+ <Switch+ checked={blurPresets[key]}+ label={i18n.t(BLUR_PRESET_I18N[key])}+ onChange={(on) =>+ setBlurPresets((prev) => {+ const next = { ...prev, [key]: on };+ localStorage.set({ blurPresets: next });+ return next;+ })+ }+ />+ </div>+ ))}+ </SettingsCard>+ ),+ 'api-keys': <ApiKeysSettings state={keys} validate={validateApiKey} title={i18n.t('settings.apiKeys')} />,+ };++ if (layout === 'sections') {+ const current = SETTINGS_SECTIONS.find((entry) => entry.id === section) ?? SETTINGS_SECTIONS[0];+ return (+ <div className="mx-auto flex w-full max-w-[960px] gap-8 px-8 py-10">+ <nav className="flex w-[220px] shrink-0 flex-col gap-0.5">+ <h1 className="mb-4 ml-3 text-[22px] font-bold text-foreground">{i18n.t('settings.title')}</h1>+ {SETTINGS_SECTIONS.map(({ id, label, Icon }) => (+ <button+ key={id}+ type="button"+ aria-current={id === section ? 'page' : undefined}+ onClick={() => showSection(id)}+ className={`flex items-center gap-2.5 rounded-lg px-3 py-2 text-left text-[13px] transition-colors ${+ id === section+ ? 'bg-card font-semibold text-foreground shadow-sm'+ : 'text-muted-foreground hover:bg-card/60 hover:text-foreground'+ }`}+ >+ <Icon size={15} className="shrink-0" />+ {i18n.t(label)}+ </button>+ ))}+ </nav>+ <main className="min-w-0 flex-1 space-y-3">+ <div className="flex h-10 items-center">+ <h2 className="text-base font-bold text-foreground">{i18n.t(current.label)}</h2>+ {savedBadge}+ </div>+ {sections[section]}+ </main>+ </div>+ );+ }+return (<div className="bg-card flex flex-col"><div className="flex items-center gap-3 px-4 py-3 border-b border-border">@@ -80,85 +199,18 @@ export function SettingsView({ onBack }: SettingsViewProps) {</button>)}<h1 className="text-[15px] font-bold text-foreground">{i18n.t('settings.title')}</h1>- <span- aria-live="polite"- className={`ml-auto flex items-center gap-1 text-[11px] font-semibold transition-opacity duration-300 ${- saved ? 'opacity-100' : 'opacity-0'- }`}- style={{ color: 'var(--color-success)' }}- >- <Check size={12} />- {i18n.t('settings.saved')}- </span>+ {savedBadge}</div><div className="flex-1 px-3 py-4 space-y-3"><div id={API_KEYS_ID} className="scroll-mt-3 space-y-3">- <ApiKeysSettings state={keys} validate={validateApiKey} title={i18n.t('settings.apiKeys')} />+ {sections['api-keys']}</div>-- <AiSettings keys={keys} onOpenKeys={openApiKeys} onChange={queue} />-- <BrandingSettings onChange={queue} />-- <SettingsCard icon={Mic} title={i18n.t('settings.voiceNarration')} hint={i18n.t('settings.voiceNarrationHint')}>- <div>- <label className="block text-[11px] font-semibold text-foreground mb-1">- {i18n.t('settings.provider')}- </label>- <ProviderSelect- value={voiceProvider}- onChange={setVoiceProvider}- onOpenKeys={openApiKeys}- options={(['openai', 'groq'] as const).map((key) => ({- value: key,- label: KEY_PROVIDER_LABELS[key],- logo: key,- available: Boolean(keys.keys[key]),- }))}- />- {!keys.keys[voiceProvider] && (- <MissingKeyNote- text={i18n.t('settings.noKeyFor', [KEY_PROVIDER_LABELS[voiceProvider]])}- onOpenKeys={openApiKeys}- />- )}- </div>-- {import.meta.env.BROWSER !== 'firefox' && (- <MicrophonePicker- value={voiceMicrophoneId}- onChange={setVoiceMicrophoneId}- onRequestAccess={requestMicrophoneAccess}- triggerClassName="h-8"- />- )}- </SettingsCard>-- <VoiceoverSettings keys={keys.keys} listVoices={listVoices} onOpenKeys={openApiKeys} onChange={queue} />-- <SettingsCard icon={EyeOff} title={i18n.t('settings.smartBlur')} className="space-y-1 [&>*:first-child]:mb-2">- {(Object.keys(PRESET_LABELS) as PresetKey[]).map((key, i, arr) => (- <div- key={key}- className={`flex items-center justify-between py-2 ${i < arr.length - 1 ? 'border-b border-secondary' : ''}`}- >- <span className="text-[11px] font-semibold text-foreground">{i18n.t(BLUR_PRESET_I18N[key])}</span>- <Switch- checked={blurPresets[key]}- label={i18n.t(BLUR_PRESET_I18N[key])}- onChange={(on) =>- setBlurPresets((prev) => {- const next = { ...prev, [key]: on };- localStorage.set({ blurPresets: next });- return next;- })- }- />- </div>- ))}- </SettingsCard>-+ {sections.ai}+ {sections.branding}+ {sections.narration}+ {sections['voice-over']}+ {sections['smart-blur']}<div className="flex items-start gap-2 px-3 py-2.5 rounded-lg bg-secondary text-[10px] text-muted-foreground leading-relaxed"><Shield size={12} className="shrink-0 mt-0.5 text-accent" /><span>{i18n.t('settings.privacyNotice')}</span>diff --git a/src/ui/shared/lib/settings-section.ts b/src/ui/shared/lib/settings-section.tsnew file mode 100644index 0000000..d29a113--- /dev/null+++ b/src/ui/shared/lib/settings-section.ts@@ -0,0 +1,17 @@+import { AudioLines, EyeOff, ImageIcon, KeyRound, Mic, Sparkles } from 'lucide-react';++export const SETTINGS_SECTIONS = [+ { id: 'ai', label: 'settings.aiDescriptions', Icon: Sparkles },+ { id: 'narration', label: 'settings.voiceNarration', Icon: Mic },+ { id: 'voice-over', label: 'settings.voiceover', Icon: AudioLines },+ { id: 'branding', label: 'settings.branding', Icon: ImageIcon },+ { id: 'smart-blur', label: 'settings.smartBlur', Icon: EyeOff },+ { id: 'api-keys', label: 'settings.apiKeys', Icon: KeyRound },+] as const;++export type SettingsSection = (typeof SETTINGS_SECTIONS)[number]['id'];++export function settingsSection(hash: string): SettingsSection {+ const id = hash.replace(/^#/, '');+ return SETTINGS_SECTIONS.find((section) => section.id === id)?.id ?? 'ai';+}