Skip to content

armgit / mimik

Public Imported from GitHub
0

🎬 A browser extension and desktop app that turns your clicks into step-by-step guides with annotated screenshots 📖

feat(desktop): mount the extension's branding cards and share its card frame and switch

Luis Ortiz6936eb84f668
diff --git a/apps/desktop/src/renderer/settings/Card.tsx b/apps/desktop/src/renderer/settings/Card.tsx
index ef01492..c34b9fb 100644
--- a/apps/desktop/src/renderer/settings/Card.tsx
+++ b/apps/desktop/src/renderer/settings/Card.tsx
@@ -1,26 +1,18 @@
-import type { Command } from 'lucide-react';
+import { SettingsCard } from '@mimik/ui';
+import type { LucideIcon } from 'lucide-react';
import type { ReactNode } from 'react';
interface CardProps {
- icon: typeof Command;
+ icon: LucideIcon;
title: string;
hint?: string;
children: ReactNode;
}
-export function Card({ icon: Icon, title, hint, children }: CardProps) {
+export function Card({ icon, title, hint, children }: CardProps) {
return (
- <div className="rounded-[10px] border border-border bg-card px-3.5 pt-3.5 pb-1">
- <div className="flex items-center gap-2.5 pb-1">
- <div className="flex h-7 w-7 shrink-0 items-center justify-center rounded-lg bg-secondary">
- <Icon size={14} className="text-accent" />
- </div>
- <span className="flex flex-col">
- <span className="text-xs font-bold text-foreground">{title}</span>
- {hint && <span className="text-[11px] text-muted-foreground">{hint}</span>}
- </span>
- </div>
- <div className="divide-y divide-secondary">{children}</div>
- </div>
+ <SettingsCard icon={icon} title={title} hint={hint} className="pb-1">
+ <div className="-mt-2 divide-y divide-secondary">{children}</div>
+ </SettingsCard>
);
}
diff --git a/apps/desktop/src/renderer/settings/MarkerColour.tsx b/apps/desktop/src/renderer/settings/MarkerColour.tsx
deleted file mode 100644
index 0013e3e..0000000
--- a/apps/desktop/src/renderer/settings/MarkerColour.tsx
+++ /dev/null
@@ -1,40 +0,0 @@
-import { i18n, localStorage } from '@mimik/core/env';
-import { DEFAULT_TARGET_COLOR, TARGET_COLORS } from '@mimik/core/screenshot/types';
-import { ColorPicker, Popover, PopoverContent, PopoverTrigger } from '@mimik/ui';
-import { ChevronDown } from 'lucide-react';
-import { useEffect, useState } from 'react';
-
-export function MarkerColour() {
- const [color, setColor] = useState(DEFAULT_TARGET_COLOR);
-
- useEffect(() => {
- localStorage.get(['targetColor']).then(({ targetColor }) => targetColor && setColor(targetColor));
- }, []);
-
- const change = (next: string) => {
- setColor(next);
- localStorage.set({ targetColor: next });
- };
-
- return (
- <Popover>
- <PopoverTrigger asChild>
- <button
- type="button"
- aria-label={i18n.t('desktop_markerColour')}
- className="flex shrink-0 items-center gap-2 rounded-lg border border-border px-2 py-1.5 text-[11px] text-foreground hover:border-accent"
- >
- <span
- className="h-[22px] w-[22px] rounded-full border border-foreground/15"
- style={{ backgroundColor: color }}
- />
- <code className="tabular-nums">{color.toUpperCase()}</code>
- <ChevronDown size={12} className="opacity-60" />
- </button>
- </PopoverTrigger>
- <PopoverContent align="end" className="w-56 p-2.5">
- <ColorPicker value={color} presets={TARGET_COLORS} onChange={change} />
- </PopoverContent>
- </Popover>
- );
-}
diff --git a/apps/desktop/src/renderer/settings/SettingsPanel.tsx b/apps/desktop/src/renderer/settings/SettingsPanel.tsx
index dc45211..c1b65cd 100644
--- a/apps/desktop/src/renderer/settings/SettingsPanel.tsx
+++ b/apps/desktop/src/renderer/settings/SettingsPanel.tsx
@@ -1,22 +1,32 @@
import { validateApiKey } from '@mimik/core/capture/ai/validate';
import { i18n } from '@mimik/core/env';
-import { AiSettings, Switch, useKeyCheck } from '@mimik/ui';
-import { AppWindow, Command, Crop, Keyboard, Monitor, MonitorPlay, MousePointerClick, Sparkles } from 'lucide-react';
+import { AiSettings, BrandingSettings, Switch, useKeyCheck } from '@mimik/ui';
+import {
+ AppWindow,
+ Command,
+ Crop,
+ ImageIcon,
+ Keyboard,
+ Monitor,
+ MonitorPlay,
+ MousePointerClick,
+ Sparkles,
+} from 'lucide-react';
import { useEffect, useState } from 'react';
import type { CaptureSettings, CaptureShortcuts } from '../../main/capture/settings';
import { Card } from './Card';
import { zoomLevels } from './lib/zoom-levels';
-import { MarkerColour } from './MarkerColour';
import { Row } from './Row';
import { Segmented } from './Segmented';
import { ShortcutRecorder } from './ShortcutRecorder';
import { Slider } from './Slider';
-type Section = 'capture' | 'ai' | 'shortcuts';
+type Section = 'capture' | 'ai' | 'branding' | 'shortcuts';
const SECTIONS: { id: Section; labelKey: string; Icon: typeof AppWindow }[] = [
{ id: 'capture', labelKey: 'desktop_capturingSection', Icon: MonitorPlay },
{ id: 'ai', labelKey: 'settings_aiDescriptions', Icon: Sparkles },
+ { id: 'branding', labelKey: 'settings_branding', Icon: ImageIcon },
{ id: 'shortcuts', labelKey: 'desktop_shortcutsSection', Icon: Command },
];
@@ -69,6 +79,8 @@ export function SettingsPanel() {
<div className="flex flex-col gap-3.5">
{section === 'ai' && <AiSettings keyCheck={keyCheck} />}
+ {section === 'branding' && <BrandingSettings />}
+
{section === 'capture' && settings && (
<>
<Card
@@ -131,9 +143,6 @@ export function SettingsPanel() {
onChange={(showCursor) => save({ showCursor })}
/>
</Row>
- <Row label={i18n.t('desktop_markerColour')} hint={i18n.t('desktop_markerColourHint')}>
- <MarkerColour />
- </Row>
</Card>
<Card icon={Keyboard} title={i18n.t('desktop_cardKeyboard')} hint={i18n.t('desktop_cardKeyboardHint')}>
diff --git a/packages/ui/src/ai/components/AiSettings.tsx b/packages/ui/src/ai/components/AiSettings.tsx
index e98d2b4..2a6ca7a 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/cor
import { AI_LANGUAGES, type AILanguageCode } from '@mimik/core/capture/ai/prompts';
import { i18n } from '@mimik/core/env';
import { Globe, Sparkles, TriangleAlert } from 'lucide-react';
+import { SettingsCard } from '../../common/components/SettingsCard';
import { Switch } from '../../common/components/Switch';
import { Button } from '../../components/ui/button';
import { Input } from '../../components/ui/input';
@@ -50,14 +51,7 @@ export function AiSettings({ keyCheck: aiKeyCheck, onChange }: AiSettingsProps)
});
return (
- <div className="border border-border rounded-[10px] p-3.5 space-y-3">
- <div className="flex items-center gap-2.5">
- <div className="w-7 h-7 rounded-lg bg-secondary flex items-center justify-center">
- <Sparkles size={14} className="text-accent" />
- </div>
- <span className="text-xs font-bold text-foreground">{i18n.t('settings.aiDescriptions')}</span>
- </div>
-
+ <SettingsCard icon={Sparkles} title={i18n.t('settings.aiDescriptions')}>
<div>
<label className="block text-[11px] font-semibold text-foreground mb-1">{i18n.t('settings.provider')}</label>
<Select value={provider} onValueChange={(v) => handleProviderChange(v as AIProviderKey)}>
@@ -178,6 +172,6 @@ export function AiSettings({ keyCheck: aiKeyCheck, onChange }: AiSettingsProps)
</SelectContent>
</Select>
</div>
- </div>
+ </SettingsCard>
);
}
diff --git a/packages/ui/src/branding/components/BrandingSettings.tsx b/packages/ui/src/branding/components/BrandingSettings.tsx
new file mode 100644
index 0000000..bd92956
--- /dev/null
+++ b/packages/ui/src/branding/components/BrandingSettings.tsx
@@ -0,0 +1,127 @@
+import { i18n } from '@mimik/core/env';
+import { TARGET_COLORS } from '@mimik/core/screenshot/types';
+import { ChevronDown, ImageIcon, Target, Trash2 } from 'lucide-react';
+import { useRef } from 'react';
+import { ColorPicker } from '../../annotation/components/ColorPicker';
+import { SettingsCard } from '../../common/components/SettingsCard';
+import { Switch } from '../../common/components/Switch';
+import { Input } from '../../components/ui/input';
+import { Popover, PopoverContent, PopoverTrigger } from '../../components/ui/popover';
+import { useBrandingSettings } from '../hooks/use-branding-settings';
+import { footerPresets } from '../lib/footer-presets';
+
+export function BrandingSettings({ onChange }: { onChange?: (patch: Record<string, unknown>) => void }) {
+ const {
+ targetColor,
+ brandLogo,
+ brandFooter,
+ brandAttribution,
+ setTargetColor,
+ pickLogo,
+ removeLogo,
+ setBrandFooter,
+ toggleAttribution,
+ } = useBrandingSettings(onChange);
+ const logoInputRef = useRef<HTMLInputElement>(null);
+
+ return (
+ <>
+ <SettingsCard
+ icon={Target}
+ title={i18n.t('settings.targetColor')}
+ hint={i18n.t('settings.targetColorHint')}
+ action={
+ <Popover>
+ <PopoverTrigger asChild>
+ <button
+ type="button"
+ className="flex items-center gap-2 shrink-0 border border-border rounded-lg px-2 py-1.5 text-[11px] text-foreground hover:border-accent"
+ >
+ <span
+ className="w-[22px] h-[22px] rounded-full border border-foreground/15"
+ style={{ backgroundColor: targetColor }}
+ />
+ <code className="tabular-nums">{targetColor.toUpperCase()}</code>
+ <ChevronDown size={12} className="opacity-60" />
+ </button>
+ </PopoverTrigger>
+ <PopoverContent align="end" className="w-56 p-2.5">
+ <ColorPicker value={targetColor} presets={TARGET_COLORS} onChange={setTargetColor} />
+ </PopoverContent>
+ </Popover>
+ }
+ />
+
+ <SettingsCard icon={ImageIcon} title={i18n.t('settings.branding')}>
+ <div>
+ <label className="block text-[11px] font-semibold text-foreground mb-1">{i18n.t('settings.brandLogo')}</label>
+ <input
+ ref={logoInputRef}
+ type="file"
+ accept="image/png,image/jpeg,image/svg+xml,image/webp"
+ className="hidden"
+ onChange={(e) => pickLogo(e.target.files?.[0])}
+ />
+ <div className="flex items-center gap-2.5">
+ {brandLogo && (
+ <img
+ src={brandLogo.dataUrl}
+ alt=""
+ className="h-9 max-w-[92px] object-contain rounded border border-border bg-secondary p-1"
+ />
+ )}
+ <button
+ type="button"
+ onClick={() => logoInputRef.current?.click()}
+ className="border border-border rounded-lg px-2.5 py-1.5 text-[11px] font-medium text-foreground hover:border-accent transition-colors"
+ >
+ {brandLogo ? i18n.t('settings.replaceLogo') : i18n.t('settings.uploadLogo')}
+ </button>
+ {brandLogo && (
+ <button
+ onClick={removeLogo}
+ aria-label={i18n.t('settings.removeLogo')}
+ className="w-7 h-7 rounded-lg flex items-center justify-center text-muted-foreground hover:text-foreground hover:bg-secondary transition-colors"
+ >
+ <Trash2 size={14} />
+ </button>
+ )}
+ </div>
+ </div>
+
+ <div>
+ <label className="block text-[11px] font-semibold text-foreground mb-1">
+ {i18n.t('settings.footerLine')}
+ </label>
+ <Input
+ value={brandFooter}
+ onChange={(e) => setBrandFooter(e.target.value)}
+ placeholder={i18n.t('settings.footerLinePlaceholder')}
+ className="h-8 text-[13px] rounded-lg border-border"
+ />
+ <div className="flex flex-wrap gap-1.5 mt-2">
+ {footerPresets().map((preset) => (
+ <button
+ key={preset}
+ type="button"
+ onClick={() => setBrandFooter(preset)}
+ className={`px-2 py-1 rounded-md border text-[10px] transition-colors ${
+ brandFooter === preset
+ ? 'border-accent text-accent'
+ : 'border-border text-muted-foreground hover:border-accent hover:text-foreground'
+ }`}
+ >
+ {preset}
+ </button>
+ ))}
+ </div>
+ </div>
+
+ <div className="flex items-center justify-between gap-3 pt-1">
+ <div className="text-[11px] font-semibold text-foreground">{i18n.t('settings.attribution')}</div>
+ <Switch checked={brandAttribution} label={i18n.t('settings.attribution')} onChange={toggleAttribution} />
+ </div>
+ </SettingsCard>
+ </>
+ );
+}
diff --git a/packages/ui/src/branding/components/__tests__/branding-settings.test.tsx b/packages/ui/src/branding/components/__tests__/branding-settings.test.tsx
new file mode 100644
index 0000000..767e03c
--- /dev/null
+++ b/packages/ui/src/branding/components/__tests__/branding-settings.test.tsx
@@ -0,0 +1,33 @@
+// @vitest-environment jsdom
+import '@testing-library/jest-dom/vitest';
+import { localStorage } from '@mimik/core/env';
+import { fireEvent, render, screen, waitFor } from '@testing-library/react';
+import { beforeEach, describe, expect, it, vi } from 'vitest';
+import { BrandingSettings } from '../BrandingSettings';
+
+describe('BrandingSettings', () => {
+ beforeEach(async () => {
+ await localStorage.set({ brandFooter: 'Acme', brandAttribution: true });
+ });
+
+ it('shows what is stored and saves each change straight away', async () => {
+ const onChange = vi.fn();
+ render(<BrandingSettings onChange={onChange} />);
+ await waitFor(() => expect(screen.getByDisplayValue('Acme')).toBeInTheDocument());
+
+ fireEvent.click(screen.getByText('settings.footerPresetConfidential'));
+ expect(onChange).toHaveBeenLastCalledWith({ brandFooter: 'settings.footerPresetConfidential' });
+
+ const attribution = screen.getByRole('switch', { name: 'settings.attribution' });
+ fireEvent.click(attribution);
+ fireEvent.click(attribution);
+ expect(onChange).toHaveBeenLastCalledWith({ brandAttribution: true });
+
+ await waitFor(async () =>
+ expect(await localStorage.get(['brandFooter', 'brandAttribution'])).toEqual({
+ brandFooter: 'settings.footerPresetConfidential',
+ brandAttribution: true,
+ }),
+ );
+ });
+});
diff --git a/packages/ui/src/branding/hooks/use-branding-settings.ts b/packages/ui/src/branding/hooks/use-branding-settings.ts
new file mode 100644
index 0000000..90abe57
--- /dev/null
+++ b/packages/ui/src/branding/hooks/use-branding-settings.ts
@@ -0,0 +1,68 @@
+import { localStorage } from '@mimik/core/env';
+import { type BrandLogo, defaultFooterLine, makeBrandLogo } from '@mimik/core/export/branding';
+import { DEFAULT_TARGET_COLOR } from '@mimik/core/screenshot/types';
+import { useEffect, useState } from 'react';
+
+const BRANDING_KEYS = ['targetColor', 'brandLogo', 'brandFooter', 'brandAttribution'] as const;
+
+export interface BrandingSettingsState {
+ targetColor: string;
+ brandLogo: BrandLogo | null;
+ brandFooter: string;
+ brandAttribution: boolean;
+ setTargetColor: (color: string) => void;
+ pickLogo: (file: File | undefined) => Promise<void>;
+ removeLogo: () => void;
+ setBrandFooter: (footer: string) => void;
+ toggleAttribution: () => void;
+}
+
+export function useBrandingSettings(onDirty?: (patch: Record<string, unknown>) => void): BrandingSettingsState {
+ const [targetColor, setColor] = useState<string>(DEFAULT_TARGET_COLOR);
+ const [brandLogo, setLogo] = useState<BrandLogo | null>(null);
+ const [brandFooter, setFooter] = useState('');
+ const [brandAttribution, setAttribution] = useState(true);
+
+ useEffect(() => {
+ localStorage.get(BRANDING_KEYS).then((stored) => {
+ if (stored.targetColor) setColor(stored.targetColor);
+ if (stored.brandLogo) setLogo(stored.brandLogo);
+ setFooter(typeof stored.brandFooter === 'string' ? stored.brandFooter : defaultFooterLine());
+ if (stored.brandAttribution === false) setAttribution(false);
+ });
+ }, []);
+
+ const save = (patch: Record<string, unknown>) => {
+ void localStorage.set(patch as never);
+ onDirty?.(patch);
+ };
+
+ return {
+ targetColor,
+ brandLogo,
+ brandFooter,
+ brandAttribution,
+ setTargetColor: (color) => {
+ setColor(color);
+ save({ targetColor: color });
+ },
+ pickLogo: async (file) => {
+ if (!file) return;
+ const logo = await makeBrandLogo(file);
+ setLogo(logo);
+ save({ brandLogo: logo });
+ },
+ removeLogo: () => {
+ setLogo(null);
+ save({ brandLogo: null });
+ },
+ setBrandFooter: (footer) => {
+ setFooter(footer);
+ save({ brandFooter: footer });
+ },
+ toggleAttribution: () => {
+ setAttribution(!brandAttribution);
+ save({ brandAttribution: !brandAttribution });
+ },
+ };
+}
diff --git a/src/ui/shared/lib/footer-presets.ts b/packages/ui/src/branding/lib/footer-presets.ts
similarity index 100%
rename from src/ui/shared/lib/footer-presets.ts
rename to packages/ui/src/branding/lib/footer-presets.ts
diff --git a/packages/ui/src/common/components/SettingsCard.tsx b/packages/ui/src/common/components/SettingsCard.tsx
new file mode 100644
index 0000000..c9ccf81
--- /dev/null
+++ b/packages/ui/src/common/components/SettingsCard.tsx
@@ -0,0 +1,30 @@
+import type { LucideIcon } from 'lucide-react';
+import type { ReactNode } from 'react';
+import { cn } from '../lib/cn';
+
+interface SettingsCardProps {
+ icon: LucideIcon;
+ title: string;
+ hint?: string;
+ action?: ReactNode;
+ className?: string;
+ children?: ReactNode;
+}
+
+export function SettingsCard({ icon: Icon, title, hint, action, className, children }: SettingsCardProps) {
+ return (
+ <div className={cn('border border-border rounded-[10px] bg-card p-3.5 space-y-3', className)}>
+ <div className="flex items-center gap-2.5">
+ <div className="w-7 h-7 rounded-lg bg-secondary flex items-center justify-center shrink-0">
+ <Icon size={14} className="text-accent" />
+ </div>
+ <div className="min-w-0 flex-1">
+ <div className="text-xs font-bold text-foreground">{title}</div>
+ {hint && <div className="text-[11px] text-muted-foreground">{hint}</div>}
+ </div>
+ {action}
+ </div>
+ {children}
+ </div>
+ );
+}
diff --git a/packages/ui/src/export/components/ExportPreviewModal.tsx b/packages/ui/src/export/components/ExportPreviewModal.tsx
index 562bc87..a43e4c0 100644
--- a/packages/ui/src/export/components/ExportPreviewModal.tsx
+++ b/packages/ui/src/export/components/ExportPreviewModal.tsx
@@ -13,9 +13,9 @@ import { STEP_SECONDS } from '@mimik/core/export/video-support';
import type { Guide, Screenshot, Step } from '@mimik/core/guides/types';
import { FileCode, FileDown, FileImage, FileText, Loader2, Video } from 'lucide-react';
import { lazy, Suspense, useEffect, useState } from 'react';
+import { Switch } from '../../common/components/Switch';
import { Button } from '../../components/ui/button';
import { Dialog, DialogContent, DialogHeader, DialogTitle } from '../../components/ui/dialog';
-
import { type ExportFormat, useGuideExport } from '../hooks/use-guide-export';
import { useVideoPreview } from '../hooks/use-video-preview';
@@ -92,21 +92,13 @@ export function ExportPreviewModal({ open, onOpenChange, guide, steps, screensho
<div className="text-[12px] font-semibold text-foreground">{label}</div>
<div className="text-[10px] text-muted-foreground leading-snug">{hint}</div>
</div>
- <button
- type="button"
- aria-label={label}
- aria-pressed={Boolean(options[key])}
- onClick={() => update({ [key]: !options[key] } as Partial<ExportOptions>)}
- className={`w-9 h-5 rounded-full transition-colors relative shrink-0 mt-0.5 ${
- options[key] ? '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 ${
- options[key] ? 'translate-x-4' : 'translate-x-0'
- }`}
+ <div className="mt-0.5 flex shrink-0">
+ <Switch
+ checked={Boolean(options[key])}
+ label={label}
+ onChange={(next) => update({ [key]: next } as Partial<ExportOptions>)}
/>
- </button>
+ </div>
</div>
))}
</div>
diff --git a/packages/ui/src/index.ts b/packages/ui/src/index.ts
index b52ded4..0c731ef 100644
--- a/packages/ui/src/index.ts
+++ b/packages/ui/src/index.ts
@@ -6,8 +6,10 @@ export { SecretInput } from './ai/components/SecretInput';
export { useAiSettings } from './ai/hooks/use-ai-settings';
export { useKeyCheck } from './ai/hooks/use-key-check';
export { ColorPicker } from './annotation/components/ColorPicker';
+export { BrandingSettings } from './branding/components/BrandingSettings';
export { CameraMascot } from './common/components/CameraMascot';
export { FaviconImg } from './common/components/FaviconImg';
+export { SettingsCard } from './common/components/SettingsCard';
export { Switch } from './common/components/Switch';
export { getDomainInitial } from './common/lib/domain-initial';
export { formatRelativeTime } from './common/lib/format-relative-time';
diff --git a/src/locales/de.yml b/src/locales/de.yml
index 7fc6342..17fc310 100644
--- a/src/locales/de.yml
+++ b/src/locales/de.yml
@@ -189,8 +189,6 @@ desktop:
cardKeyboardHint: "Was die Tastatur zur Anleitung beiträgt"
captureModeHint: "Fenster folgt der App, die du anklickst."
showCursorHint: "Zeichnet einen Zeiger an die Klickstelle."
- markerColour: "Markierungsfarbe"
- markerColourHint: "Der Rahmen um das Angeklickte und die Akzentfarbe in Exporten."
screenshotDelayHint: "Wartezeit vor dem Screenshot, für Menüs mit Animation."
keepClicksBeyondAreaHint: "Nur im Bereichsmodus. Diese Schritte zeigen trotzdem den Bereich."
typingDebounceHint: "Eine so lange Pause beendet den Schritt."
diff --git a/src/locales/en.yml b/src/locales/en.yml
index f743f2d..6eba324 100644
--- a/src/locales/en.yml
+++ b/src/locales/en.yml
@@ -189,8 +189,6 @@ desktop:
cardKeyboardHint: "What the keyboard adds to a guide"
captureModeHint: "Window follows the app you click."
showCursorHint: "Draws a pointer where you clicked."
- markerColour: "Marker colour"
- markerColourHint: "The outline around what you clicked, and the accent in exports."
screenshotDelayHint: "Wait before taking the screenshot, for menus that animate."
keepClicksBeyondAreaHint: "Area mode only. Those steps still show the area."
typingDebounceHint: "A pause this long ends the step."
diff --git a/src/locales/es.yml b/src/locales/es.yml
index 194c843..178cfa3 100644
--- a/src/locales/es.yml
+++ b/src/locales/es.yml
@@ -189,8 +189,6 @@ desktop:
cardKeyboardHint: "Lo que el teclado añade a una guía"
captureModeHint: "Ventana sigue a la app en la que haces clic."
showCursorHint: "Dibuja un puntero donde hiciste clic."
- markerColour: "Color del marcador"
- markerColourHint: "El contorno de lo que pulsaste y el color de acento en las exportaciones."
screenshotDelayHint: "Espera antes de la captura, para menús con animación."
keepClicksBeyondAreaHint: "Solo en modo Área. Esos pasos siguen mostrando el área."
typingDebounceHint: "Una pausa así de larga termina el paso."
diff --git a/src/locales/fr.yml b/src/locales/fr.yml
index b7c7501..fa509b4 100644
--- a/src/locales/fr.yml
+++ b/src/locales/fr.yml
@@ -189,8 +189,6 @@ desktop:
cardKeyboardHint: "Ce que le clavier ajoute au guide"
captureModeHint: "Fenêtre suit l’application sur laquelle vous cliquez."
showCursorHint: "Dessine un pointeur là où vous avez cliqué."
- markerColour: "Couleur du repère"
- markerColourHint: "Le contour de l’élément cliqué, et l’accent des exports."
screenshotDelayHint: "Attente avant la capture, pour les menus animés."
keepClicksBeyondAreaHint: "Mode Zone uniquement. Ces étapes montrent toujours la zone."
typingDebounceHint: "Une pause de cette durée termine l’étape."
diff --git a/src/locales/pt-BR.yml b/src/locales/pt-BR.yml
index 2d685c1..cf03096 100644
--- a/src/locales/pt-BR.yml
+++ b/src/locales/pt-BR.yml
@@ -189,8 +189,6 @@ desktop:
cardKeyboardHint: "O que o teclado adiciona ao guia"
captureModeHint: "Janela acompanha o app em que você clica."
showCursorHint: "Desenha um ponteiro onde você clicou."
- markerColour: "Cor do marcador"
- markerColourHint: "O contorno do que você clicou e a cor de destaque nas exportações."
screenshotDelayHint: "Espera antes da captura, para menus com animação."
keepClicksBeyondAreaHint: "Só no modo Área. Esses passos ainda mostram a área."
typingDebounceHint: "Uma pausa desse tamanho encerra o passo."
diff --git a/src/locales/zh-CN.yml b/src/locales/zh-CN.yml
index b43ec28..0e4ffc1 100644
--- a/src/locales/zh-CN.yml
+++ b/src/locales/zh-CN.yml
@@ -189,8 +189,6 @@ desktop:
cardKeyboardHint: "键盘为指南添加的内容"
captureModeHint: "窗口模式跟随你点击的应用。"
showCursorHint: "在点击位置绘制指针。"
- markerColour: "标记颜色"
- markerColourHint: "点击目标周围的轮廓,以及导出文件的强调色。"
screenshotDelayHint: "截图前等待,适用于带动画的菜单。"
keepClicksBeyondAreaHint: "仅限区域模式。这些步骤仍显示该区域。"
typingDebounceHint: "停顿这么久即结束该步骤。"
diff --git a/src/ui/shared/SettingsView.tsx b/src/ui/shared/SettingsView.tsx
index 6f778d3..2391e78 100644
--- a/src/ui/shared/SettingsView.tsx
+++ b/src/ui/shared/SettingsView.tsx
@@ -4,47 +4,27 @@ import { type AIProviderKey, providerOrDefault } from '@mimik/core/capture/ai/mo
import { resolveVoiceApiKey } from '@mimik/core/capture/voice/api-key';
import type { VoiceProvider } from '@mimik/core/capture/voice/transcribe';
import { i18n } from '@mimik/core/env';
-import { type BrandLogo, defaultFooterLine, makeBrandLogo } from '@mimik/core/export/branding';
-import { DEFAULT_TARGET_COLOR, TARGET_COLORS } from '@mimik/core/screenshot/types';
import {
AiSettings,
+ BrandingSettings,
Button,
- ColorPicker,
- Input,
KeyStatusNote,
ModelList,
- Popover,
- PopoverContent,
- PopoverTrigger,
SecretInput,
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
+ SettingsCard,
+ Switch,
} from '@mimik/ui';
-import {
- ArrowLeft,
- Bug,
- Check,
- ChevronDown,
- ChevronRight,
- EyeOff,
- ImageIcon,
- Mic,
- Shield,
- Sparkles,
- Star,
- Target,
- Trash2,
- TriangleAlert,
-} from 'lucide-react';
-import { useEffect, useRef, useState } from 'react';
+import { ArrowLeft, Bug, Check, ChevronRight, EyeOff, Mic, Shield, Sparkles, Star, TriangleAlert } from 'lucide-react';
+import { useEffect, useState } from 'react';
import { localStorage } from '@/lib/browser-api/local-storage';
import { useKeyCheck } from '@/ui/shared/hooks/use-key-check';
import { useSettingsAutosave } from '@/ui/shared/hooks/use-settings-autosave';
import { MicrophonePicker } from '@/ui/shared/MicrophonePicker';
-import { footerPresets } from './lib/footer-presets';
interface SettingsViewProps {
onBack?: () => void;
@@ -59,11 +39,6 @@ export function SettingsView({ onBack }: SettingsViewProps) {
const [voiceProvider, setVoiceProvider] = useState<VoiceProvider>('openai');
const [voiceApiKey, setVoiceApiKey] = useState('');
const [voiceMicrophoneId, setVoiceMicrophoneId] = useState('');
- const [targetColor, setTargetColor] = useState<string>(DEFAULT_TARGET_COLOR);
- const [brandLogo, setBrandLogo] = useState<BrandLogo | null>(null);
- const [brandFooter, setBrandFooter] = useState('');
- const [brandAttribution, setBrandAttribution] = useState(true);
- const logoInputRef = useRef<HTMLInputElement>(null);
const [blurPresets, setBlurPresets] = useState<Record<PresetKey, boolean>>({
email: true,
phone: true,
@@ -86,10 +61,6 @@ export function SettingsView({ onBack }: SettingsViewProps) {
'voiceProvider',
'voiceApiKey',
'voiceMicrophoneId',
- 'targetColor',
- 'brandLogo',
- 'brandFooter',
- 'brandAttribution',
])
.then((result) => {
const p = providerOrDefault(result.aiProvider);
@@ -99,10 +70,6 @@ export function SettingsView({ onBack }: SettingsViewProps) {
setVoiceProvider((result.voiceProvider as VoiceProvider) || 'openai');
if (result.voiceApiKey) setVoiceApiKey(result.voiceApiKey as string);
if (result.voiceMicrophoneId) setVoiceMicrophoneId(result.voiceMicrophoneId as string);
- if (result.targetColor) setTargetColor(result.targetColor as string);
- if (result.brandLogo) setBrandLogo(result.brandLogo as BrandLogo);
- setBrandFooter(typeof result.brandFooter === 'string' ? result.brandFooter : defaultFooterLine());
- if (result.brandAttribution === false) setBrandAttribution(false);
setLoaded(true);
});
}, []);
@@ -112,18 +79,9 @@ export function SettingsView({ onBack }: SettingsViewProps) {
voiceProvider,
voiceApiKey,
voiceMicrophoneId,
- targetColor,
- brandLogo,
- brandFooter,
- brandAttribution,
};
- const { saved } = useSettingsAutosave(stored, loaded);
-
- const handleLogoPick = async (file: File | undefined) => {
- if (!file) return;
- setBrandLogo(await makeBrandLogo(file));
- };
+ const { saved, queue } = useSettingsAutosave(stored, loaded);
const voiceKey = resolveVoiceApiKey({ voiceProvider, voiceApiKey, aiProvider: provider, aiApiKey: apiKey });
@@ -169,135 +127,9 @@ export function SettingsView({ onBack }: SettingsViewProps) {
}}
/>
- <div className="border border-border rounded-[10px] p-3.5 flex items-center justify-between gap-3">
- <div className="flex items-center gap-2.5">
- <div className="w-7 h-7 rounded-lg bg-secondary flex items-center justify-center shrink-0">
- <Target size={14} className="text-accent" />
- </div>
- <div>
- <div className="text-xs font-bold text-foreground">{i18n.t('settings.targetColor')}</div>
- <div className="text-[11px] text-muted-foreground">{i18n.t('settings.targetColorHint')}</div>
- </div>
- </div>
- <Popover>
- <PopoverTrigger asChild>
- <button
- type="button"
- className="flex items-center gap-2 shrink-0 border border-border rounded-lg px-2 py-1.5 text-[11px] text-foreground hover:border-accent"
- >
- <span
- className="w-[22px] h-[22px] rounded-full border border-foreground/15"
- style={{ backgroundColor: targetColor }}
- />
- <code className="tabular-nums">{targetColor.toUpperCase()}</code>
- <ChevronDown size={12} className="opacity-60" />
- </button>
- </PopoverTrigger>
- <PopoverContent align="end" className="w-56 p-2.5">
- <ColorPicker value={targetColor} presets={TARGET_COLORS} onChange={setTargetColor} />
- </PopoverContent>
- </Popover>
- </div>
-
- <div className="border border-border rounded-[10px] p-3.5 space-y-3">
- <div className="flex items-center gap-2.5">
- <div className="w-7 h-7 rounded-lg bg-secondary flex items-center justify-center">
- <ImageIcon size={14} className="text-accent" />
- </div>
- <span className="text-xs font-bold text-foreground">{i18n.t('settings.branding')}</span>
- </div>
-
- <div>
- <label className="block text-[11px] font-semibold text-foreground mb-1">
- {i18n.t('settings.brandLogo')}
- </label>
- <input
- ref={logoInputRef}
- type="file"
- accept="image/png,image/jpeg,image/svg+xml,image/webp"
- className="hidden"
- onChange={(e) => handleLogoPick(e.target.files?.[0])}
- />
- <div className="flex items-center gap-2.5">
- {brandLogo && (
- <img
- src={brandLogo.dataUrl}
- alt=""
- className="h-9 max-w-[92px] object-contain rounded border border-border bg-secondary p-1"
- />
- )}
- <button
- type="button"
- onClick={() => logoInputRef.current?.click()}
- className="border border-border rounded-lg px-2.5 py-1.5 text-[11px] font-medium text-foreground hover:border-accent transition-colors"
- >
- {brandLogo ? i18n.t('settings.replaceLogo') : i18n.t('settings.uploadLogo')}
- </button>
- {brandLogo && (
- <button
- onClick={() => setBrandLogo(null)}
- aria-label={i18n.t('settings.removeLogo')}
- className="w-7 h-7 rounded-lg flex items-center justify-center text-muted-foreground hover:text-foreground hover:bg-secondary transition-colors"
- >
- <Trash2 size={14} />
- </button>
- )}
- </div>
- </div>
-
- <div>
- <label className="block text-[11px] font-semibold text-foreground mb-1">
- {i18n.t('settings.footerLine')}
- </label>
- <Input
- value={brandFooter}
- onChange={(e) => setBrandFooter(e.target.value)}
- placeholder={i18n.t('settings.footerLinePlaceholder')}
- className="h-8 text-[13px] rounded-lg border-border"
- />
- <div className="flex flex-wrap gap-1.5 mt-2">
- {footerPresets().map((preset) => (
- <button
- key={preset}
- type="button"
- onClick={() => setBrandFooter(preset)}
- className={`px-2 py-1 rounded-md border text-[10px] transition-colors ${
- brandFooter === preset
- ? 'border-accent text-accent'
- : 'border-border text-muted-foreground hover:border-accent hover:text-foreground'
- }`}
- >
- {preset}
- </button>
- ))}
- </div>
- </div>
-
- <div className="flex items-center justify-between gap-3 pt-1">
- <div className="text-[11px] font-semibold text-foreground">{i18n.t('settings.attribution')}</div>
- <button
- onClick={() => setBrandAttribution((prev) => !prev)}
- className={`w-9 h-5 rounded-full transition-colors relative shrink-0 ${
- brandAttribution ? '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 ${
- brandAttribution ? 'translate-x-4' : 'translate-x-0'
- }`}
- />
- </button>
- </div>
- </div>
-
- <div className="border border-border rounded-[10px] p-3.5 space-y-3">
- <div className="flex items-center gap-2.5">
- <div className="w-7 h-7 rounded-lg bg-secondary flex items-center justify-center">
- <Mic size={14} className="text-accent" />
- </div>
- <span className="text-xs font-bold text-foreground">{i18n.t('settings.voiceNarration')}</span>
- </div>
+ <BrandingSettings onChange={queue} />
+ <SettingsCard icon={Mic} title={i18n.t('settings.voiceNarration')}>
<div>
<label className="block text-[11px] font-semibold text-foreground mb-1">
{i18n.t('settings.provider')}
@@ -360,43 +192,29 @@ export function SettingsView({ onBack }: SettingsViewProps) {
{import.meta.env.BROWSER !== 'firefox' && (
<MicrophonePicker value={voiceMicrophoneId} onChange={setVoiceMicrophoneId} triggerClassName="h-8" />
)}
- </div>
-
- <div className="border border-border rounded-[10px] p-3.5 space-y-1">
- <div className="flex items-center gap-2.5 mb-2">
- <div className="w-7 h-7 rounded-lg bg-secondary flex items-center justify-center">
- <EyeOff size={14} className="text-accent" />
- </div>
- <span className="text-xs font-bold text-foreground">{i18n.t('settings.smartBlur')}</span>
- </div>
+ </SettingsCard>
+ <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>
- <button
- onClick={() =>
+ <Switch
+ checked={blurPresets[key]}
+ label={i18n.t(BLUR_PRESET_I18N[key])}
+ onChange={(on) =>
setBlurPresets((prev) => {
- const next = { ...prev, [key]: !prev[key] };
+ const next = { ...prev, [key]: on };
localStorage.set({ blurPresets: next });
return next;
})
}
- className={`w-9 h-5 rounded-full transition-colors relative ${
- blurPresets[key] ? '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 ${
- blurPresets[key] ? 'translate-x-4' : 'translate-x-0'
- }`}
- />
- </button>
+ />
</div>
))}
- </div>
+ </SettingsCard>
<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" />