이 문서는 Daepyro Design System의 테마 커스터마이징 방법을 설명합니다.
현재 디자인 시스템은 vanilla-extract를 사용하여 CSS 변수를 통해 테마를 커스터마이징할 수 있습니다.
/* 전역 CSS 변수 정의 */
:root {
--color-primary: #007bff;
--color-secondary: #6c757d;
--spacing-unit: 8px;
--border-radius: 4px;
}import { style } from "@vanilla-extract/css";
export const button = style({
padding: "8px 12px",
borderRadius: "9999px",
border: "none",
cursor: "pointer",
fontWeight: 500,
// CSS 변수 사용
backgroundColor: "var(--color-primary, #007bff)",
color: "var(--color-text, #ffffff)",
});/* 라이트 모드 */
:root {
--bg-color: #ffffff;
--text-color: #000000;
}
/* 다크 모드 */
@media (prefers-color-scheme: dark) {
:root {
--bg-color: #1a1a1a;
--text-color: #ffffff;
}
}// 다크 모드 클래스 추가
document.documentElement.classList.add("dark");
// CSS
.dark {
--bg-color: #1a1a1a;
--text-color: #ffffff;
}import { Button } from "@team-numberone/design-system";
import "./custom-button.css";
function CustomButton() {
return (
<Button className="custom-button">
커스텀 버튼
</Button>
);
}/* custom-button.css */
.custom-button {
background-color: #ff6b6b;
border-radius: 8px;
padding: 12px 24px;
}import { Button } from "@team-numberone/design-system";
import { css } from "@emotion/react";
const customStyle = css`
background-color: #ff6b6b;
border-radius: 8px;
`;
function CustomButton() {
return (
<Button css={customStyle}>
커스텀 버튼
</Button>
);
}// tokens/colors.ts
export const colors = {
primary: {
main: "#007bff",
light: "#66b3ff",
dark: "#0056b3",
},
secondary: {
main: "#6c757d",
light: "#9fa5aa",
dark: "#4e5459",
},
} as const;
// tokens/spacing.ts
export const spacing = {
xs: "4px",
sm: "8px",
md: "16px",
lg: "24px",
xl: "32px",
} as const;import { style } from "@vanilla-extract/css";
import { colors, spacing } from "../tokens";
export const button = style({
padding: `${spacing.sm} ${spacing.md}`,
backgroundColor: colors.primary.main,
color: "#ffffff",
borderRadius: "9999px",
});/* 브랜드별 CSS 변수 */
:root[data-brand="company-a"] {
--color-primary: #ff6b6b;
--color-secondary: #4ecdc4;
}
:root[data-brand="company-b"] {
--color-primary: #95e1d3;
--color-secondary: #f38181;
}// 브랜드 설정
document.documentElement.setAttribute("data-brand", "company-a");import { style } from "@vanilla-extract/css";
export const button = style({
padding: "8px 12px",
"@media": {
"(min-width: 768px)": {
padding: "12px 24px",
},
"(min-width: 1024px)": {
padding: "16px 32px",
},
},
});:root {
transition: background-color 0.3s ease, color 0.3s ease;
}
* {
transition: background-color 0.3s ease, color 0.3s ease;
}