refactor: extract hexToRgba and prefersReducedMotion to shared utils
Move hexToRgba() (3 identical copies) and prefersReducedMotion (5 module-level copies) to src/lib/utils.ts. Re-export prefersReducedMotion from constellation/constants.ts to preserve existing importers. Add clarifying comments to constellation.ts and tags.ts re-export layers (Phase 1.4).
This commit is contained in:
@@ -17,8 +17,7 @@ import { useDetailPanel } from '@/contexts/DetailPanelContext'
|
||||
import { timelineConsultations } from '@/data/timeline'
|
||||
import { skills } from '@/data/skills'
|
||||
import type { PaletteAction } from '@/lib/search'
|
||||
|
||||
const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches
|
||||
import { hexToRgba, prefersReducedMotion } from '@/lib/utils'
|
||||
|
||||
const sidebarVariants = {
|
||||
hidden: prefersReducedMotion ? { x: 0, opacity: 1 } : { x: -272, opacity: 0 },
|
||||
@@ -41,13 +40,6 @@ const contentVariants = {
|
||||
},
|
||||
}
|
||||
|
||||
function hexToRgba(hex: string, opacity: number): string {
|
||||
const r = parseInt(hex.slice(1, 3), 16)
|
||||
const g = parseInt(hex.slice(3, 5), 16)
|
||||
const b = parseInt(hex.slice(5, 7), 16)
|
||||
return `rgba(${r},${g},${b},${opacity})`
|
||||
}
|
||||
|
||||
interface LastConsultationSubsectionProps {
|
||||
highlightedRoleId?: string | null
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user