feat(V2-1c): packages/ui 추출 — DS 컴포넌트 + theme + theme-vars 분리

packages/ui (@d3ro/ui) 신규:
- src/theme.ts (d3roPalette/d3roTypo/d3roShadow/d3roRadius SSOT)
- src/theme-vars.ts (팝업/main 프로세스용 CSS 변수 맵)
- src/components/ds/ (CrtDisplay, InstrumentPanel, Led, MetalCard,
  MetalDial, PhosphorText, PhysicalButton, ScreenPanel, ButtonGroup)
- src/index.ts barrel
- subpath exports: ./theme, ./theme-vars, ./components/ds
- React/MUI/Emotion은 peerDependencies로 선언
- @d3ro/core만 직접 의존성

apps/desktop/src/shared/ 디렉토리 완전 제거:
- theme-vars가 마지막 남은 파일이었음
- tsconfig include에서 src/shared/**/* 제거

일괄 치환 (renderer 전역):
- ../theme, ../../theme, ./theme → @d3ro/ui/theme
- ../components/ds, ../../components/ds, ./ds, ../ds → @d3ro/ui/components/ds
- ../ds/<Component>, ../../ds/<Component> → @d3ro/ui/components/ds
  (세부 파일 import는 barrel로 통합)
- @shared/theme-vars → @d3ro/ui/theme-vars (WindowManager)

apps/desktop 설정:
- package.json: @d3ro/ui: '*' dep 추가
- tsconfig.node/web.json: @shared/* paths 완전 제거, @d3ro/ui,
  @d3ro/ui/* paths 추가
- electron.vite.config.ts: @shared alias 제거, @d3ro/ui alias 추가,
  externalize exclude에 @d3ro/ui 추가
- vitest.config.ts: alias 교체

DS 컴포넌트 내부의 '../../theme' 상대 경로는 packages/ui 구조에서
동일하게 해결되어 그대로 유효.

검증: typecheck + build + dev 런타임 모두 통과.
This commit is contained in:
yunchan8804 2026-04-08 14:50:33 +09:00
parent 3b0eb3393b
commit a041f1b6a9
56 changed files with 191 additions and 76 deletions

View file

@ -0,0 +1,82 @@
// src/renderer/components/ds/InstrumentPanel.tsx
// 시안 A: 메탈 섀시 컨테이너 — 노이즈 텍스처, 각인 텍스트, 물리적 존재감
import { Box, Typography } from '@mui/material'
import { useTheme } from '@mui/material/styles'
import { d3roPalette, d3roFontMono, d3roShadow, d3roRadius, d3roTypo } from '../../theme'
interface InstrumentPanelProps {
children: React.ReactNode
/** 상단 좌측 각인 */
engravingLeft?: string
/** 상단 우측 각인 */
engravingRight?: string
/** 하단 중앙 각인 */
engravingBottom?: string
}
export function InstrumentPanel({
children,
engravingLeft = 'D3RO-VOICE SYS.',
engravingRight = 'MOD-01 / TERMINAL',
engravingBottom = 'LOCAL AI VOICE ASSISTANT',
}: InstrumentPanelProps): React.ReactElement {
return (
<Box
sx={{
position: 'relative',
bgcolor: d3roPalette.bg.chassis,
borderRadius: d3roRadius.outer,
p: 3,
boxShadow: d3roShadow.chassis,
// 메탈 노이즈는 CSS로 시뮬레이션
'&::before': {
content: '""',
position: 'absolute',
inset: 0,
borderRadius: d3roRadius.outer,
backgroundImage: `url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E")`,
opacity: 0.04,
mixBlendMode: 'overlay',
pointerEvents: 'none',
zIndex: 1,
},
}}
>
{/* 각인 텍스트 */}
<Engraving sx={{ top: 12, left: 24 }}>{engravingLeft}</Engraving>
<Engraving sx={{ top: 12, right: 24 }}>{engravingRight}</Engraving>
<Engraving sx={{ bottom: 12, left: '50%', transform: 'translateX(-50%)' }}>{engravingBottom}</Engraving>
{/* 콘텐츠 (z-index 5로 노이즈 위) */}
<Box sx={{ position: 'relative', zIndex: 5 }}>
{children}
</Box>
</Box>
)
}
function Engraving({ children, sx }: { children: string; sx: Record<string, unknown> }): React.ReactElement {
const theme = useTheme()
const isLight = theme.palette.mode === 'light'
return (
<Typography
sx={{
position: 'absolute',
fontSize: d3roTypo.engrave.size,
letterSpacing: d3roTypo.engrave.spacing,
color: d3roPalette.text.engraving,
textShadow: isLight
? '0 -1px 0 rgba(0,0,0,0.1)'
: '0 1px 0 rgba(255,255,255,0.08)',
fontWeight: 700,
fontFamily: d3roFontMono,
zIndex: 2,
userSelect: 'none',
...sx,
}}
>
{children}
</Typography>
)
}