π¬ 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): give every component, hook and function its own file
Luis Ortiz324e10b0d74c
diff --git a/biome.json b/biome.jsonindex a447d9d..15b5b28 100644--- a/biome.json+++ b/biome.json@@ -108,6 +108,29 @@}}}+ },+ {+ "includes": ["packages/ui/src/**/*.ts", "packages/ui/src/**/*.tsx", "!packages/ui/src/components/ui/**"],+ "linter": {+ "rules": {+ "performance": {+ "noBarrelFile": "error"+ },+ "style": {+ "useComponentExportOnlyModules": "error"+ }+ }+ }+ },+ {+ "includes": ["packages/ui/src/index.ts"],+ "linter": {+ "rules": {+ "performance": {+ "noBarrelFile": "off"+ }+ }+ }}]}diff --git a/packages/ui/package.json b/packages/ui/package.jsonindex fec20c0..122107f 100644--- a/packages/ui/package.json+++ b/packages/ui/package.json@@ -8,6 +8,6 @@},"sideEffects": ["**/*.css",- "./src/common/lib/utils.ts"+ "./src/common/lib/dayjs-locale.ts"]}diff --git a/packages/ui/src/ai/components/AiSettings.tsx b/packages/ui/src/ai/components/AiSettings.tsxindex 8f17a5a..177f11d 100644--- a/packages/ui/src/ai/components/AiSettings.tsx+++ b/packages/ui/src/ai/components/AiSettings.tsx@@ -1,19 +1,16 @@import { AI_PROVIDERS, type AIProviderKey, CUSTOM_MODEL_VALUE } from '@mimik/core/capture/ai/models';import { AI_LANGUAGES, type AILanguageCode } from '@mimik/core/capture/ai/prompts';import { i18n } from '@mimik/core/env';-import {- type KeyStatus,- KeyStatusNote,- type KeyWarning,- KeyWarningNote,- ModelList,- SecretInput,-} from '@mimik/ui/ai/components/key-status';+import { KeyStatusNote } from '@mimik/ui/ai/components/KeyStatusNote';+import { KeyWarningNote } from '@mimik/ui/ai/components/KeyWarningNote';+import { SecretInput } from '@mimik/ui/ai/components/SecretInput';import { useAiSettings } from '@mimik/ui/ai/hooks/use-ai-settings';import { Button } from '@mimik/ui/components/ui/button';import { Input } from '@mimik/ui/components/ui/input';import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@mimik/ui/components/ui/select';import { Globe, Sparkles, TriangleAlert } from 'lucide-react';+import type { KeyStatus, KeyWarning } from '../types';+import { ModelList } from './ModelList';export interface KeyCheck {status: KeyStatus;diff --git a/packages/ui/src/ai/components/KeyStatusNote.tsx b/packages/ui/src/ai/components/KeyStatusNote.tsxnew file mode 100644index 0000000..569dd76--- /dev/null+++ b/packages/ui/src/ai/components/KeyStatusNote.tsx@@ -0,0 +1,42 @@+import { i18n } from '@mimik/core/env';+import { Check } from 'lucide-react';+import type { KeyStatus } from '../types';++export function KeyStatusNote({ status }: { status: KeyStatus }) {+ if (status === 'checking') {+ return <p className="mt-1 text-[11px] text-muted-foreground">{i18n.t('settings.validatingKey')}</p>;+ }+ if (status === 'valid') {+ return (+ <p className="mt-1 text-[11px] flex items-center gap-1" style={{ color: 'var(--color-success)' }}>+ <Check size={11} />+ {i18n.t('settings.keyValid')}+ </p>+ );+ }+ if (status === 'rejected') {+ return (+ <p className="mt-1 text-[11px] text-destructive" role="alert">+ {i18n.t('settings.keyInvalid')}+ </p>+ );+ }+ if (status === 'unreachable') {+ return <p className="mt-1 text-[11px] text-muted-foreground">{i18n.t('settings.keyUnreachable')}</p>;+ }+ if (status === 'model-required') {+ return (+ <p className="mt-1 text-[11px] text-destructive" role="alert">+ {i18n.t('settings.keyModelRequired')}+ </p>+ );+ }+ if (status === 'model-invalid') {+ return (+ <p className="mt-1 text-[11px] text-destructive" role="alert">+ {i18n.t('settings.keyModelInvalid')}+ </p>+ );+ }+ return null;+}diff --git a/packages/ui/src/ai/components/KeyWarningNote.tsx b/packages/ui/src/ai/components/KeyWarningNote.tsxnew file mode 100644index 0000000..592bb26--- /dev/null+++ b/packages/ui/src/ai/components/KeyWarningNote.tsx@@ -0,0 +1,13 @@+import { i18n } from '@mimik/core/env';+import { TriangleAlert } from 'lucide-react';+import type { KeyWarning } from '../types';++export function KeyWarningNote({ warning }: { warning: KeyWarning | null }) {+ if (!warning) return null;+ return (+ <p className="mt-1 flex items-start gap-1.5 text-[10px] text-foreground leading-relaxed" role="status">+ <TriangleAlert size={11} className="shrink-0 mt-0.5 text-destructive" />+ <span>{i18n.t('settings.keyCannotSpend')}</span>+ </p>+ );+}diff --git a/packages/ui/src/ai/components/ModelList.tsx b/packages/ui/src/ai/components/ModelList.tsxnew file mode 100644index 0000000..c5dca88--- /dev/null+++ b/packages/ui/src/ai/components/ModelList.tsx@@ -0,0 +1,21 @@+import { i18n } from '@mimik/core/env';++export function ModelList({ models }: { models: string[] }) {+ return (+ <div className="mt-1.5 rounded-lg bg-secondary px-2.5 py-2">+ <p className="text-[10px] font-semibold text-muted-foreground mb-1">+ {i18n.t('settings.modelsFound', [String(models.length)])}+ </p>+ <ul+ className="max-h-24 overflow-y-auto space-y-0.5"+ aria-label={i18n.t('settings.modelsFound', [String(models.length)])}+ >+ {models.map((id) => (+ <li key={id} className="text-[10px] text-foreground truncate font-mono">+ {id}+ </li>+ ))}+ </ul>+ </div>+ );+}diff --git a/packages/ui/src/ai/components/SecretInput.tsx b/packages/ui/src/ai/components/SecretInput.tsxnew file mode 100644index 0000000..1b5af9f--- /dev/null+++ b/packages/ui/src/ai/components/SecretInput.tsx@@ -0,0 +1,42 @@+import { i18n } from '@mimik/core/env';+import { Input } from '@mimik/ui/components/ui/input';+import { Eye, EyeOff } from 'lucide-react';+import { useState } from 'react';++export function SecretInput({+ value,+ onChange,+ placeholder,+ className,+ buttonClassName,+}: {+ value: string;+ onChange: (next: string) => void;+ placeholder?: string;+ className?: string;+ buttonClassName?: string;+}) {+ const [revealed, setRevealed] = useState(false);+ const Icon = revealed ? EyeOff : Eye;+ return (+ <div className="relative flex-1 min-w-0">+ <Input+ type={revealed ? 'text' : 'password'}+ value={value}+ onChange={(e) => onChange(e.target.value)}+ placeholder={placeholder}+ className={`pr-8 ${className ?? ''}`}+ />+ <button+ type="button"+ onClick={() => setRevealed((on) => !on)}+ aria-pressed={revealed}+ aria-label={i18n.t(revealed ? 'settings.hideKey' : 'settings.showKey')}+ title={i18n.t(revealed ? 'settings.hideKey' : 'settings.showKey')}+ className={`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors ${buttonClassName ?? ''}`}+ >+ <Icon size={13} />+ </button>+ </div>+ );+}diff --git a/packages/ui/src/ai/components/key-status.tsx b/packages/ui/src/ai/components/key-status.tsxdeleted file mode 100644index 2ccd168..0000000--- a/packages/ui/src/ai/components/key-status.tsx+++ /dev/null@@ -1,178 +0,0 @@-import { i18n } from '@mimik/core/env';-import { Input } from '@mimik/ui/components/ui/input';-import { Check, Eye, EyeOff, TriangleAlert } from 'lucide-react';-import { useCallback, useRef, useState } from 'react';--export type KeyStatus = 'checking' | 'valid' | 'rejected' | 'unreachable' | 'model-required' | 'model-invalid' | null;--export type KeyWarning = 'cannot-spend';--export function KeyStatusNote({ status }: { status: KeyStatus }) {- if (status === 'checking') {- return <p className="mt-1 text-[11px] text-muted-foreground">{i18n.t('settings.validatingKey')}</p>;- }- if (status === 'valid') {- return (- <p className="mt-1 text-[11px] flex items-center gap-1" style={{ color: 'var(--color-success)' }}>- <Check size={11} />- {i18n.t('settings.keyValid')}- </p>- );- }- if (status === 'rejected') {- return (- <p className="mt-1 text-[11px] text-destructive" role="alert">- {i18n.t('settings.keyInvalid')}- </p>- );- }- if (status === 'unreachable') {- return <p className="mt-1 text-[11px] text-muted-foreground">{i18n.t('settings.keyUnreachable')}</p>;- }- if (status === 'model-required') {- return (- <p className="mt-1 text-[11px] text-destructive" role="alert">- {i18n.t('settings.keyModelRequired')}- </p>- );- }- if (status === 'model-invalid') {- return (- <p className="mt-1 text-[11px] text-destructive" role="alert">- {i18n.t('settings.keyModelInvalid')}- </p>- );- }- return null;-}--export function KeyWarningNote({ warning }: { warning: KeyWarning | null }) {- if (!warning) return null;- return (- <p className="mt-1 flex items-start gap-1.5 text-[10px] text-foreground leading-relaxed" role="status">- <TriangleAlert size={11} className="shrink-0 mt-0.5 text-destructive" />- <span>{i18n.t('settings.keyCannotSpend')}</span>- </p>- );-}--export function ModelList({ models }: { models: string[] }) {- return (- <div className="mt-1.5 rounded-lg bg-secondary px-2.5 py-2">- <p className="text-[10px] font-semibold text-muted-foreground mb-1">- {i18n.t('settings.modelsFound', [String(models.length)])}- </p>- <ul- className="max-h-24 overflow-y-auto space-y-0.5"- aria-label={i18n.t('settings.modelsFound', [String(models.length)])}- >- {models.map((id) => (- <li key={id} className="text-[10px] text-foreground truncate font-mono">- {id}- </li>- ))}- </ul>- </div>- );-}--export function SecretInput({- value,- onChange,- placeholder,- className,- buttonClassName,-}: {- value: string;- onChange: (next: string) => void;- placeholder?: string;- className?: string;- buttonClassName?: string;-}) {- const [revealed, setRevealed] = useState(false);- const Icon = revealed ? EyeOff : Eye;- return (- <div className="relative flex-1 min-w-0">- <Input- type={revealed ? 'text' : 'password'}- value={value}- onChange={(e) => onChange(e.target.value)}- placeholder={placeholder}- className={`pr-8 ${className ?? ''}`}- />- <button- type="button"- onClick={() => setRevealed((on) => !on)}- aria-pressed={revealed}- aria-label={i18n.t(revealed ? 'settings.hideKey' : 'settings.showKey')}- title={i18n.t(revealed ? 'settings.hideKey' : 'settings.showKey')}- className={`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors ${buttonClassName ?? ''}`}- >- <Icon size={13} />- </button>- </div>- );-}--export interface KeyCheckResult {- valid: boolean;- reason?: 'rejected' | 'network' | 'model-required' | 'model-invalid';- models?: string[];- warning?: KeyWarning;-}--export type ValidateKey = (- provider: string,- apiKey: string,- baseUrl?: string,- model?: string,-) => Promise<KeyCheckResult | null>;--export function useKeyCheck(validate: ValidateKey) {- const [status, setStatus] = useState<KeyStatus>(null);- const [models, setModels] = useState<string[] | null>(null);- const [warning, setWarning] = useState<KeyWarning | null>(null);- const validated = useRef('');- const requestId = useRef(0);-- const check = useCallback(- async (provider: string, apiKey: string, baseUrl?: string, model?: string) => {- const fingerprint = `${provider}:${apiKey}:${baseUrl ?? ''}:${model ?? ''}`;- if (validated.current === fingerprint) {- setStatus('valid');- return;- }- const currentRequestId = ++requestId.current;- setStatus('checking');- setModels(null);- setWarning(null);- const result = await validate(provider, apiKey, baseUrl, model).catch(() => null);- if (requestId.current !== currentRequestId) return;- if (result?.valid) validated.current = fingerprint;- setModels(result?.models?.length ? result.models : null);- setWarning(result?.valid && result.warning ? result.warning : null);- setStatus(- result?.valid- ? 'valid'- : result?.reason === 'rejected'- ? 'rejected'- : result?.reason === 'model-required'- ? 'model-required'- : result?.reason === 'model-invalid'- ? 'model-invalid'- : 'unreachable',- );- },- [validate],- );-- const reset = useCallback(() => {- requestId.current += 1;- validated.current = '';- setStatus(null);- setModels(null);- setWarning(null);- }, []);-- return { status, models, warning, check, reset };-}diff --git a/packages/ui/src/ai/hooks/use-key-check.ts b/packages/ui/src/ai/hooks/use-key-check.tsnew file mode 100644index 0000000..03caa44--- /dev/null+++ b/packages/ui/src/ai/hooks/use-key-check.ts@@ -0,0 +1,51 @@+import { useCallback, useRef, useState } from 'react';+import type { KeyStatus, KeyWarning, ValidateKey } from '../types';++export function useKeyCheck(validate: ValidateKey) {+ const [status, setStatus] = useState<KeyStatus>(null);+ const [models, setModels] = useState<string[] | null>(null);+ const [warning, setWarning] = useState<KeyWarning | null>(null);+ const validated = useRef('');+ const requestId = useRef(0);++ const check = useCallback(+ async (provider: string, apiKey: string, baseUrl?: string, model?: string) => {+ const fingerprint = `${provider}:${apiKey}:${baseUrl ?? ''}:${model ?? ''}`;+ if (validated.current === fingerprint) {+ setStatus('valid');+ return;+ }+ const currentRequestId = ++requestId.current;+ setStatus('checking');+ setModels(null);+ setWarning(null);+ const result = await validate(provider, apiKey, baseUrl, model).catch(() => null);+ if (requestId.current !== currentRequestId) return;+ if (result?.valid) validated.current = fingerprint;+ setModels(result?.models?.length ? result.models : null);+ setWarning(result?.valid && result.warning ? result.warning : null);+ setStatus(+ result?.valid+ ? 'valid'+ : result?.reason === 'rejected'+ ? 'rejected'+ : result?.reason === 'model-required'+ ? 'model-required'+ : result?.reason === 'model-invalid'+ ? 'model-invalid'+ : 'unreachable',+ );+ },+ [validate],+ );++ const reset = useCallback(() => {+ requestId.current += 1;+ validated.current = '';+ setStatus(null);+ setModels(null);+ setWarning(null);+ }, []);++ return { status, models, warning, check, reset };+}diff --git a/packages/ui/src/ai/types.ts b/packages/ui/src/ai/types.tsnew file mode 100644index 0000000..61d26a1--- /dev/null+++ b/packages/ui/src/ai/types.ts@@ -0,0 +1,17 @@+export type KeyStatus = 'checking' | 'valid' | 'rejected' | 'unreachable' | 'model-required' | 'model-invalid' | null;++export type KeyWarning = 'cannot-spend';++export interface KeyCheckResult {+ valid: boolean;+ reason?: 'rejected' | 'network' | 'model-required' | 'model-invalid';+ models?: string[];+ warning?: KeyWarning;+}++export type ValidateKey = (+ provider: string,+ apiKey: string,+ baseUrl?: string,+ model?: string,+) => Promise<KeyCheckResult | null>;diff --git a/packages/ui/src/annotation/components/AnnotationEditor.tsx b/packages/ui/src/annotation/components/AnnotationEditor.tsxindex 02ff8de..ecbd5c3 100644--- a/packages/ui/src/annotation/components/AnnotationEditor.tsx+++ b/packages/ui/src/annotation/components/AnnotationEditor.tsx@@ -42,7 +42,6 @@ import {DropdownMenuItem,DropdownMenuTrigger,} from '@mimik/ui/components/ui/dropdown-menu';-import { Popover, PopoverContent, PopoverTrigger } from '@mimik/ui/components/ui/popover';import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@mimik/ui/components/ui/tooltip';import {ArrowUpRight,@@ -63,12 +62,20 @@ import {Type,Undo2,} from 'lucide-react';-import type { ComponentType, ReactNode } from 'react';+import type { ComponentType } from 'react';import { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';-import ColorPicker, { swatchStyle } from './ColorPicker';--type EditorMode = 'crop' | 'annotate' | 'redact';-type EditorTool = 'select' | 'crop' | 'box' | 'ellipse' | 'arrow' | 'line' | 'text' | 'redact';+import { cursorFor } from '../lib/cursor-for';+import { handleCorners } from '../lib/handle-corners';+import { hitHandle } from '../lib/hit-handle';+import { modeForTool } from '../lib/mode-for-tool';+import { selectionBounds } from '../lib/selection-bounds';+import { swatchStyle } from '../lib/swatch-style';+import type { EditorTool } from '../types';+import { ArrowEndGlyph } from './ArrowEndGlyph';+import { ColorPopover } from './ColorPopover';+import { MenuPopover } from './MenuPopover';+import { Stepper } from './Stepper';+import { Tip } from './Tip';interface AnnotationEditorProps {screenshot: Screenshot;@@ -101,138 +108,9 @@ const MIN_CROP_SIZE = 20;const HANDLE_DISPLAY_SIZE = 10;const HANDLE_HIT_PX = 10;-function clampNumber(raw: string | number, min: number, max: number): number {- const n = Number(raw);- if (!Number.isFinite(n)) return min;- return Math.min(max, Math.max(min, n));-}--interface StepperProps {- label: string;- value: number;- min: number;- max: number;- step: number;- decimals?: number;- width: string;- prefix?: ReactNode;- suffix?: ReactNode;- onChange: (value: number) => void;-}--function Stepper({ label, value, min, max, step, decimals = 0, width, prefix, suffix, onChange }: StepperProps) {- const round = (n: number) => Number(n.toFixed(decimals));- return (- <Tip label={label}>- <div className="flex items-center gap-0.5 rounded-md bg-primary-foreground/10 h-6 px-1">- {prefix}- <button- type="button"- aria-label="-"- onClick={() => onChange(round(clampNumber(value - step, min, max)))}- className="w-4 h-5 rounded text-primary-foreground/70 hover:bg-primary-foreground/15 text-[13px] leading-none"- >- −- </button>- <input- value={value}- inputMode="decimal"- aria-label={label}- onChange={(e) => onChange(round(clampNumber(e.target.value, min, max)))}- className={`${width} bg-transparent text-center text-[11px] tabular-nums text-primary-foreground outline-none`}- />- <button- type="button"- aria-label="+"- onClick={() => onChange(round(clampNumber(value + step, min, max)))}- className="w-4 h-5 rounded text-primary-foreground/70 hover:bg-primary-foreground/15 text-[13px] leading-none"- >- +- </button>- {suffix}- </div>- </Tip>- );-}-const TOOLBAR_TRIGGER ='flex items-center gap-1 h-6 rounded-md bg-primary-foreground/10 px-1.5 text-primary-foreground hover:bg-primary-foreground/20';-function Tip({ label, children }: { label: string; children: ReactNode }) {- return (- <Tooltip>- <TooltipTrigger asChild>{children}</TooltipTrigger>- <TooltipContent>{label}</TooltipContent>- </Tooltip>- );-}--interface ColorPopoverProps {- label: string;- value: string;- allowNone?: boolean;- onChange: (color: string) => void;- children: ReactNode;-}--function ColorPopover({ label, value, allowNone, onChange, children }: ColorPopoverProps) {- return (- <Popover>- <Tooltip>- <TooltipTrigger asChild>- <PopoverTrigger asChild>{children}</PopoverTrigger>- </TooltipTrigger>- <TooltipContent>{label}</TooltipContent>- </Tooltip>- <PopoverContent align="center" className="w-56 p-2.5">- <ColorPicker value={value} allowNone={allowNone} onChange={onChange} />- </PopoverContent>- </Popover>- );-}--function MenuPopover({ label, children, items }: { label: string; children: ReactNode; items: ReactNode }) {- return (- <DropdownMenu>- <Tooltip>- <TooltipTrigger asChild>- <DropdownMenuTrigger asChild>{children}</DropdownMenuTrigger>- </TooltipTrigger>- <TooltipContent>{label}</TooltipContent>- </Tooltip>- <DropdownMenuContent align="center">{items}</DropdownMenuContent>- </DropdownMenu>- );-}--const ARROW_END_MARKS: Record<ArrowEnd, ReactNode> = {- none: null,- bar: <line x1="25" y1="2" x2="25" y2="10" />,- arrow: <polyline points="19,2 25,6 19,10" fill="none" />,- 'arrow-solid': <polygon points="26,6 18,2 18,10" stroke="none" />,- circle: <circle cx="22" cy="6" r="3.5" fill="none" />,- 'circle-solid': <circle cx="22" cy="6" r="3.5" stroke="none" />,- square: <rect x="18.5" y="2.5" width="7" height="7" fill="none" />,- 'square-solid': <rect x="18.5" y="2.5" width="7" height="7" stroke="none" />,-};--function ArrowEndGlyph({ end }: { end: ArrowEnd }) {- return (- <svg- width="30"- height="12"- viewBox="0 0 30 12"- stroke="currentColor"- strokeWidth="1.6"- fill="currentColor"- aria-hidden="true"- >- <line x1="3" y1="6" x2={end === 'none' ? 27 : 19} y2="6" />- {ARROW_END_MARKS[end]}- </svg>- );-}-const TARGET_DASH = [8, 5];const TARGET_MARCH = [26, 10];const DASH_PERIOD = 13;@@ -249,7 +127,6 @@ const TARGET_SWEEP: [number, number, number][] = [[1, 0.35, 0.9],];-const SELECTION_GAP = 6;const DRAFT_ID = 'draft';const TARGET_ID = 'click-target';@@ -264,43 +141,6 @@ const TOOLS: { id: EditorTool; icon: ComponentType<{ size?: number }>; labelKey:{ id: 'redact', icon: EyeOff, labelKey: 'annotationEditor.toolRedact' },];-function modeForTool(tool: EditorTool): EditorMode {- if (tool === 'crop') return 'crop';- if (tool === 'redact') return 'redact';- return 'annotate';-}--function cursorFor(mode: EditorMode, tool: EditorTool, hovering: boolean, grabbing: boolean): string {- if (grabbing) return 'grabbing';- if (mode !== 'annotate') return 'crosshair';- if (hovering) return 'grab';- if (tool === 'select') return 'default';- if (tool === 'text') return 'text';- return 'crosshair';-}--function handleCorners(b: ScreenshotBounds): [Handle, number, number][] {- return [- ['nw', b.x, b.y],- ['ne', b.x + b.width, b.y],- ['sw', b.x, b.y + b.height],- ['se', b.x + b.width, b.y + b.height],- ];-}--function selectionBounds(a: Annotation, scale: number): ScreenshotBounds {- const inset = SELECTION_GAP * scale;- const b = annotationBounds(a);- return { x: b.x - inset, y: b.y - inset, width: b.width + inset * 2, height: b.height + inset * 2 };-}--function hitHandle(b: ScreenshotBounds, x: number, y: number, radius: number): Handle | null {- for (const [handle, hx, hy] of handleCorners(b)) {- if (Math.abs(x - hx) <= radius && Math.abs(y - hy) <= radius) return handle;- }- return null;-}-export default function AnnotationEditor({ screenshot, tool, onDone, onCancel }: AnnotationEditorProps) {const [activeTool, setActiveTool] = useState<EditorTool>(tool === 'crop' ? 'crop' : tool === 'redact' ? 'redact' : 'box',diff --git a/packages/ui/src/annotation/components/ArrowEndGlyph.tsx b/packages/ui/src/annotation/components/ArrowEndGlyph.tsxnew file mode 100644index 0000000..9cf60d0--- /dev/null+++ b/packages/ui/src/annotation/components/ArrowEndGlyph.tsx@@ -0,0 +1,30 @@+import type { ArrowEnd } from '@mimik/core/screenshot/types';+import type { ReactNode } from 'react';++const ARROW_END_MARKS: Record<ArrowEnd, ReactNode> = {+ none: null,+ bar: <line x1="25" y1="2" x2="25" y2="10" />,+ arrow: <polyline points="19,2 25,6 19,10" fill="none" />,+ 'arrow-solid': <polygon points="26,6 18,2 18,10" stroke="none" />,+ circle: <circle cx="22" cy="6" r="3.5" fill="none" />,+ 'circle-solid': <circle cx="22" cy="6" r="3.5" stroke="none" />,+ square: <rect x="18.5" y="2.5" width="7" height="7" fill="none" />,+ 'square-solid': <rect x="18.5" y="2.5" width="7" height="7" stroke="none" />,+};++export function ArrowEndGlyph({ end }: { end: ArrowEnd }) {+ return (+ <svg+ width="30"+ height="12"+ viewBox="0 0 30 12"+ stroke="currentColor"+ strokeWidth="1.6"+ fill="currentColor"+ aria-hidden="true"+ >+ <line x1="3" y1="6" x2={end === 'none' ? 27 : 19} y2="6" />+ {ARROW_END_MARKS[end]}+ </svg>+ );+}diff --git a/packages/ui/src/annotation/components/ColorPicker.tsx b/packages/ui/src/annotation/components/ColorPicker.tsxindex 7a16d19..69c6f9c 100644--- a/packages/ui/src/annotation/components/ColorPicker.tsx+++ b/packages/ui/src/annotation/components/ColorPicker.tsx@@ -2,12 +2,7 @@ import { hexToHsv, hsvToHex, normalizeHex } from '@mimik/core/screenshot/color';import { SHAPE_COLORS } from '@mimik/core/screenshot/types';import { Input } from '@mimik/ui/components/ui/input';import { useRef, useState } from 'react';--export const NO_FILL_SWATCH = 'linear-gradient(45deg, #FFFFFF 44%, #EF4444 44%, #EF4444 56%, #FFFFFF 56%)';--export function swatchStyle(color: string | undefined) {- return !color || color === 'transparent' ? { backgroundImage: NO_FILL_SWATCH } : { backgroundColor: color };-}+import { swatchStyle } from '../lib/swatch-style';interface ColorPickerProps {value: string;diff --git a/packages/ui/src/annotation/components/ColorPopover.tsx b/packages/ui/src/annotation/components/ColorPopover.tsxnew file mode 100644index 0000000..c2c2db2--- /dev/null+++ b/packages/ui/src/annotation/components/ColorPopover.tsx@@ -0,0 +1,28 @@+import { Popover, PopoverContent, PopoverTrigger } from '@mimik/ui/components/ui/popover';+import { Tooltip, TooltipContent, TooltipTrigger } from '@mimik/ui/components/ui/tooltip';+import type { ReactNode } from 'react';+import ColorPicker from './ColorPicker';++export interface ColorPopoverProps {+ label: string;+ value: string;+ allowNone?: boolean;+ onChange: (color: string) => void;+ children: ReactNode;+}++export function ColorPopover({ label, value, allowNone, onChange, children }: ColorPopoverProps) {+ return (+ <Popover>+ <Tooltip>+ <TooltipTrigger asChild>+ <PopoverTrigger asChild>{children}</PopoverTrigger>+ </TooltipTrigger>+ <TooltipContent>{label}</TooltipContent>+ </Tooltip>+ <PopoverContent align="center" className="w-56 p-2.5">+ <ColorPicker value={value} allowNone={allowNone} onChange={onChange} />+ </PopoverContent>+ </Popover>+ );+}diff --git a/packages/ui/src/annotation/components/MenuPopover.tsx b/packages/ui/src/annotation/components/MenuPopover.tsxnew file mode 100644index 0000000..a3729a8--- /dev/null+++ b/packages/ui/src/annotation/components/MenuPopover.tsx@@ -0,0 +1,17 @@+import { DropdownMenu, DropdownMenuContent, DropdownMenuTrigger } from '@mimik/ui/components/ui/dropdown-menu';+import { Tooltip, TooltipContent, TooltipTrigger } from '@mimik/ui/components/ui/tooltip';+import type { ReactNode } from 'react';++export function MenuPopover({ label, children, items }: { label: string; children: ReactNode; items: ReactNode }) {+ return (+ <DropdownMenu>+ <Tooltip>+ <TooltipTrigger asChild>+ <DropdownMenuTrigger asChild>{children}</DropdownMenuTrigger>+ </TooltipTrigger>+ <TooltipContent>{label}</TooltipContent>+ </Tooltip>+ <DropdownMenuContent align="center">{items}</DropdownMenuContent>+ </DropdownMenu>+ );+}diff --git a/packages/ui/src/annotation/components/Stepper.tsx b/packages/ui/src/annotation/components/Stepper.tsxnew file mode 100644index 0000000..330462e--- /dev/null+++ b/packages/ui/src/annotation/components/Stepper.tsx@@ -0,0 +1,51 @@+import type { ReactNode } from 'react';+import { clampNumber } from '../lib/clamp-number';+import { Tip } from './Tip';++export interface StepperProps {+ label: string;+ value: number;+ min: number;+ max: number;+ step: number;+ decimals?: number;+ width: string;+ prefix?: ReactNode;+ suffix?: ReactNode;+ onChange: (value: number) => void;+}++export function Stepper({ label, value, min, max, step, decimals = 0, width, prefix, suffix, onChange }: StepperProps) {+ const round = (n: number) => Number(n.toFixed(decimals));+ return (+ <Tip label={label}>+ <div className="flex items-center gap-0.5 rounded-md bg-primary-foreground/10 h-6 px-1">+ {prefix}+ <button+ type="button"+ aria-label="-"+ onClick={() => onChange(round(clampNumber(value - step, min, max)))}+ className="w-4 h-5 rounded text-primary-foreground/70 hover:bg-primary-foreground/15 text-[13px] leading-none"+ >+ −+ </button>+ <input+ value={value}+ inputMode="decimal"+ aria-label={label}+ onChange={(e) => onChange(round(clampNumber(e.target.value, min, max)))}+ className={`${width} bg-transparent text-center text-[11px] tabular-nums text-primary-foreground outline-none`}+ />+ <button+ type="button"+ aria-label="+"+ onClick={() => onChange(round(clampNumber(value + step, min, max)))}+ className="w-4 h-5 rounded text-primary-foreground/70 hover:bg-primary-foreground/15 text-[13px] leading-none"+ >+ ++ </button>+ {suffix}+ </div>+ </Tip>+ );+}diff --git a/packages/ui/src/annotation/components/Tip.tsx b/packages/ui/src/annotation/components/Tip.tsxnew file mode 100644index 0000000..95d275f--- /dev/null+++ b/packages/ui/src/annotation/components/Tip.tsx@@ -0,0 +1,11 @@+import { Tooltip, TooltipContent, TooltipTrigger } from '@mimik/ui/components/ui/tooltip';+import type { ReactNode } from 'react';++export function Tip({ label, children }: { label: string; children: ReactNode }) {+ return (+ <Tooltip>+ <TooltipTrigger asChild>{children}</TooltipTrigger>+ <TooltipContent>{label}</TooltipContent>+ </Tooltip>+ );+}diff --git a/packages/ui/src/annotation/lib/clamp-number.ts b/packages/ui/src/annotation/lib/clamp-number.tsnew file mode 100644index 0000000..c3dda3b--- /dev/null+++ b/packages/ui/src/annotation/lib/clamp-number.ts@@ -0,0 +1,5 @@+export function clampNumber(raw: string | number, min: number, max: number): number {+ const n = Number(raw);+ if (!Number.isFinite(n)) return min;+ return Math.min(max, Math.max(min, n));+}diff --git a/packages/ui/src/annotation/lib/cursor-for.ts b/packages/ui/src/annotation/lib/cursor-for.tsnew file mode 100644index 0000000..173348d--- /dev/null+++ b/packages/ui/src/annotation/lib/cursor-for.ts@@ -0,0 +1,10 @@+import type { EditorMode, EditorTool } from '../types';++export function cursorFor(mode: EditorMode, tool: EditorTool, hovering: boolean, grabbing: boolean): string {+ if (grabbing) return 'grabbing';+ if (mode !== 'annotate') return 'crosshair';+ if (hovering) return 'grab';+ if (tool === 'select') return 'default';+ if (tool === 'text') return 'text';+ return 'crosshair';+}diff --git a/packages/ui/src/annotation/lib/handle-corners.ts b/packages/ui/src/annotation/lib/handle-corners.tsnew file mode 100644index 0000000..fc9e7a7--- /dev/null+++ b/packages/ui/src/annotation/lib/handle-corners.ts@@ -0,0 +1,11 @@+import type { ScreenshotBounds } from '@mimik/core/guides/types';+import type { Handle } from '@mimik/core/screenshot/geometry';++export function handleCorners(b: ScreenshotBounds): [Handle, number, number][] {+ return [+ ['nw', b.x, b.y],+ ['ne', b.x + b.width, b.y],+ ['sw', b.x, b.y + b.height],+ ['se', b.x + b.width, b.y + b.height],+ ];+}diff --git a/packages/ui/src/annotation/lib/hit-handle.ts b/packages/ui/src/annotation/lib/hit-handle.tsnew file mode 100644index 0000000..45a9c53--- /dev/null+++ b/packages/ui/src/annotation/lib/hit-handle.ts@@ -0,0 +1,10 @@+import type { ScreenshotBounds } from '@mimik/core/guides/types';+import type { Handle } from '@mimik/core/screenshot/geometry';+import { handleCorners } from './handle-corners';++export function hitHandle(b: ScreenshotBounds, x: number, y: number, radius: number): Handle | null {+ for (const [handle, hx, hy] of handleCorners(b)) {+ if (Math.abs(x - hx) <= radius && Math.abs(y - hy) <= radius) return handle;+ }+ return null;+}diff --git a/packages/ui/src/annotation/lib/mode-for-tool.ts b/packages/ui/src/annotation/lib/mode-for-tool.tsnew file mode 100644index 0000000..9e7d4a2--- /dev/null+++ b/packages/ui/src/annotation/lib/mode-for-tool.ts@@ -0,0 +1,7 @@+import type { EditorMode, EditorTool } from '../types';++export function modeForTool(tool: EditorTool): EditorMode {+ if (tool === 'crop') return 'crop';+ if (tool === 'redact') return 'redact';+ return 'annotate';+}diff --git a/packages/ui/src/annotation/lib/selection-bounds.ts b/packages/ui/src/annotation/lib/selection-bounds.tsnew file mode 100644index 0000000..c3067fa--- /dev/null+++ b/packages/ui/src/annotation/lib/selection-bounds.ts@@ -0,0 +1,11 @@+import type { ScreenshotBounds } from '@mimik/core/guides/types';+import { annotationBounds } from '@mimik/core/screenshot/geometry';+import type { Annotation } from '@mimik/core/screenshot/types';++const SELECTION_GAP = 6;++export function selectionBounds(a: Annotation, scale: number): ScreenshotBounds {+ const inset = SELECTION_GAP * scale;+ const b = annotationBounds(a);+ return { x: b.x - inset, y: b.y - inset, width: b.width + inset * 2, height: b.height + inset * 2 };+}diff --git a/packages/ui/src/annotation/lib/swatch-style.ts b/packages/ui/src/annotation/lib/swatch-style.tsnew file mode 100644index 0000000..874939c--- /dev/null+++ b/packages/ui/src/annotation/lib/swatch-style.ts@@ -0,0 +1,5 @@+const NO_FILL_SWATCH = 'linear-gradient(45deg, #FFFFFF 44%, #EF4444 44%, #EF4444 56%, #FFFFFF 56%)';++export function swatchStyle(color: string | undefined) {+ return !color || color === 'transparent' ? { backgroundImage: NO_FILL_SWATCH } : { backgroundColor: color };+}diff --git a/packages/ui/src/annotation/types.ts b/packages/ui/src/annotation/types.tsnew file mode 100644index 0000000..5e977fb--- /dev/null+++ b/packages/ui/src/annotation/types.ts@@ -0,0 +1,3 @@+export type EditorMode = 'crop' | 'annotate' | 'redact';++export type EditorTool = 'select' | 'crop' | 'box' | 'ellipse' | 'arrow' | 'line' | 'text' | 'redact';diff --git a/packages/ui/src/common/components/FaviconImg.tsx b/packages/ui/src/common/components/FaviconImg.tsxindex 5e3250b..7434f97 100644--- a/packages/ui/src/common/components/FaviconImg.tsx+++ b/packages/ui/src/common/components/FaviconImg.tsx@@ -1,5 +1,6 @@-import { getDomainInitial, getFaviconUrl } from '@mimik/ui/common/lib/utils';import { useState } from 'react';+import { getDomainInitial } from '../lib/domain-initial';+import { getFaviconUrl } from '../lib/favicon-url';interface FaviconImgProps {domain: string;diff --git a/packages/ui/src/common/lib/cn.ts b/packages/ui/src/common/lib/cn.tsnew file mode 100644index 0000000..9ad0df4--- /dev/null+++ b/packages/ui/src/common/lib/cn.ts@@ -0,0 +1,6 @@+import { type ClassValue, clsx } from 'clsx';+import { twMerge } from 'tailwind-merge';++export function cn(...inputs: ClassValue[]) {+ return twMerge(clsx(inputs));+}diff --git a/packages/ui/src/common/lib/dayjs-locale.ts b/packages/ui/src/common/lib/dayjs-locale.tsnew file mode 100644index 0000000..9ff1324--- /dev/null+++ b/packages/ui/src/common/lib/dayjs-locale.ts@@ -0,0 +1,30 @@+import dayjs from 'dayjs';+import relativeTime from 'dayjs/plugin/relativeTime';+import 'dayjs/locale/es';+import 'dayjs/locale/pt-br';+import 'dayjs/locale/fr';+import 'dayjs/locale/de';+import 'dayjs/locale/zh-cn';+import { i18n } from '@mimik/core/env';++dayjs.extend(relativeTime);++const DAYJS_LOCALE_MAP: Record<string, string> = {+ es: 'es',+ 'pt-BR': 'pt-br',+ pt: 'pt-br',+ fr: 'fr',+ de: 'de',+ 'zh-CN': 'zh-cn',+ zh: 'zh-cn',+};++export function getDayjsLocale(): string | undefined {+ try {+ const locale = i18n.t('meta.locale');+ if (locale && DAYJS_LOCALE_MAP[locale]) return DAYJS_LOCALE_MAP[locale];+ const key = locale?.split(/[-_]/)[0]?.toLowerCase();+ if (key && DAYJS_LOCALE_MAP[key]) return DAYJS_LOCALE_MAP[key];+ } catch {}+ return undefined;+}diff --git a/packages/ui/src/common/lib/domain-initial.ts b/packages/ui/src/common/lib/domain-initial.tsnew file mode 100644index 0000000..d73ffb3--- /dev/null+++ b/packages/ui/src/common/lib/domain-initial.ts@@ -0,0 +1,18 @@+const INITIAL_GRADIENTS = [+ ['#6366F1', '#818CF8'],+ ['#8B5CF6', '#A78BFA'],+ ['#EC4899', '#F472B6'],+ ['#14B8A6', '#2DD4BF'],+ ['#F59E0B', '#FBBF24'],+ ['#3B82F6', '#60A5FA'],+] as const;++export function getDomainInitial(domain: string): { letter: string; gradient: readonly [string, string] } {+ const letter = domain.charAt(0).toUpperCase();+ let hash = 0;+ for (let i = 0; i < domain.length; i++) {+ hash = (hash * 31 + domain.charCodeAt(i)) | 0;+ }+ const gradient = INITIAL_GRADIENTS[Math.abs(hash) % INITIAL_GRADIENTS.length];+ return { letter, gradient };+}diff --git a/packages/ui/src/common/lib/favicon-url.ts b/packages/ui/src/common/lib/favicon-url.tsnew file mode 100644index 0000000..b7f92c5--- /dev/null+++ b/packages/ui/src/common/lib/favicon-url.ts@@ -0,0 +1,8 @@+export function getFaviconUrl(url: string, size = 64): string {+ try {+ const full = /^https?:\/\//i.test(url) ? url : `https://${url}`;+ return `https://t1.gstatic.com/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&url=${encodeURIComponent(full)}&size=${size}&drop_404_icon=true`;+ } catch {+ return '';+ }+}diff --git a/packages/ui/src/common/lib/format-date-short.ts b/packages/ui/src/common/lib/format-date-short.tsnew file mode 100644index 0000000..9b0230e--- /dev/null+++ b/packages/ui/src/common/lib/format-date-short.ts@@ -0,0 +1,8 @@+import dayjs from 'dayjs';+import { getDayjsLocale } from './dayjs-locale';++export function formatDateShort(ts: number): string {+ const locale = getDayjsLocale();+ const d = locale ? dayjs(ts).locale(locale) : dayjs(ts);+ return d.format('MMM D');+}diff --git a/packages/ui/src/common/lib/format-date-time.ts b/packages/ui/src/common/lib/format-date-time.tsnew file mode 100644index 0000000..77a2d96--- /dev/null+++ b/packages/ui/src/common/lib/format-date-time.ts@@ -0,0 +1,8 @@+import dayjs from 'dayjs';+import { getDayjsLocale } from './dayjs-locale';++export function formatDateTime(ts: number): string {+ const locale = getDayjsLocale();+ const d = locale ? dayjs(ts).locale(locale) : dayjs(ts);+ return d.format('MMM D, YYYY β h:mm A');+}diff --git a/packages/ui/src/common/lib/format-relative-time.ts b/packages/ui/src/common/lib/format-relative-time.tsnew file mode 100644index 0000000..d56364d--- /dev/null+++ b/packages/ui/src/common/lib/format-relative-time.ts@@ -0,0 +1,7 @@+import dayjs from 'dayjs';+import { getDayjsLocale } from './dayjs-locale';++export function formatRelativeTime(ts: number): string {+ const locale = getDayjsLocale();+ return locale ? dayjs(ts).locale(locale).fromNow() : dayjs(ts).fromNow();+}diff --git a/packages/ui/src/common/lib/utils.ts b/packages/ui/src/common/lib/utils.tsdeleted file mode 100644index f5edcbf..0000000--- a/packages/ui/src/common/lib/utils.ts+++ /dev/null@@ -1,85 +0,0 @@-export { extractDomain, getMostCommonDomain } from '@/core/guides/domain';--import { type ClassValue, clsx } from 'clsx';-import dayjs from 'dayjs';-import relativeTime from 'dayjs/plugin/relativeTime';-import 'dayjs/locale/es';-import 'dayjs/locale/pt-br';-import 'dayjs/locale/fr';-import 'dayjs/locale/de';-import 'dayjs/locale/zh-cn';-import { i18n } from '@mimik/core/env';-import { twMerge } from 'tailwind-merge';--dayjs.extend(relativeTime);--const DAYJS_LOCALE_MAP: Record<string, string> = {- es: 'es',- 'pt-BR': 'pt-br',- pt: 'pt-br',- fr: 'fr',- de: 'de',- 'zh-CN': 'zh-cn',- zh: 'zh-cn',-};--function getDayjsLocale(): string | undefined {- try {- const locale = i18n.t('meta.locale');- if (locale && DAYJS_LOCALE_MAP[locale]) return DAYJS_LOCALE_MAP[locale];- const key = locale?.split(/[-_]/)[0]?.toLowerCase();- if (key && DAYJS_LOCALE_MAP[key]) return DAYJS_LOCALE_MAP[key];- } catch {}- return undefined;-}--export function cn(...inputs: ClassValue[]) {- return twMerge(clsx(inputs));-}--export { formatDate } from '@mimik/core/export/utils';--export function formatDateShort(ts: number): string {- const locale = getDayjsLocale();- const d = locale ? dayjs(ts).locale(locale) : dayjs(ts);- return d.format('MMM D');-}--export function formatDateTime(ts: number): string {- const locale = getDayjsLocale();- const d = locale ? dayjs(ts).locale(locale) : dayjs(ts);- return d.format('MMM D, YYYY β h:mm A');-}--export function formatRelativeTime(ts: number): string {- const locale = getDayjsLocale();- return locale ? dayjs(ts).locale(locale).fromNow() : dayjs(ts).fromNow();-}--export function getFaviconUrl(url: string, size = 64): string {- try {- const full = /^https?:\/\//i.test(url) ? url : `https://${url}`;- return `https://t1.gstatic.com/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&url=${encodeURIComponent(full)}&size=${size}&drop_404_icon=true`;- } catch {- return '';- }-}--const INITIAL_GRADIENTS = [- ['#6366F1', '#818CF8'],- ['#8B5CF6', '#A78BFA'],- ['#EC4899', '#F472B6'],- ['#14B8A6', '#2DD4BF'],- ['#F59E0B', '#FBBF24'],- ['#3B82F6', '#60A5FA'],-] as const;--export function getDomainInitial(domain: string): { letter: string; gradient: readonly [string, string] } {- const letter = domain.charAt(0).toUpperCase();- let hash = 0;- for (let i = 0; i < domain.length; i++) {- hash = (hash * 31 + domain.charCodeAt(i)) | 0;- }- const gradient = INITIAL_GRADIENTS[Math.abs(hash) % INITIAL_GRADIENTS.length];- return { letter, gradient };-}diff --git a/packages/ui/src/components/ui/badge.tsx b/packages/ui/src/components/ui/badge.tsxindex 1f731f1..0094342 100644--- a/packages/ui/src/components/ui/badge.tsx+++ b/packages/ui/src/components/ui/badge.tsx@@ -1,4 +1,4 @@-import { cn } from '@mimik/ui/common/lib/utils';+import { cn } from '@mimik/ui/common/lib/cn';import { cva, type VariantProps } from 'class-variance-authority';import { Slot } from 'radix-ui';import type * as React from 'react';diff --git a/packages/ui/src/components/ui/button.tsx b/packages/ui/src/components/ui/button.tsxindex 17c8718..d7c5eb2 100644--- a/packages/ui/src/components/ui/button.tsx+++ b/packages/ui/src/components/ui/button.tsx@@ -1,4 +1,4 @@-import { cn } from '@mimik/ui/common/lib/utils';+import { cn } from '@mimik/ui/common/lib/cn';import { cva, type VariantProps } from 'class-variance-authority';import { Slot } from 'radix-ui';import type * as React from 'react';diff --git a/packages/ui/src/components/ui/dialog.tsx b/packages/ui/src/components/ui/dialog.tsxindex be38b49..b489cf1 100644--- a/packages/ui/src/components/ui/dialog.tsx+++ b/packages/ui/src/components/ui/dialog.tsx@@ -1,4 +1,4 @@-import { cn } from '@mimik/ui/common/lib/utils';+import { cn } from '@mimik/ui/common/lib/cn';import { XIcon } from 'lucide-react';import { Dialog as DialogPrimitive } from 'radix-ui';import type * as React from 'react';diff --git a/packages/ui/src/components/ui/dropdown-menu.tsx b/packages/ui/src/components/ui/dropdown-menu.tsxindex f04785e..417c27b 100644--- a/packages/ui/src/components/ui/dropdown-menu.tsx+++ b/packages/ui/src/components/ui/dropdown-menu.tsx@@ -1,4 +1,4 @@-import { cn } from '@mimik/ui/common/lib/utils';+import { cn } from '@mimik/ui/common/lib/cn';import { ChevronRight } from 'lucide-react';import { DropdownMenu as DropdownMenuPrimitive } from 'radix-ui';import type * as React from 'react';diff --git a/packages/ui/src/components/ui/input.tsx b/packages/ui/src/components/ui/input.tsxindex 5b92ca3..f7765fd 100644--- a/packages/ui/src/components/ui/input.tsx+++ b/packages/ui/src/components/ui/input.tsx@@ -1,4 +1,4 @@-import { cn } from '@mimik/ui/common/lib/utils';+import { cn } from '@mimik/ui/common/lib/cn';import type * as React from 'react';function Input({ className, type, ...props }: React.ComponentProps<'input'>) {diff --git a/packages/ui/src/components/ui/popover.tsx b/packages/ui/src/components/ui/popover.tsxindex 4f1a2e0..69b3bfa 100644--- a/packages/ui/src/components/ui/popover.tsx+++ b/packages/ui/src/components/ui/popover.tsx@@ -1,4 +1,4 @@-import { cn } from '@mimik/ui/common/lib/utils';+import { cn } from '@mimik/ui/common/lib/cn';import { Popover as PopoverPrimitive } from 'radix-ui';import type * as React from 'react';diff --git a/packages/ui/src/components/ui/select.tsx b/packages/ui/src/components/ui/select.tsxindex a6aa925..fccbaa5 100644--- a/packages/ui/src/components/ui/select.tsx+++ b/packages/ui/src/components/ui/select.tsx@@ -1,4 +1,4 @@-import { cn } from '@mimik/ui/common/lib/utils';+import { cn } from '@mimik/ui/common/lib/cn';import { Check, ChevronDown } from 'lucide-react';import { Select as SelectPrimitive } from 'radix-ui';import type * as React from 'react';diff --git a/packages/ui/src/components/ui/tooltip.tsx b/packages/ui/src/components/ui/tooltip.tsxindex e3f0386..595b5f1 100644--- a/packages/ui/src/components/ui/tooltip.tsx+++ b/packages/ui/src/components/ui/tooltip.tsx@@ -1,4 +1,4 @@-import { cn } from '@mimik/ui/common/lib/utils';+import { cn } from '@mimik/ui/common/lib/cn';import { Tooltip as TooltipPrimitive } from 'radix-ui';import type * as React from 'react';diff --git a/packages/ui/src/export/components/PlayerBody.tsx b/packages/ui/src/export/components/PlayerBody.tsxnew file mode 100644index 0000000..944ecd7--- /dev/null+++ b/packages/ui/src/export/components/PlayerBody.tsx@@ -0,0 +1,76 @@+import { i18n } from '@mimik/core/env';+import type { VideoChapter } from '@mimik/core/export/video-export';+import { FullscreenButton, MediaProvider, PlayButton, useMediaRemote, useMediaState } from '@vidstack/react';+import { ChevronLeft, ChevronRight, Maximize, Minimize, Pause, Play } from 'lucide-react';+import { activeIndex } from '../lib/active-index';+import { formatClock } from '../lib/format-clock';+import { StepList } from './StepList';++const RATES = [1, 1.25, 1.5, 2];++export function PlayerBody({ chapters }: { chapters: VideoChapter[] }) {+ const remote = useMediaRemote();+ const time = useMediaState('currentTime');+ const duration = useMediaState('duration');+ const rate = useMediaState('playbackRate');+ const paused = useMediaState('paused');+ const fullscreen = useMediaState('fullscreen');++ const index = activeIndex(chapters, time);+ const seekTo = (seconds: number) => remote.seek(Math.max(0, seconds + 0.01));+ const jump = (i: number) => chapters[i] && seekTo(chapters[i].start);++ return (+ <>+ <div className="relative min-w-0 flex-1">+ <MediaProvider className="size-full [&_video]:size-full [&_video]:object-contain" />++ <div className="absolute inset-x-0 bottom-0 flex items-center gap-2 bg-gradient-to-t from-black/85 to-transparent px-3 pb-2.5 pt-8 text-white">+ <PlayButton className="rounded-md p-1 hover:bg-white/15">+ {paused ? <Play size={16} fill="currentColor" /> : <Pause size={16} fill="currentColor" />}+ </PlayButton>++ <button+ type="button"+ disabled={index <= 0}+ onClick={() => jump(index - 1)}+ aria-label={i18n.t('videoPlayer.previousStep')}+ className="rounded-md p-1 hover:bg-white/15 disabled:opacity-35 disabled:hover:bg-transparent"+ >+ <ChevronLeft size={16} />+ </button>+ <button+ type="button"+ disabled={index < 0 || index >= chapters.length - 1}+ onClick={() => jump(index + 1)}+ aria-label={i18n.t('videoPlayer.nextStep')}+ className="rounded-md p-1 hover:bg-white/15 disabled:opacity-35 disabled:hover:bg-transparent"+ >+ <ChevronRight size={16} />+ </button>++ <span className="font-mono text-[11px] tabular-nums text-white/75">+ {formatClock(time)} / {formatClock(duration)}+ </span>++ <span className="flex-1" />++ <button+ type="button"+ onClick={() => remote.changePlaybackRate(RATES[(RATES.indexOf(rate) + 1) % RATES.length])}+ aria-label={i18n.t('videoPlayer.speed')}+ className="rounded-md px-1.5 py-1 font-mono text-[11px] tabular-nums hover:bg-white/15"+ >+ {rate}x+ </button>++ <FullscreenButton className="rounded-md p-1 hover:bg-white/15">+ {fullscreen ? <Minimize size={16} /> : <Maximize size={16} />}+ </FullscreenButton>+ </div>+ </div>++ {chapters.length > 0 && <StepList chapters={chapters} index={index} onJump={jump} />}+ </>+ );+}diff --git a/packages/ui/src/export/components/StepList.tsx b/packages/ui/src/export/components/StepList.tsxnew file mode 100644index 0000000..88f5cbd--- /dev/null+++ b/packages/ui/src/export/components/StepList.tsx@@ -0,0 +1,48 @@+import { i18n } from '@mimik/core/env';+import type { StepKind, VideoChapter } from '@mimik/core/export/video-export';+import { useEffect, useRef } from 'react';+import { formatClock } from '../lib/format-clock';++const KIND_DOT: Record<StepKind, string> = {+ click: 'bg-accent',+ type: 'bg-violet-light',+ key: 'bg-violet',+ navigate: 'bg-lavender',+ note: 'bg-muted-foreground',+};++export function StepList({+ chapters,+ index,+ onJump,+}: {+ chapters: VideoChapter[];+ index: number;+ onJump: (n: number) => void;+}) {+ const list = useRef<HTMLElement>(null);++ useEffect(() => {+ list.current?.querySelectorAll('button')[index]?.scrollIntoView({ block: 'nearest' });+ }, [index]);++ return (+ <aside ref={list} className="w-[228px] shrink-0 overflow-y-auto border-l border-white/10 bg-deep">+ <div className="px-3 pb-2 pt-3 font-mono text-[9px] uppercase tracking-[0.1em] text-white/45">+ {i18n.t('videoPlayer.stepCount', [String(chapters.length)])}+ </div>+ {chapters.map((chapter, i) => (+ <button+ key={chapter.stepId}+ type="button"+ onClick={() => onJump(i)}+ className={`flex w-full items-start gap-2.5 border-l-2 px-3 py-1.5 text-left transition-colors ${i === index ? 'border-l-accent bg-white/10' : 'border-l-transparent hover:bg-white/5'}`}+ >+ <span className={`mt-1.5 size-1.5 shrink-0 rounded-full ${KIND_DOT[chapter.kind]}`} />+ <span className="min-w-0 flex-1 text-[10.5px] leading-snug text-white/80">{chapter.title}</span>+ <span className="pt-0.5 font-mono text-[9px] tabular-nums text-white/40">{formatClock(chapter.start)}</span>+ </button>+ ))}+ </aside>+ );+}diff --git a/packages/ui/src/export/components/VideoStepPlayer.tsx b/packages/ui/src/export/components/VideoStepPlayer.tsxindex d46b43a..93a396c 100644--- a/packages/ui/src/export/components/VideoStepPlayer.tsx+++ b/packages/ui/src/export/components/VideoStepPlayer.tsx@@ -1,28 +1,8 @@-import { i18n } from '@mimik/core/env';-import type { StepKind, VideoChapter } from '@mimik/core/export/video-export';+import type { VideoChapter } from '@mimik/core/export/video-export';import { FRAME_FILL } from '@mimik/core/export/video-support';-import {- FullscreenButton,- MediaPlayer,- MediaProvider,- PlayButton,- useMediaRemote,- useMediaState,-} from '@vidstack/react';-import { ChevronLeft, ChevronRight, Maximize, Minimize, Pause, Play } from 'lucide-react';-import { useEffect, useRef } from 'react';--const RATES = [1, 1.25, 1.5, 2];--const KIND_DOT: Record<StepKind, string> = {- click: 'bg-accent',- type: 'bg-violet-light',- key: 'bg-violet',- navigate: 'bg-lavender',- note: 'bg-muted-foreground',-};--export type VideoMime = 'video/mp4' | 'video/webm';+import { MediaPlayer } from '@vidstack/react';+import type { VideoMime } from '../types';+import { PlayerBody } from './PlayerBody';interface VideoStepPlayerProps {src: string;@@ -30,123 +10,6 @@ interface VideoStepPlayerProps {chapters: VideoChapter[];}-function formatClock(seconds: number): string {- const total = Number.isFinite(seconds) ? Math.max(0, Math.round(seconds)) : 0;- return `${Math.floor(total / 60)}:${String(total % 60).padStart(2, '0')}`;-}--function activeIndex(chapters: VideoChapter[], time: number): number {- for (let i = chapters.length - 1; i >= 0; i--) {- if (time >= chapters[i].start) return i;- }- return -1;-}--function StepList({- chapters,- index,- onJump,-}: {- chapters: VideoChapter[];- index: number;- onJump: (n: number) => void;-}) {- const list = useRef<HTMLElement>(null);-- useEffect(() => {- list.current?.querySelectorAll('button')[index]?.scrollIntoView({ block: 'nearest' });- }, [index]);-- return (- <aside ref={list} className="w-[228px] shrink-0 overflow-y-auto border-l border-white/10 bg-deep">- <div className="px-3 pb-2 pt-3 font-mono text-[9px] uppercase tracking-[0.1em] text-white/45">- {i18n.t('videoPlayer.stepCount', [String(chapters.length)])}- </div>- {chapters.map((chapter, i) => (- <button- key={chapter.stepId}- type="button"- onClick={() => onJump(i)}- className={`flex w-full items-start gap-2.5 border-l-2 px-3 py-1.5 text-left transition-colors ${- i === index ? 'border-l-accent bg-white/10' : 'border-l-transparent hover:bg-white/5'- }`}- >- <span className={`mt-1.5 size-1.5 shrink-0 rounded-full ${KIND_DOT[chapter.kind]}`} />- <span className="min-w-0 flex-1 text-[10.5px] leading-snug text-white/80">{chapter.title}</span>- <span className="pt-0.5 font-mono text-[9px] tabular-nums text-white/40">{formatClock(chapter.start)}</span>- </button>- ))}- </aside>- );-}--function PlayerBody({ chapters }: { chapters: VideoChapter[] }) {- const remote = useMediaRemote();- const time = useMediaState('currentTime');- const duration = useMediaState('duration');- const rate = useMediaState('playbackRate');- const paused = useMediaState('paused');- const fullscreen = useMediaState('fullscreen');-- const index = activeIndex(chapters, time);- const seekTo = (seconds: number) => remote.seek(Math.max(0, seconds + 0.01));- const jump = (i: number) => chapters[i] && seekTo(chapters[i].start);-- return (- <>- <div className="relative min-w-0 flex-1">- <MediaProvider className="size-full [&_video]:size-full [&_video]:object-contain" />-- <div className="absolute inset-x-0 bottom-0 flex items-center gap-2 bg-gradient-to-t from-black/85 to-transparent px-3 pb-2.5 pt-8 text-white">- <PlayButton className="rounded-md p-1 hover:bg-white/15">- {paused ? <Play size={16} fill="currentColor" /> : <Pause size={16} fill="currentColor" />}- </PlayButton>-- <button- type="button"- disabled={index <= 0}- onClick={() => jump(index - 1)}- aria-label={i18n.t('videoPlayer.previousStep')}- className="rounded-md p-1 hover:bg-white/15 disabled:opacity-35 disabled:hover:bg-transparent"- >- <ChevronLeft size={16} />- </button>- <button- type="button"- disabled={index < 0 || index >= chapters.length - 1}- onClick={() => jump(index + 1)}- aria-label={i18n.t('videoPlayer.nextStep')}- className="rounded-md p-1 hover:bg-white/15 disabled:opacity-35 disabled:hover:bg-transparent"- >- <ChevronRight size={16} />- </button>-- <span className="font-mono text-[11px] tabular-nums text-white/75">- {formatClock(time)} / {formatClock(duration)}- </span>-- <span className="flex-1" />-- <button- type="button"- onClick={() => remote.changePlaybackRate(RATES[(RATES.indexOf(rate) + 1) % RATES.length])}- aria-label={i18n.t('videoPlayer.speed')}- className="rounded-md px-1.5 py-1 font-mono text-[11px] tabular-nums hover:bg-white/15"- >- {rate}x- </button>-- <FullscreenButton className="rounded-md p-1 hover:bg-white/15">- {fullscreen ? <Minimize size={16} /> : <Maximize size={16} />}- </FullscreenButton>- </div>- </div>-- {chapters.length > 0 && <StepList chapters={chapters} index={index} onJump={jump} />}- </>- );-}-export default function VideoStepPlayer({ src, type, chapters }: VideoStepPlayerProps) {return (<MediaPlayerdiff --git a/packages/ui/src/export/hooks/use-video-preview.ts b/packages/ui/src/export/hooks/use-video-preview.tsindex 32b6b46..8fd4288 100644--- a/packages/ui/src/export/hooks/use-video-preview.ts+++ b/packages/ui/src/export/hooks/use-video-preview.ts@@ -4,7 +4,7 @@ import { canExportVideo } from '@mimik/core/export/video-support';import type { Guide, Screenshot, Step } from '@mimik/core/guides/types';import { useEffect, useState } from 'react';-import type { VideoMime } from '../components/VideoStepPlayer';+import type { VideoMime } from '../types';const AUTOPLAY_STEP_LIMIT = 25;diff --git a/packages/ui/src/export/lib/active-index.ts b/packages/ui/src/export/lib/active-index.tsnew file mode 100644index 0000000..39cb99a--- /dev/null+++ b/packages/ui/src/export/lib/active-index.ts@@ -0,0 +1,8 @@+import type { VideoChapter } from '@mimik/core/export/video-export';++export function activeIndex(chapters: VideoChapter[], time: number): number {+ for (let i = chapters.length - 1; i >= 0; i--) {+ if (time >= chapters[i].start) return i;+ }+ return -1;+}diff --git a/packages/ui/src/export/lib/format-clock.ts b/packages/ui/src/export/lib/format-clock.tsnew file mode 100644index 0000000..d01e343--- /dev/null+++ b/packages/ui/src/export/lib/format-clock.ts@@ -0,0 +1,4 @@+export function formatClock(seconds: number): string {+ const total = Number.isFinite(seconds) ? Math.max(0, Math.round(seconds)) : 0;+ return `${Math.floor(total / 60)}:${String(total % 60).padStart(2, '0')}`;+}diff --git a/packages/ui/src/export/types.ts b/packages/ui/src/export/types.tsnew file mode 100644index 0000000..5b26f9c--- /dev/null+++ b/packages/ui/src/export/types.ts@@ -0,0 +1 @@+export type VideoMime = 'video/mp4' | 'video/webm';diff --git a/packages/ui/src/guide/components/BlockCard.tsx b/packages/ui/src/guide/components/BlockCard.tsxindex 45fdae7..5dd43a8 100644--- a/packages/ui/src/guide/components/BlockCard.tsx+++ b/packages/ui/src/guide/components/BlockCard.tsx@@ -4,9 +4,11 @@ import { updateCallout } from '@mimik/core/guides/service';import type { CalloutVariant, Step } from '@mimik/core/guides/types';import ConfirmDialog from '@mimik/ui/common/components/ConfirmDialog';import { Tooltip, TooltipContent, TooltipTrigger } from '@mimik/ui/components/ui/tooltip';-import { DragGrip, type DragHandleProps, useCardDrag } from '@mimik/ui/guide/components/card-drag';+import { DragGrip } from '@mimik/ui/guide/components/DragGrip';import { Trash2 } from 'lucide-react';import { useEffect, useState } from 'react';+import { useCardDrag } from '../hooks/use-card-drag';+import type { DragHandleProps } from '../types';interface BlockCardProps {step: Step;diff --git a/packages/ui/src/guide/components/DragGrip.tsx b/packages/ui/src/guide/components/DragGrip.tsxnew file mode 100644index 0000000..e415d58--- /dev/null+++ b/packages/ui/src/guide/components/DragGrip.tsx@@ -0,0 +1,13 @@+import { GripVertical } from 'lucide-react';++export function DragGrip() {+ return (+ <span+ data-drag-handle=""+ aria-hidden="true"+ className="shrink-0 p-1 -m-1 cursor-grab text-border hover:text-muted-foreground"+ >+ <GripVertical size={14} />+ </span>+ );+}diff --git a/packages/ui/src/guide/components/GuideContent.tsx b/packages/ui/src/guide/components/GuideContent.tsxindex ce9b29d..b32f825 100644--- a/packages/ui/src/guide/components/GuideContent.tsx+++ b/packages/ui/src/guide/components/GuideContent.tsx@@ -1,11 +1,11 @@import { i18n, localStorage } from '@mimik/core/env';+import { formatDate } from '@mimik/core/export/utils';import { isReplayable } from '@mimik/core/guideme/session';import { actionSteps } from '@mimik/core/guides/blocks';import { getMostCommonDomain } from '@mimik/core/guides/domain';import {deleteStep,getGuide,- getScreenshotsForSteps,onGuidesChanged,updateGuideDescription,updateGuideTitle,@@ -19,15 +19,16 @@ import { useAskAi } from '@mimik/ui/ai/hooks/use-ask-ai';import AnnotationEditor from '@mimik/ui/annotation/components/AnnotationEditor';import FaviconImg from '@mimik/ui/common/components/FaviconImg';import Toast from '@mimik/ui/common/components/Toast';-import { formatDate } from '@mimik/ui/common/lib/utils';import { Tooltip, TooltipContent, TooltipTrigger } from '@mimik/ui/components/ui/tooltip';import { panel, send, tabs } from '@mimik/ui/env';-import { useFullview } from '@mimik/ui/stores/fullview';+import { useFullview } from '@mimik/ui/stores/use-fullview';import { History, Loader2, Play, Sparkles } from 'lucide-react';import { useCallback, useEffect, useMemo, useRef, useState } from 'react';import { TypeAnimation } from 'react-type-animation';import { useGuideDescription } from '../../ai/hooks/use-guide-description';import VersionHistoryPanel from '../../history/components/VersionHistoryPanel';+import { buildPreview } from '../lib/build-preview';+import type { PreviewData } from '../types';import GuideStepList from './GuideStepList';interface GuideContentProps {@@ -42,27 +43,6 @@ interface GuideData {screenshots: Map<string, Screenshot>;}-interface PreviewData {- snapshotId: string;- steps: Step[];- screenshots: Map<string, Screenshot>;-}--async function buildPreview(snapshot: Snapshot): Promise<PreviewData> {- const rows = new Map(snapshot.screenshots.map((row) => [row.id, row]));- const steps = [...snapshot.steps].sort((a, b) => a.index - b.index);- const wanted = steps.map((s) => s.screenshotId).filter((id): id is string => !!id && rows.has(id));- const live = await getScreenshotsForSteps(wanted);- const blobs = new Map([...live.values()].map((row) => [row.id, row.blob]));- const screenshots = new Map<string, Screenshot>();- for (const step of steps) {- const row = step.screenshotId ? rows.get(step.screenshotId) : undefined;- const blob = row ? blobs.get(row.id) : undefined;- if (row && blob) screenshots.set(step.id, { ...row, blob });- }- return { snapshotId: snapshot.id, steps, screenshots };-}-export default function GuideContent({ guideId, initialStepId, initialTool }: GuideContentProps) {const {setGuideTitle,diff --git a/packages/ui/src/guide/components/GuideStepList.tsx b/packages/ui/src/guide/components/GuideStepList.tsxindex 9ae3f65..1c128fb 100644--- a/packages/ui/src/guide/components/GuideStepList.tsx+++ b/packages/ui/src/guide/components/GuideStepList.tsx@@ -11,7 +11,7 @@ import CaptureTabDialog from '@mimik/ui/guide/components/CaptureTabDialog';import EmptyGuideState from '@mimik/ui/guide/components/EmptyGuideState';import InsertBlockMenu from '@mimik/ui/guide/components/InsertBlockMenu';import StepCard from '@mimik/ui/guide/components/StepCard';-import { useFullview } from '@mimik/ui/stores/fullview';+import { useFullview } from '@mimik/ui/stores/use-fullview';import { Trash2 } from 'lucide-react';import { useEffect, useRef, useState } from 'react';diff --git a/packages/ui/src/guide/components/ScreenshotView.tsx b/packages/ui/src/guide/components/ScreenshotView.tsxindex 8343a95..63dab94 100644--- a/packages/ui/src/guide/components/ScreenshotView.tsx+++ b/packages/ui/src/guide/components/ScreenshotView.tsx@@ -21,6 +21,7 @@ import ImagePlaceholder from '@mimik/ui/guide/components/ImagePlaceholder';import ReplaceImageDialog from '@mimik/ui/guide/components/ReplaceImageDialog';import { Download, ImageUp, Pencil, Trash2, ZoomIn, ZoomOut } from 'lucide-react';import { useEffect, useRef, useState } from 'react';+import { withFullViewport } from '../lib/with-full-viewport';interface ScreenshotViewProps {screenshot: Screenshot;@@ -51,13 +52,6 @@ const FRAME_EASING = 'cubic-bezier(0.22, 1, 0.36, 1)';const FRAME_TRANSITION = `width 0.4s ${FRAME_EASING}, height 0.4s ${FRAME_EASING}, left 0.4s ${FRAME_EASING}, top 0.4s ${FRAME_EASING}`;const FRAME_RATIO_EPSILON = 0.01;-function withFullViewport(screenshot: Screenshot): Screenshot {- return {- ...screenshot,- edits: { ...screenshot.edits, viewport: { x: 0, y: 0, width: screenshot.width, height: screenshot.height } },- };-}-export default function ScreenshotView({screenshot,className = '',diff --git a/packages/ui/src/guide/components/StepCard.tsx b/packages/ui/src/guide/components/StepCard.tsxindex 1f8c38a..14d7443 100644--- a/packages/ui/src/guide/components/StepCard.tsx+++ b/packages/ui/src/guide/components/StepCard.tsx@@ -6,12 +6,14 @@ import { imageDimensions, renderScreenshot } from '@mimik/core/screenshot/renderimport { useAskAi } from '@mimik/ui/ai/hooks/use-ask-ai';import ConfirmDialog from '@mimik/ui/common/components/ConfirmDialog';import { Tooltip, TooltipContent, TooltipTrigger } from '@mimik/ui/components/ui/tooltip';-import { DragGrip, type DragHandleProps, useCardDrag } from '@mimik/ui/guide/components/card-drag';+import { DragGrip } from '@mimik/ui/guide/components/DragGrip';import ImagePlaceholder from '@mimik/ui/guide/components/ImagePlaceholder';import ScreenshotView from '@mimik/ui/guide/components/ScreenshotView';import StepSourceBadge from '@mimik/ui/guide/components/StepSourceBadge';import { Check, Copy, Loader2, Trash2 } from 'lucide-react';import { useEffect, useState } from 'react';+import { useCardDrag } from '../hooks/use-card-drag';+import type { DragHandleProps } from '../types';interface StepCardProps {step: Step;diff --git a/packages/ui/src/guide/components/card-drag.tsx b/packages/ui/src/guide/hooks/use-card-drag.tssimilarity index 53%rename from packages/ui/src/guide/components/card-drag.tsxrename to packages/ui/src/guide/hooks/use-card-drag.tsindex 3ff05fa..ef0f35f 100644--- a/packages/ui/src/guide/components/card-drag.tsx+++ b/packages/ui/src/guide/hooks/use-card-drag.ts@@ -1,11 +1,5 @@-import { GripVertical } from 'lucide-react';import { useRef } from 'react';--export interface DragHandleProps {- onDragStart: (e: React.DragEvent) => void;- onDragOver: (e: React.DragEvent) => void;- onDragEnd: () => void;-}+import type { DragHandleProps } from '../types';export function useCardDrag(dragHandleProps?: DragHandleProps) {const pressedHandle = useRef(false);@@ -23,15 +17,3 @@ export function useCardDrag(dragHandleProps?: DragHandleProps) {},};}--export function DragGrip() {- return (- <span- data-drag-handle=""- aria-hidden="true"- className="shrink-0 p-1 -m-1 cursor-grab text-border hover:text-muted-foreground"- >- <GripVertical size={14} />- </span>- );-}diff --git a/packages/ui/src/guide/lib/build-preview.ts b/packages/ui/src/guide/lib/build-preview.tsnew file mode 100644index 0000000..a359889--- /dev/null+++ b/packages/ui/src/guide/lib/build-preview.ts@@ -0,0 +1,18 @@+import { getScreenshotsForSteps } from '@mimik/core/guides/service';+import type { Screenshot, Snapshot } from '@mimik/core/guides/types';+import type { PreviewData } from '../types';++export async function buildPreview(snapshot: Snapshot): Promise<PreviewData> {+ const rows = new Map(snapshot.screenshots.map((row) => [row.id, row]));+ const steps = [...snapshot.steps].sort((a, b) => a.index - b.index);+ const wanted = steps.map((s) => s.screenshotId).filter((id): id is string => !!id && rows.has(id));+ const live = await getScreenshotsForSteps(wanted);+ const blobs = new Map([...live.values()].map((row) => [row.id, row.blob]));+ const screenshots = new Map<string, Screenshot>();+ for (const step of steps) {+ const row = step.screenshotId ? rows.get(step.screenshotId) : undefined;+ const blob = row ? blobs.get(row.id) : undefined;+ if (row && blob) screenshots.set(step.id, { ...row, blob });+ }+ return { snapshotId: snapshot.id, steps, screenshots };+}diff --git a/packages/ui/src/guide/lib/with-full-viewport.ts b/packages/ui/src/guide/lib/with-full-viewport.tsnew file mode 100644index 0000000..6d99f15--- /dev/null+++ b/packages/ui/src/guide/lib/with-full-viewport.ts@@ -0,0 +1,8 @@+import type { Screenshot } from '@mimik/core/guides/types';++export function withFullViewport(screenshot: Screenshot): Screenshot {+ return {+ ...screenshot,+ edits: { ...screenshot.edits, viewport: { x: 0, y: 0, width: screenshot.width, height: screenshot.height } },+ };+}diff --git a/packages/ui/src/guide/types.ts b/packages/ui/src/guide/types.tsnew file mode 100644index 0000000..bdac4e4--- /dev/null+++ b/packages/ui/src/guide/types.ts@@ -0,0 +1,13 @@+import type { Screenshot, Step } from '@mimik/core/guides/types';++export interface DragHandleProps {+ onDragStart: (e: React.DragEvent) => void;+ onDragOver: (e: React.DragEvent) => void;+ onDragEnd: () => void;+}++export interface PreviewData {+ snapshotId: string;+ steps: Step[];+ screenshots: Map<string, Screenshot>;+}diff --git a/packages/ui/src/history/components/VersionHistoryPanel.tsx b/packages/ui/src/history/components/VersionHistoryPanel.tsxindex 875c601..c8e50f7 100644--- a/packages/ui/src/history/components/VersionHistoryPanel.tsx+++ b/packages/ui/src/history/components/VersionHistoryPanel.tsx@@ -2,7 +2,7 @@ import { i18n } from '@mimik/core/env';import { diffSnapshots, type SnapshotDiff, type SnapshotLike } from '@mimik/core/guides/snapshot-diff';import { groupSnapshots } from '@mimik/core/guides/snapshot-groups';import type { Snapshot } from '@mimik/core/guides/types';-import { formatDateTime } from '@mimik/ui/common/lib/utils';+import { formatDateTime } from '@mimik/ui/common/lib/format-date-time';import {DropdownMenu,DropdownMenuContent,@@ -12,38 +12,8 @@ import {import { ChevronRight, MoreVertical, RotateCcw, X } from 'lucide-react';import { useCallback, useEffect, useMemo, useRef, useState } from 'react';import { useSnapshots } from '../hooks/use-snapshots';--function changeSummary(diff: SnapshotDiff): string {- const parts: string[] = [];- if (diff.titleChanged) parts.push(i18n.t('history.changeTitle'));- if (diff.added === 1) parts.push(i18n.t('history.changeStepAdded', [String(diff.added)]));- else if (diff.added > 1) parts.push(i18n.t('history.changeStepsAdded', [String(diff.added)]));- if (diff.removed === 1) parts.push(i18n.t('history.changeStepRemoved', [String(diff.removed)]));- else if (diff.removed > 1) parts.push(i18n.t('history.changeStepsRemoved', [String(diff.removed)]));- if (diff.edited === 1) parts.push(i18n.t('history.changeStepEdited', [String(diff.edited)]));- else if (diff.edited > 1) parts.push(i18n.t('history.changeStepsEdited', [String(diff.edited)]));- if (diff.urls === 1) parts.push(i18n.t('history.changeLink', [String(diff.urls)]));- else if (diff.urls > 1) parts.push(i18n.t('history.changeLinks', [String(diff.urls)]));- if (diff.replaced === 1) parts.push(i18n.t('history.changeImageReplaced', [String(diff.replaced)]));- else if (diff.replaced > 1) parts.push(i18n.t('history.changeImagesReplaced', [String(diff.replaced)]));- if (diff.cropped === 1) parts.push(i18n.t('history.changeImageCropped', [String(diff.cropped)]));- else if (diff.cropped > 1) parts.push(i18n.t('history.changeImagesCropped', [String(diff.cropped)]));- if (diff.annotated === 1) parts.push(i18n.t('history.changeImageAnnotated', [String(diff.annotated)]));- else if (diff.annotated > 1) parts.push(i18n.t('history.changeImagesAnnotated', [String(diff.annotated)]));- if (diff.blurred === 1) parts.push(i18n.t('history.changeImageBlurred', [String(diff.blurred)]));- else if (diff.blurred > 1) parts.push(i18n.t('history.changeImagesBlurred', [String(diff.blurred)]));- if (diff.altEdited) parts.push(i18n.t('history.changeAltText'));- if (diff.reordered) parts.push(i18n.t('history.changeStepReordered'));- return parts.join(' Β· ');-}--function filterPill(active: boolean): string {- return `px-2 py-0.5 rounded-full text-[10px] font-semibold border ${- active- ? 'bg-secondary border-border text-foreground'- : 'border-transparent text-muted-foreground hover:text-foreground'- }`;-}+import { changeSummary } from '../lib/change-summary';+import { filterPill } from '../lib/filter-pill';interface VersionHistoryPanelProps {guideId: string;diff --git a/packages/ui/src/history/lib/change-summary.ts b/packages/ui/src/history/lib/change-summary.tsnew file mode 100644index 0000000..ff9c855--- /dev/null+++ b/packages/ui/src/history/lib/change-summary.ts@@ -0,0 +1,26 @@+import { i18n } from '@mimik/core/env';+import type { SnapshotDiff } from '@mimik/core/guides/snapshot-diff';++export function changeSummary(diff: SnapshotDiff): string {+ const parts: string[] = [];+ if (diff.titleChanged) parts.push(i18n.t('history.changeTitle'));+ if (diff.added === 1) parts.push(i18n.t('history.changeStepAdded', [String(diff.added)]));+ else if (diff.added > 1) parts.push(i18n.t('history.changeStepsAdded', [String(diff.added)]));+ if (diff.removed === 1) parts.push(i18n.t('history.changeStepRemoved', [String(diff.removed)]));+ else if (diff.removed > 1) parts.push(i18n.t('history.changeStepsRemoved', [String(diff.removed)]));+ if (diff.edited === 1) parts.push(i18n.t('history.changeStepEdited', [String(diff.edited)]));+ else if (diff.edited > 1) parts.push(i18n.t('history.changeStepsEdited', [String(diff.edited)]));+ if (diff.urls === 1) parts.push(i18n.t('history.changeLink', [String(diff.urls)]));+ else if (diff.urls > 1) parts.push(i18n.t('history.changeLinks', [String(diff.urls)]));+ if (diff.replaced === 1) parts.push(i18n.t('history.changeImageReplaced', [String(diff.replaced)]));+ else if (diff.replaced > 1) parts.push(i18n.t('history.changeImagesReplaced', [String(diff.replaced)]));+ if (diff.cropped === 1) parts.push(i18n.t('history.changeImageCropped', [String(diff.cropped)]));+ else if (diff.cropped > 1) parts.push(i18n.t('history.changeImagesCropped', [String(diff.cropped)]));+ if (diff.annotated === 1) parts.push(i18n.t('history.changeImageAnnotated', [String(diff.annotated)]));+ else if (diff.annotated > 1) parts.push(i18n.t('history.changeImagesAnnotated', [String(diff.annotated)]));+ if (diff.blurred === 1) parts.push(i18n.t('history.changeImageBlurred', [String(diff.blurred)]));+ else if (diff.blurred > 1) parts.push(i18n.t('history.changeImagesBlurred', [String(diff.blurred)]));+ if (diff.altEdited) parts.push(i18n.t('history.changeAltText'));+ if (diff.reordered) parts.push(i18n.t('history.changeStepReordered'));+ return parts.join(' Β· ');+}diff --git a/packages/ui/src/history/lib/filter-pill.ts b/packages/ui/src/history/lib/filter-pill.tsnew file mode 100644index 0000000..7a43f6c--- /dev/null+++ b/packages/ui/src/history/lib/filter-pill.ts@@ -0,0 +1,7 @@+export function filterPill(active: boolean): string {+ return `px-2 py-0.5 rounded-full text-[10px] font-semibold border ${+ active+ ? 'bg-secondary border-border text-foreground'+ : 'border-transparent text-muted-foreground hover:text-foreground'+ }`;+}diff --git a/packages/ui/src/index.ts b/packages/ui/src/index.tsindex 66bbb3d..4f23ec2 100644--- a/packages/ui/src/index.ts+++ b/packages/ui/src/index.ts@@ -1,8 +1,14 @@export { default as AiSettings } from './ai/components/AiSettings';-export { KeyStatusNote, KeyWarningNote, ModelList, SecretInput, useKeyCheck } from './ai/components/key-status';+export { KeyStatusNote } from './ai/components/KeyStatusNote';+export { KeyWarningNote } from './ai/components/KeyWarningNote';+export { ModelList } from './ai/components/ModelList';+export { SecretInput } from './ai/components/SecretInput';export { useAiSettings } from './ai/hooks/use-ai-settings';+export { useKeyCheck } from './ai/hooks/use-key-check';export { default as ColorPicker } from './annotation/components/ColorPicker';export { default as FaviconImg } from './common/components/FaviconImg';+export { getDomainInitial } from './common/lib/domain-initial';+export { formatRelativeTime } from './common/lib/format-relative-time';export {MASCOT_ASPECT,MASCOT_BODY,@@ -12,7 +18,6 @@ export {MASCOT_SEAM,MASCOT_VIEW_BOX,} from './common/lib/mascot-shapes';-export { extractDomain, formatRelativeTime, getDomainInitial, getMostCommonDomain } from './common/lib/utils';export { Button } from './components/ui/button';export { Input } from './components/ui/input';export { Popover, PopoverContent, PopoverTrigger } from './components/ui/popover';@@ -27,6 +32,7 @@ export { default as StepCard } from './guide/components/StepCard';export { default as StepSourceBadge } from './guide/components/StepSourceBadge';export { default as LibraryContent } from './library/components/LibraryContent';export { default as TopNav } from './navigation/components/TopNav';-export { navigate, useRoute } from './navigation/lib/router';+export { useRoute } from './navigation/hooks/use-route';+export { navigate } from './navigation/lib/navigate';export { default as SearchModal } from './search/components/SearchModal';-export { useFullview } from './stores/fullview';+export { useFullview } from './stores/use-fullview';diff --git a/packages/ui/src/library/components/CardMenu.tsx b/packages/ui/src/library/components/CardMenu.tsxnew file mode 100644index 0000000..1edbd22--- /dev/null+++ b/packages/ui/src/library/components/CardMenu.tsx@@ -0,0 +1,111 @@+import { i18n } from '@mimik/core/env';+import { MoreVertical, RotateCcw, Star, StarOff, Trash2 } from 'lucide-react';+import { useEffect, useRef, useState } from 'react';++export function CardMenu({+ guideId,+ starred,+ category,+ onStar,+ onTrash,+ onRestore,+ onPermanentDelete,+}: {+ guideId: string;+ starred: boolean;+ category: string;+ onStar: (e: React.MouseEvent, id: string) => void;+ onTrash: (e: React.MouseEvent, id: string) => void;+ onRestore: (e: React.MouseEvent, id: string) => void;+ onPermanentDelete: (e: React.MouseEvent, id: string) => void;+}) {+ const [open, setOpen] = useState(false);+ const ref = useRef<HTMLDivElement>(null);++ useEffect(() => {+ if (!open) return;+ const handler = (e: MouseEvent) => {+ if (ref.current && !ref.current.contains(e.target as Node)) setOpen(false);+ };+ document.addEventListener('mousedown', handler);+ return () => document.removeEventListener('mousedown', handler);+ }, [open]);++ const items: {+ icon: React.ReactNode;+ label: string;+ onClick: (e: React.MouseEvent) => void;+ destructive?: boolean;+ }[] = [];++ if (category === 'trash') {+ items.push({+ icon: <RotateCcw size={13} />,+ label: i18n.t('common_restore'),+ onClick: (e) => {+ onRestore(e, guideId);+ setOpen(false);+ },+ });+ items.push({+ icon: <Trash2 size={13} />,+ label: i18n.t('library_deletePermanently'),+ onClick: (e) => {+ onPermanentDelete(e, guideId);+ setOpen(false);+ },+ destructive: true,+ });+ } else {+ items.push({+ icon: starred ? <StarOff size={13} /> : <Star size={13} />,+ label: starred ? i18n.t('common_unstar') : i18n.t('common_star'),+ onClick: (e) => {+ onStar(e, guideId);+ setOpen(false);+ },+ });+ items.push({+ icon: <Trash2 size={13} />,+ label: i18n.t('library_moveToTrash'),+ onClick: (e) => {+ onTrash(e, guideId);+ setOpen(false);+ },+ destructive: true,+ });+ }++ return (+ <div ref={ref} className="relative">+ <button+ onClick={(e) => {+ e.stopPropagation();+ setOpen(!open);+ }}+ className="flex items-center justify-center w-7 h-7 rounded-md text-muted-foreground hover:text-foreground hover:bg-secondary transition-colors"+ >+ <MoreVertical size={14} />+ </button>+ {open && (+ <div+ className="absolute left-full ml-1 top-0 bg-card border border-border rounded-lg shadow-lg py-1 z-20 min-w-[160px]"+ onClick={(e) => e.stopPropagation()}+ >+ {items.map((item) => (+ <button+ key={item.label}+ onClick={item.onClick}+ className={`flex items-center gap-2 w-full text-left text-xs font-medium px-3 py-2 transition-colors ${+ item.destructive ? 'text-destructive hover:bg-destructive/10' : 'text-foreground hover:bg-secondary'+ }`}+ >+ {item.icon}+ {item.label}+ </button>+ ))}+ </div>+ )}+ </div>+ );+}diff --git a/packages/ui/src/library/components/EmptyMascot.tsx b/packages/ui/src/library/components/EmptyMascot.tsxnew file mode 100644index 0000000..d8773be--- /dev/null+++ b/packages/ui/src/library/components/EmptyMascot.tsx@@ -0,0 +1,9 @@+import { NoGuidesMascot } from './NoGuidesMascot';+import { StarredMascot } from './StarredMascot';+import { TrashMascot } from './TrashMascot';++export function EmptyMascot({ category }: { category: string }) {+ if (category === 'starred') return <StarredMascot />;+ if (category === 'trash') return <TrashMascot />;+ return <NoGuidesMascot />;+}diff --git a/packages/ui/src/library/components/GuideGridView.tsx b/packages/ui/src/library/components/GuideGridView.tsxindex 591f843..3543cba 100644--- a/packages/ui/src/library/components/GuideGridView.tsx+++ b/packages/ui/src/library/components/GuideGridView.tsx@@ -1,10 +1,10 @@import { i18n } from '@mimik/core/env';-import { formatDate } from '@mimik/ui/common/lib/utils';+import { formatDate } from '@mimik/core/export/utils';import ScreenshotView from '@mimik/ui/guide/components/ScreenshotView';-import { useFullview } from '@mimik/ui/stores/fullview';-import { MoreVertical, RotateCcw, Star, StarOff, Trash2 } from 'lucide-react';-import { useEffect, useRef, useState } from 'react';-import { navigate } from '../../navigation/lib/router';+import { navigate } from '@mimik/ui/navigation/lib/navigate';+import { useFullview } from '@mimik/ui/stores/use-fullview';+import { CardMenu } from './CardMenu';+import { MimikEyes } from './MimikEyes';interface GuideGridViewProps {category: 'all' | 'starred' | 'trash';@@ -14,126 +14,6 @@ interface GuideGridViewProps {onPermanentDelete: (e: React.MouseEvent, id: string) => void;}-function MimikEyes() {- return (- <div className="w-full h-full flex items-center justify-center bg-primary">- <svg width="120" height="50" viewBox="0 0 120 50" fill="none">- <path d="M15 30 Q27 14 39 30" stroke="#C7D2FE" strokeWidth="5" strokeLinecap="round" fill="none" />- <path d="M81 30 Q93 14 105 30" stroke="#C7D2FE" strokeWidth="5" strokeLinecap="round" fill="none" />- <path d="M39 44 Q60 54 81 44" stroke="#C7D2FE" strokeWidth="3.5" strokeLinecap="round" fill="none" />- </svg>- </div>- );-}--function CardMenu({- guideId,- starred,- category,- onStar,- onTrash,- onRestore,- onPermanentDelete,-}: {- guideId: string;- starred: boolean;- category: string;- onStar: (e: React.MouseEvent, id: string) => void;- onTrash: (e: React.MouseEvent, id: string) => void;- onRestore: (e: React.MouseEvent, id: string) => void;- onPermanentDelete: (e: React.MouseEvent, id: string) => void;-}) {- const [open, setOpen] = useState(false);- const ref = useRef<HTMLDivElement>(null);-- useEffect(() => {- if (!open) return;- const handler = (e: MouseEvent) => {- if (ref.current && !ref.current.contains(e.target as Node)) setOpen(false);- };- document.addEventListener('mousedown', handler);- return () => document.removeEventListener('mousedown', handler);- }, [open]);-- const items: {- icon: React.ReactNode;- label: string;- onClick: (e: React.MouseEvent) => void;- destructive?: boolean;- }[] = [];-- if (category === 'trash') {- items.push({- icon: <RotateCcw size={13} />,- label: i18n.t('common_restore'),- onClick: (e) => {- onRestore(e, guideId);- setOpen(false);- },- });- items.push({- icon: <Trash2 size={13} />,- label: i18n.t('library_deletePermanently'),- onClick: (e) => {- onPermanentDelete(e, guideId);- setOpen(false);- },- destructive: true,- });- } else {- items.push({- icon: starred ? <StarOff size={13} /> : <Star size={13} />,- label: starred ? i18n.t('common_unstar') : i18n.t('common_star'),- onClick: (e) => {- onStar(e, guideId);- setOpen(false);- },- });- items.push({- icon: <Trash2 size={13} />,- label: i18n.t('library_moveToTrash'),- onClick: (e) => {- onTrash(e, guideId);- setOpen(false);- },- destructive: true,- });- }-- return (- <div ref={ref} className="relative">- <button- onClick={(e) => {- e.stopPropagation();- setOpen(!open);- }}- className="flex items-center justify-center w-7 h-7 rounded-md text-muted-foreground hover:text-foreground hover:bg-secondary transition-colors"- >- <MoreVertical size={14} />- </button>- {open && (- <div- className="absolute left-full ml-1 top-0 bg-card border border-border rounded-lg shadow-lg py-1 z-20 min-w-[160px]"- onClick={(e) => e.stopPropagation()}- >- {items.map((item) => (- <button- key={item.label}- onClick={item.onClick}- className={`flex items-center gap-2 w-full text-left text-xs font-medium px-3 py-2 transition-colors ${- item.destructive ? 'text-destructive hover:bg-destructive/10' : 'text-foreground hover:bg-secondary'- }`}- >- {item.icon}- {item.label}- </button>- ))}- </div>- )}- </div>- );-}-export default function GuideGridView({ category, onStar, onTrash, onRestore, onPermanentDelete }: GuideGridViewProps) {const { guides, thumbnails } = useFullview((s) => ({guides: s.guides,diff --git a/packages/ui/src/library/components/GuideListView.tsx b/packages/ui/src/library/components/GuideListView.tsxindex b25d889..0e02c79 100644--- a/packages/ui/src/library/components/GuideListView.tsx+++ b/packages/ui/src/library/components/GuideListView.tsx@@ -1,9 +1,9 @@import { i18n } from '@mimik/core/env';-import { formatDate } from '@mimik/ui/common/lib/utils';+import { formatDate } from '@mimik/core/export/utils';import { Tooltip, TooltipContent, TooltipTrigger } from '@mimik/ui/components/ui/tooltip';-import { useFullview } from '@mimik/ui/stores/fullview';+import { navigate } from '@mimik/ui/navigation/lib/navigate';+import { useFullview } from '@mimik/ui/stores/use-fullview';import { RotateCcw, Star, Trash2 } from 'lucide-react';-import { navigate } from '../../navigation/lib/router';interface GuideListViewProps {category: 'all' | 'starred' | 'trash';diff --git a/packages/ui/src/library/components/LibraryContent.tsx b/packages/ui/src/library/components/LibraryContent.tsxindex faf9d5f..cc3f20f 100644--- a/packages/ui/src/library/components/LibraryContent.tsx+++ b/packages/ui/src/library/components/LibraryContent.tsx@@ -13,7 +13,7 @@ import {} from '@mimik/core/guides/service';import type { Guide, Screenshot } from '@mimik/core/guides/types';import { Tooltip, TooltipContent, TooltipTrigger } from '@mimik/ui/components/ui/tooltip';-import { useFullview } from '@mimik/ui/stores/fullview';+import { useFullview } from '@mimik/ui/stores/use-fullview';import {ArrowDownWideNarrow,ChevronDown,@@ -24,7 +24,10 @@ import {Video,} from 'lucide-react';import { useCallback, useEffect, useRef, useState } from 'react';+import { sortGuides } from '../lib/sort-guides';+import type { SortKey } from '../types';import ConfirmDeleteModal from './ConfirmDeleteModal';+import { EmptyMascot } from './EmptyMascot';import GuideGridView from './GuideGridView';import GuideListView from './GuideListView';@@ -39,94 +42,6 @@ const emptyConfig: Record<string, { titleKey: string; subKey: string }> = {trash: { titleKey: 'library_trashEmptyTitle', subKey: 'library_trashEmptySub' },};-function EmptyMascot({ category }: { category: string }) {- if (category === 'starred') return <StarredMascot />;- if (category === 'trash') return <TrashMascot />;- return <NoGuidesMascot />;-}--function NoGuidesMascot() {- return (- <svg viewBox="0 0 200 200" className="w-24 h-24 animate-[float_3s_ease-in-out_infinite]">- <style>{`- @keyframes float{0%,100%{transform:translateY(0)}50%{transform:translateY(-6px)}}- @keyframes sparkle{0%,100%{opacity:.3;transform:scale(.8)}50%{opacity:1;transform:scale(1.1)}}- `}</style>- <circle cx="45" cy="80" r="3" fill="#818CF8" style={{ animation: 'sparkle 1.5s ease-in-out infinite' }} />- <circle cx="160" cy="70" r="2.5" fill="#818CF8" style={{ animation: 'sparkle 1.5s ease-in-out infinite 0.3s' }} />- <circle cx="50" cy="140" r="2" fill="#A5B4FC" style={{ animation: 'sparkle 1.5s ease-in-out infinite 0.6s' }} />- <circle- cx="155"- cy="145"- r="2.5"- fill="#818CF8"- style={{ animation: 'sparkle 1.5s ease-in-out infinite 0.9s' }}- />- <circle cx="100" cy="110" r="50" fill="#C7D2FE" />- <rect x="58" y="110" width="84" height="40" rx="5" fill="#1E1B4B" />- <path d="M58 110 L58 98 Q58 82 100 82 Q142 82 142 98 L142 110Z" fill="#3730A3" />- <path d="M58 110 L58 98 Q58 82 100 82 Q142 82 142 98 L142 110Z" fill="#4F46E5" />- <rect x="58" y="109" width="84" height="2" fill="#C7D2FE" />- <path d="M82 126 Q88 118 94 126" stroke="#C7D2FE" strokeWidth="3" fill="none" strokeLinecap="round" />- <path d="M106 126 Q112 118 118 126" stroke="#C7D2FE" strokeWidth="3" fill="none" strokeLinecap="round" />- <path d="M90 138 Q100 146 110 138" stroke="#C7D2FE" strokeWidth="2.5" fill="none" strokeLinecap="round" />- </svg>- );-}--function StarredMascot() {- return (- <svg viewBox="0 0 200 200" className="w-24 h-24">- <style>{`- @keyframes twinkle{0%,100%{opacity:.4;transform:scale(.9)}50%{opacity:1;transform:scale(1.15)}}- `}</style>- <circle cx="100" cy="115" r="50" fill="#C7D2FE" />- <rect x="58" y="115" width="84" height="40" rx="5" fill="#1E1B4B" />- <path d="M58 115 L58 103 Q58 87 100 87 Q142 87 142 103 L142 115Z" fill="#3730A3" />- <path d="M58 115 L58 103 Q58 87 100 87 Q142 87 142 103 L142 115Z" fill="#4F46E5" />- <rect x="58" y="114" width="84" height="2" fill="#C7D2FE" />- <path d="M82 131 Q88 124 94 131" stroke="#C7D2FE" strokeWidth="3" fill="none" strokeLinecap="round" />- <path d="M106 131 Q112 124 118 131" stroke="#C7D2FE" strokeWidth="3" fill="none" strokeLinecap="round" />- <path d="M92 143 Q100 150 108 143" stroke="#C7D2FE" strokeWidth="2.5" fill="none" strokeLinecap="round" />- <g style={{ animation: 'twinkle 1.5s ease-in-out infinite' }}>- <polygon- points="155,70 159,80 170,81 162,88 164,99 155,93 146,99 148,88 140,81 151,80"- fill="#FBBF24"- stroke="#F59E0B"- strokeWidth="1"- />- </g>- <line x1="142" y1="120" x2="153" y2="90" stroke="#C7D2FE" strokeWidth="3" strokeLinecap="round" />- </svg>- );-}--function TrashMascot() {- return (- <svg viewBox="0 0 200 200" className="w-24 h-24">- <style>{`- @keyframes sweep{0%,100%{transform:rotate(-10deg)}50%{transform:rotate(10deg)}}- @keyframes sparkle{0%,100%{opacity:.3;transform:scale(.8)}50%{opacity:1;transform:scale(1.1)}}- `}</style>- <circle cx="100" cy="115" r="50" fill="#C7D2FE" />- <rect x="58" y="115" width="84" height="40" rx="5" fill="#1E1B4B" />- <path d="M58 115 L58 103 Q58 87 100 87 Q142 87 142 103 L142 115Z" fill="#3730A3" />- <path d="M58 115 L58 103 Q58 87 100 87 Q142 87 142 103 L142 115Z" fill="#4F46E5" />- <rect x="58" y="114" width="84" height="2" fill="#C7D2FE" />- <path d="M82 131 Q88 124 94 131" stroke="#C7D2FE" strokeWidth="3" fill="none" strokeLinecap="round" />- <path d="M106 131 Q112 124 118 131" stroke="#C7D2FE" strokeWidth="3" fill="none" strokeLinecap="round" />- <path d="M92 143 Q100 150 108 143" stroke="#C7D2FE" strokeWidth="2.5" fill="none" strokeLinecap="round" />- <g style={{ transformOrigin: '155px 130px', animation: 'sweep 1.5s ease-in-out infinite' }}>- <line x1="155" y1="75" x2="155" y2="140" stroke="#A5B4FC" strokeWidth="3" strokeLinecap="round" />- <path d="M147 140 Q155 135 163 140 L160 155 Q155 158 150 155Z" fill="#818CF8" />- </g>- <circle cx="165" cy="155" r="2" fill="#818CF8" style={{ animation: 'sparkle 1s ease-in-out infinite' }} />- <circle cx="148" cy="160" r="1.5" fill="#818CF8" style={{ animation: 'sparkle 1s ease-in-out infinite 0.3s' }} />- </svg>- );-}--type SortKey = 'recent' | 'oldest' | 'alpha' | 'steps';const sortLabelKeys: Record<SortKey, string> = {recent: 'sort_recentFirst',oldest: 'sort_oldestFirst',@@ -136,20 +51,6 @@ const sortLabelKeys: Record<SortKey, string> = {const PAGE_SIZE = 9;-function sortGuides(guides: Guide[], sort: SortKey): Guide[] {- const sorted = [...guides];- switch (sort) {- case 'recent':- return sorted.sort((a, b) => b.updatedAt - a.updatedAt);- case 'oldest':- return sorted.sort((a, b) => a.updatedAt - b.updatedAt);- case 'alpha':- return sorted.sort((a, b) => a.title.localeCompare(b.title));- case 'steps':- return sorted.sort((a, b) => b.stepIds.length - a.stepIds.length);- }-}-export default function LibraryContent({ category, onStartCapture }: LibraryContentProps) {const {setGuides,diff --git a/packages/ui/src/library/components/MimikEyes.tsx b/packages/ui/src/library/components/MimikEyes.tsxnew file mode 100644index 0000000..78e38af--- /dev/null+++ b/packages/ui/src/library/components/MimikEyes.tsx@@ -0,0 +1,11 @@+export function MimikEyes() {+ return (+ <div className="w-full h-full flex items-center justify-center bg-primary">+ <svg width="120" height="50" viewBox="0 0 120 50" fill="none">+ <path d="M15 30 Q27 14 39 30" stroke="#C7D2FE" strokeWidth="5" strokeLinecap="round" fill="none" />+ <path d="M81 30 Q93 14 105 30" stroke="#C7D2FE" strokeWidth="5" strokeLinecap="round" fill="none" />+ <path d="M39 44 Q60 54 81 44" stroke="#C7D2FE" strokeWidth="3.5" strokeLinecap="round" fill="none" />+ </svg>+ </div>+ );+}diff --git a/packages/ui/src/library/components/NoGuidesMascot.tsx b/packages/ui/src/library/components/NoGuidesMascot.tsxnew file mode 100644index 0000000..e0d0a54--- /dev/null+++ b/packages/ui/src/library/components/NoGuidesMascot.tsx@@ -0,0 +1,28 @@+export function NoGuidesMascot() {+ return (+ <svg viewBox="0 0 200 200" className="w-24 h-24 animate-[float_3s_ease-in-out_infinite]">+ <style>{`+ @keyframes float{0%,100%{transform:translateY(0)}50%{transform:translateY(-6px)}}+ @keyframes sparkle{0%,100%{opacity:.3;transform:scale(.8)}50%{opacity:1;transform:scale(1.1)}}+ `}</style>+ <circle cx="45" cy="80" r="3" fill="#818CF8" style={{ animation: 'sparkle 1.5s ease-in-out infinite' }} />+ <circle cx="160" cy="70" r="2.5" fill="#818CF8" style={{ animation: 'sparkle 1.5s ease-in-out infinite 0.3s' }} />+ <circle cx="50" cy="140" r="2" fill="#A5B4FC" style={{ animation: 'sparkle 1.5s ease-in-out infinite 0.6s' }} />+ <circle+ cx="155"+ cy="145"+ r="2.5"+ fill="#818CF8"+ style={{ animation: 'sparkle 1.5s ease-in-out infinite 0.9s' }}+ />+ <circle cx="100" cy="110" r="50" fill="#C7D2FE" />+ <rect x="58" y="110" width="84" height="40" rx="5" fill="#1E1B4B" />+ <path d="M58 110 L58 98 Q58 82 100 82 Q142 82 142 98 L142 110Z" fill="#3730A3" />+ <path d="M58 110 L58 98 Q58 82 100 82 Q142 82 142 98 L142 110Z" fill="#4F46E5" />+ <rect x="58" y="109" width="84" height="2" fill="#C7D2FE" />+ <path d="M82 126 Q88 118 94 126" stroke="#C7D2FE" strokeWidth="3" fill="none" strokeLinecap="round" />+ <path d="M106 126 Q112 118 118 126" stroke="#C7D2FE" strokeWidth="3" fill="none" strokeLinecap="round" />+ <path d="M90 138 Q100 146 110 138" stroke="#C7D2FE" strokeWidth="2.5" fill="none" strokeLinecap="round" />+ </svg>+ );+}diff --git a/packages/ui/src/library/components/StarredMascot.tsx b/packages/ui/src/library/components/StarredMascot.tsxnew file mode 100644index 0000000..b049050--- /dev/null+++ b/packages/ui/src/library/components/StarredMascot.tsx@@ -0,0 +1,26 @@+export function StarredMascot() {+ return (+ <svg viewBox="0 0 200 200" className="w-24 h-24">+ <style>{`+ @keyframes twinkle{0%,100%{opacity:.4;transform:scale(.9)}50%{opacity:1;transform:scale(1.15)}}+ `}</style>+ <circle cx="100" cy="115" r="50" fill="#C7D2FE" />+ <rect x="58" y="115" width="84" height="40" rx="5" fill="#1E1B4B" />+ <path d="M58 115 L58 103 Q58 87 100 87 Q142 87 142 103 L142 115Z" fill="#3730A3" />+ <path d="M58 115 L58 103 Q58 87 100 87 Q142 87 142 103 L142 115Z" fill="#4F46E5" />+ <rect x="58" y="114" width="84" height="2" fill="#C7D2FE" />+ <path d="M82 131 Q88 124 94 131" stroke="#C7D2FE" strokeWidth="3" fill="none" strokeLinecap="round" />+ <path d="M106 131 Q112 124 118 131" stroke="#C7D2FE" strokeWidth="3" fill="none" strokeLinecap="round" />+ <path d="M92 143 Q100 150 108 143" stroke="#C7D2FE" strokeWidth="2.5" fill="none" strokeLinecap="round" />+ <g style={{ animation: 'twinkle 1.5s ease-in-out infinite' }}>+ <polygon+ points="155,70 159,80 170,81 162,88 164,99 155,93 146,99 148,88 140,81 151,80"+ fill="#FBBF24"+ stroke="#F59E0B"+ strokeWidth="1"+ />+ </g>+ <line x1="142" y1="120" x2="153" y2="90" stroke="#C7D2FE" strokeWidth="3" strokeLinecap="round" />+ </svg>+ );+}diff --git a/packages/ui/src/library/components/TrashMascot.tsx b/packages/ui/src/library/components/TrashMascot.tsxnew file mode 100644index 0000000..b32a9bf--- /dev/null+++ b/packages/ui/src/library/components/TrashMascot.tsx@@ -0,0 +1,24 @@+export function TrashMascot() {+ return (+ <svg viewBox="0 0 200 200" className="w-24 h-24">+ <style>{`+ @keyframes sweep{0%,100%{transform:rotate(-10deg)}50%{transform:rotate(10deg)}}+ @keyframes sparkle{0%,100%{opacity:.3;transform:scale(.8)}50%{opacity:1;transform:scale(1.1)}}+ `}</style>+ <circle cx="100" cy="115" r="50" fill="#C7D2FE" />+ <rect x="58" y="115" width="84" height="40" rx="5" fill="#1E1B4B" />+ <path d="M58 115 L58 103 Q58 87 100 87 Q142 87 142 103 L142 115Z" fill="#3730A3" />+ <path d="M58 115 L58 103 Q58 87 100 87 Q142 87 142 103 L142 115Z" fill="#4F46E5" />+ <rect x="58" y="114" width="84" height="2" fill="#C7D2FE" />+ <path d="M82 131 Q88 124 94 131" stroke="#C7D2FE" strokeWidth="3" fill="none" strokeLinecap="round" />+ <path d="M106 131 Q112 124 118 131" stroke="#C7D2FE" strokeWidth="3" fill="none" strokeLinecap="round" />+ <path d="M92 143 Q100 150 108 143" stroke="#C7D2FE" strokeWidth="2.5" fill="none" strokeLinecap="round" />+ <g style={{ transformOrigin: '155px 130px', animation: 'sweep 1.5s ease-in-out infinite' }}>+ <line x1="155" y1="75" x2="155" y2="140" stroke="#A5B4FC" strokeWidth="3" strokeLinecap="round" />+ <path d="M147 140 Q155 135 163 140 L160 155 Q155 158 150 155Z" fill="#818CF8" />+ </g>+ <circle cx="165" cy="155" r="2" fill="#818CF8" style={{ animation: 'sparkle 1s ease-in-out infinite' }} />+ <circle cx="148" cy="160" r="1.5" fill="#818CF8" style={{ animation: 'sparkle 1s ease-in-out infinite 0.3s' }} />+ </svg>+ );+}diff --git a/packages/ui/src/library/lib/sort-guides.ts b/packages/ui/src/library/lib/sort-guides.tsnew file mode 100644index 0000000..b72bae1--- /dev/null+++ b/packages/ui/src/library/lib/sort-guides.ts@@ -0,0 +1,16 @@+import type { Guide } from '@mimik/core/guides/types';+import type { SortKey } from '../types';++export function sortGuides(guides: Guide[], sort: SortKey): Guide[] {+ const sorted = [...guides];+ switch (sort) {+ case 'recent':+ return sorted.sort((a, b) => b.updatedAt - a.updatedAt);+ case 'oldest':+ return sorted.sort((a, b) => a.updatedAt - b.updatedAt);+ case 'alpha':+ return sorted.sort((a, b) => a.title.localeCompare(b.title));+ case 'steps':+ return sorted.sort((a, b) => b.stepIds.length - a.stepIds.length);+ }+}diff --git a/packages/ui/src/library/types.ts b/packages/ui/src/library/types.tsnew file mode 100644index 0000000..874fa14--- /dev/null+++ b/packages/ui/src/library/types.ts@@ -0,0 +1 @@+export type SortKey = 'recent' | 'oldest' | 'alpha' | 'steps';diff --git a/packages/ui/src/navigation/components/TopNav.tsx b/packages/ui/src/navigation/components/TopNav.tsxindex aba5416..ede18b8 100644--- a/packages/ui/src/navigation/components/TopNav.tsx+++ b/packages/ui/src/navigation/components/TopNav.tsx@@ -3,9 +3,7 @@ import { createSnapshot } from '@mimik/core/guides/service';import { logger } from '@mimik/core/logger';import MascotIcon from '@mimik/ui/common/components/MascotIcon';import { Button } from '@mimik/ui/components/ui/button';-import type { Route } from '@mimik/ui/navigation/lib/router';-import { navigate } from '@mimik/ui/navigation/lib/router';-import { useFullview } from '@mimik/ui/stores/fullview';+import { useFullview } from '@mimik/ui/stores/use-fullview';import {Check,ChevronRight,@@ -21,6 +19,8 @@ import {import type { ReactNode } from 'react';import { useState } from 'react';import ExportPreviewModal from '../../export/components/ExportPreviewModal';+import { navigate } from '../lib/navigate';+import type { Route } from '../types';interface TopNavProps {route: Route;diff --git a/packages/ui/src/navigation/lib/router.ts b/packages/ui/src/navigation/hooks/use-route.tssimilarity index 73%rename from packages/ui/src/navigation/lib/router.tsrename to packages/ui/src/navigation/hooks/use-route.tsindex 43eb525..f6fa9f9 100644--- a/packages/ui/src/navigation/lib/router.ts+++ b/packages/ui/src/navigation/hooks/use-route.ts@@ -1,13 +1,5 @@import { useEffect, useState } from 'react';--export type Route =- | { page: 'library'; category: 'all' | 'starred' | 'trash' }- | {- page: 'guide';- guideId: string;- stepId?: string;- tool?: 'annotate' | 'redact' | 'crop' | 'target';- };+import type { Route } from '../types';function parseHash(hash: string): Route {const h = hash.replace(/^#\/?/, '');@@ -20,16 +12,6 @@ function parseHash(hash: string): Route {return { page: 'library', category: 'all' };}-export function navigate(route: Route) {- if (route.page === 'guide') {- window.location.hash = `#guide/${route.guideId}`;- } else if (route.category === 'all') {- window.location.hash = '#library';- } else {- window.location.hash = `#library/${route.category}`;- }-}-export function useRoute(): Route {const [route, setRoute] = useState<Route>(() => {const params = new URLSearchParams(window.location.search);diff --git a/packages/ui/src/navigation/lib/navigate.ts b/packages/ui/src/navigation/lib/navigate.tsnew file mode 100644index 0000000..a7854d8--- /dev/null+++ b/packages/ui/src/navigation/lib/navigate.ts@@ -0,0 +1,11 @@+import type { Route } from '../types';++export function navigate(route: Route) {+ if (route.page === 'guide') {+ window.location.hash = `#guide/${route.guideId}`;+ } else if (route.category === 'all') {+ window.location.hash = '#library';+ } else {+ window.location.hash = `#library/${route.category}`;+ }+}diff --git a/packages/ui/src/navigation/types.ts b/packages/ui/src/navigation/types.tsnew file mode 100644index 0000000..35ee7fc--- /dev/null+++ b/packages/ui/src/navigation/types.ts@@ -0,0 +1,8 @@+export type Route =+ | { page: 'library'; category: 'all' | 'starred' | 'trash' }+ | {+ page: 'guide';+ guideId: string;+ stepId?: string;+ tool?: 'annotate' | 'redact' | 'crop' | 'target';+ };diff --git a/packages/ui/src/search/components/SearchModal.tsx b/packages/ui/src/search/components/SearchModal.tsxindex 30289f3..54bd5e3 100644--- a/packages/ui/src/search/components/SearchModal.tsx+++ b/packages/ui/src/search/components/SearchModal.tsx@@ -3,8 +3,8 @@ import { getGuideDomain, getGuides } from '@mimik/core/guides/service';import type { Guide } from '@mimik/core/guides/types';import { Dialog, DialogPortal } from '@mimik/ui/components/ui/dialog';import { Input } from '@mimik/ui/components/ui/input';-import { navigate } from '@mimik/ui/navigation/lib/router';-import { useFullview } from '@mimik/ui/stores/fullview';+import { navigate } from '@mimik/ui/navigation/lib/navigate';+import { useFullview } from '@mimik/ui/stores/use-fullview';import { Search, X } from 'lucide-react';import { useCallback, useEffect, useRef, useState } from 'react';import KeyboardHints from './KeyboardHints';diff --git a/packages/ui/src/search/components/SearchResults.tsx b/packages/ui/src/search/components/SearchResults.tsxindex 0cc241e..6e54f18 100644--- a/packages/ui/src/search/components/SearchResults.tsx+++ b/packages/ui/src/search/components/SearchResults.tsx@@ -1,7 +1,7 @@import { i18n } from '@mimik/core/env';import type { Guide } from '@mimik/core/guides/types';import FaviconImg from '@mimik/ui/common/components/FaviconImg';-import { formatDateShort } from '@mimik/ui/common/lib/utils';+import { formatDateShort } from '@mimik/ui/common/lib/format-date-short';interface GuideResult {guide: Guide;diff --git a/packages/ui/src/stores/fullview.ts b/packages/ui/src/stores/fullview.tsindex ca53f1a..8b228b2 100644--- a/packages/ui/src/stores/fullview.ts+++ b/packages/ui/src/stores/fullview.ts@@ -1,13 +1,10 @@import { create } from 'zustand';-import { useShallow } from 'zustand/react/shallow';import { createEditorSlice, type EditorSlice } from '../guide/store/editor-slice';import { createGuideSlice, type GuideSlice } from '../guide/store/guide-slice';import { createLibrarySlice, type LibrarySlice } from '../library/store/library-slice';import { createSearchSlice, type SearchSlice } from '../search/store/search-slice';-export type { GuideExportData } from '../guide/store/guide-slice';--type FullviewStore = LibrarySlice & SearchSlice & GuideSlice & EditorSlice;+export type FullviewStore = LibrarySlice & SearchSlice & GuideSlice & EditorSlice;export const useFullviewStore = create<FullviewStore>()((...a) => ({...createLibrarySlice(...a),@@ -15,7 +12,3 @@ export const useFullviewStore = create<FullviewStore>()((...a) => ({...createGuideSlice(...a),...createEditorSlice(...a),}));--export function useFullview<T>(selector: (s: FullviewStore) => T): T {- return useFullviewStore(useShallow(selector));-}diff --git a/packages/ui/src/stores/use-fullview.ts b/packages/ui/src/stores/use-fullview.tsnew file mode 100644index 0000000..dbedb72--- /dev/null+++ b/packages/ui/src/stores/use-fullview.ts@@ -0,0 +1,6 @@+import { useShallow } from 'zustand/react/shallow';+import { type FullviewStore, useFullviewStore } from './fullview';++export function useFullview<T>(selector: (s: FullviewStore) => T): T {+ return useFullviewStore(useShallow(selector));+}diff --git a/src/lib/__tests__/utils.test.ts b/src/lib/__tests__/utils.test.tsindex decd7eb..ef60c3c 100644--- a/src/lib/__tests__/utils.test.ts+++ b/src/lib/__tests__/utils.test.ts@@ -1,4 +1,5 @@-import { extractDomain, getDomainInitial, getMostCommonDomain } from '@mimik/ui';+import { extractDomain, getMostCommonDomain } from '@mimik/core/guides/domain';+import { getDomainInitial } from '@mimik/ui';import { describe, expect, it } from 'vitest';describe('extractDomain', () => {diff --git a/src/ui/sidepanel/GuideEditor.tsx b/src/ui/sidepanel/GuideEditor.tsxindex 3836281..1b36105 100644--- a/src/ui/sidepanel/GuideEditor.tsx+++ b/src/ui/sidepanel/GuideEditor.tsx@@ -1,13 +1,5 @@-import {- BlockCard,- EmptyGuideState,- FaviconImg,- getMostCommonDomain,- StepCard,- Tooltip,- TooltipContent,- TooltipTrigger,-} from '@mimik/ui';+import { getMostCommonDomain } from '@mimik/core/guides/domain';+import { BlockCard, EmptyGuideState, FaviconImg, StepCard, Tooltip, TooltipContent, TooltipTrigger } from '@mimik/ui';import { ArrowLeft, Maximize2, Play } from 'lucide-react';import { useCallback, useEffect, useState } from 'react';import { i18n } from '#imports';diff --git a/src/ui/sidepanel/GuideMeView.tsx b/src/ui/sidepanel/GuideMeView.tsxindex 4dc7d2b..1c8424d 100644--- a/src/ui/sidepanel/GuideMeView.tsx+++ b/src/ui/sidepanel/GuideMeView.tsx@@ -1,4 +1,5 @@-import { extractDomain, FaviconImg, ScreenshotView } from '@mimik/ui';+import { extractDomain } from '@mimik/core/guides/domain';+import { FaviconImg, ScreenshotView } from '@mimik/ui';import { ArrowLeft, Check, ChevronLeft, ChevronRight, TriangleAlert } from 'lucide-react';import { useCallback, useEffect, useState } from 'react';import { browser, i18n } from '#imports';diff --git a/src/ui/sidepanel/RecordingView.tsx b/src/ui/sidepanel/RecordingView.tsxindex 9ee4aae..07bca20 100644--- a/src/ui/sidepanel/RecordingView.tsx+++ b/src/ui/sidepanel/RecordingView.tsx@@ -1,12 +1,5 @@-import {- Button,- extractDomain,- ScreenshotView,- StepSourceBadge,- Tooltip,- TooltipContent,- TooltipTrigger,-} from '@mimik/ui';+import { extractDomain } from '@mimik/core/guides/domain';+import { Button, ScreenshotView, StepSourceBadge, Tooltip, TooltipContent, TooltipTrigger } from '@mimik/ui';import { Check, EyeOff, Loader2, X } from 'lucide-react';import { useCallback, useEffect, useRef, useState } from 'react';import { browser, i18n } from '#imports';