π¬ 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): keep the mascot geometry in one place
Luis Ortiz298d18f6a666
diff --git a/packages/ui/src/shared/MascotIcon.tsx b/packages/ui/src/shared/MascotIcon.tsxindex 556179a..379a329 100644--- a/packages/ui/src/shared/MascotIcon.tsx+++ b/packages/ui/src/shared/MascotIcon.tsx@@ -1,6 +1,17 @@+import {+ MASCOT_ASPECT,+ MASCOT_BODY,+ MASCOT_CROWN,+ MASCOT_CROWN_SPLIT,+ MASCOT_FACES,+ MASCOT_SEAM,+ MASCOT_VIEW_BOX,+ type MascotPose,+} from './mascot-shapes';+interface MascotIconProps {size?: number;- pose?: 'happy' | 'lookaway';+ pose?: MascotPose;tone?: 'brand' | 'muted';}@@ -10,45 +21,54 @@ export default function MascotIcon({ size = 22, pose = 'happy', tone = 'brand' }const crown = muted ? 'fill-current opacity-80' : 'fill-violet-mid';const seam = muted ? 'fill-current opacity-25' : 'fill-lavender';const feature = muted ? 'fill-card stroke-card' : 'fill-lavender stroke-lavender';+ const face = MASCOT_FACES[pose];return (<svgxmlns="http://www.w3.org/2000/svg"- viewBox="20 50 160 120"+ viewBox={MASCOT_VIEW_BOX}width={size}- height={Math.round((size * 120) / 160)}+ height={Math.round(size * MASCOT_ASPECT)}className="block shrink-0"aria-hidden="true"><defs><clipPath id="mascot-crown-split">- <path d="M30 95 L170 60 L170 95 Z" />+ <path d={MASCOT_CROWN_SPLIT} /></clipPath></defs>- <rect x="30" y="95" width="140" height="68" rx="5" className={body} />- <path d="M30 95 L30 80 Q30 60, 100 60 Q170 60, 170 80 L170 95 Z" className={crown} />- {!muted && (- <path- d="M30 95 L30 80 Q30 60, 100 60 Q170 60, 170 80 L170 95 Z"- className="fill-accent"- clipPath="url(#mascot-crown-split)"- />- )}- <rect x="30" y="93" width="140" height="3" className={seam} />+ <rect {...MASCOT_BODY} className={body} />+ <path d={MASCOT_CROWN} className={crown} />+ {!muted && <path d={MASCOT_CROWN} className="fill-accent" clipPath="url(#mascot-crown-split)" />}+ <rect {...MASCOT_SEAM} className={seam} />- {pose === 'lookaway' ? (+ {'pupils' in face ? (<>- <circle cx="80" cy="124" r="5" className={feature} strokeWidth="0" />- <circle cx="128" cy="124" r="5" className={feature} strokeWidth="0" />- <path d="M86 141 Q100 136 116 141" className={feature} strokeWidth="3.5" fill="none" strokeLinecap="round" />+ {face.pupils.map((pupil) => (+ <circle key={pupil.cx} {...pupil} className={feature} strokeWidth="0" />+ ))}</>) : (<>- <path d="M68 122 Q76 112 84 122" className={feature} strokeWidth="5" fill="none" strokeLinecap="round" />- <path d="M116 122 Q124 112 132 122" className={feature} strokeWidth="5" fill="none" strokeLinecap="round" />- <path d="M84 138 Q100 148 116 138" className={feature} strokeWidth="3.5" fill="none" strokeLinecap="round" />+ {face.eyes.map((eye) => (+ <path+ key={eye}+ d={eye}+ className={feature}+ strokeWidth={face.eyeWidth}+ fill="none"+ strokeLinecap="round"+ />+ ))}</>)}+ <path+ d={face.mouth}+ className={feature}+ strokeWidth={face.mouthWidth}+ fill="none"+ strokeLinecap="round"+ /></svg>);}diff --git a/packages/ui/src/shared/mascot-shapes.ts b/packages/ui/src/shared/mascot-shapes.tsnew file mode 100644index 0000000..232fbb3--- /dev/null+++ b/packages/ui/src/shared/mascot-shapes.ts@@ -0,0 +1,26 @@+export const MASCOT_VIEW_BOX = '20 50 160 120';+export const MASCOT_ASPECT = 120 / 160;++export const MASCOT_BODY = { x: 30, y: 95, width: 140, height: 68, rx: 5 };+export const MASCOT_SEAM = { x: 30, y: 93, width: 140, height: 3 };+export const MASCOT_CROWN = 'M30 95 L30 80 Q30 60, 100 60 Q170 60, 170 80 L170 95 Z';+export const MASCOT_CROWN_SPLIT = 'M30 95 L170 60 L170 95 Z';++export const MASCOT_FACES = {+ happy: {+ eyes: ['M68 122 Q76 112 84 122', 'M116 122 Q124 112 132 122'],+ eyeWidth: 5,+ mouth: 'M84 138 Q100 148 116 138',+ mouthWidth: 3.5,+ },+ lookaway: {+ pupils: [+ { cx: 80, cy: 124, r: 5 },+ { cx: 128, cy: 124, r: 5 },+ ],+ mouth: 'M86 141 Q100 136 116 141',+ mouthWidth: 3.5,+ },+} as const;++export type MascotPose = keyof typeof MASCOT_FACES;