-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: semantic token 구현 완료 * docs: color 문서 완료 * docs: spacing 문서 완료 * refactor: spacing을 number와 radius로 분리 * feat: Number 관련 문서 완료
- Loading branch information
Showing
25 changed files
with
573 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import { ColorItem, ColorPalette } from '@storybook/blocks'; | ||
import { Meta, StoryObj } from '@storybook/react'; | ||
import { styled } from 'styled-components'; | ||
|
||
import { semanticColorPalette } from '@/style/foundation/color/semanticColor'; | ||
|
||
const meta: Meta = { | ||
title: 'Foundation/Color', | ||
parameters: { | ||
layout: 'centered', | ||
}, | ||
}; | ||
|
||
const StyledColorExample = styled.div` | ||
width: 100px; | ||
height: 100px; | ||
color: ${({ theme }) => theme.semantic.color.textBasicWhite}; | ||
background-color: ${({ theme }) => theme.semantic.color.bgBrandPrimary}; | ||
`; | ||
|
||
const AllThemeColors = () => { | ||
const getSemanticColorPalette = (prefix: string) => { | ||
const colors: Record<string, string> = {}; | ||
|
||
Object.entries(semanticColorPalette).forEach(([name, value]) => { | ||
if (name.startsWith(prefix)) { | ||
colors[name] = value; | ||
} | ||
}); | ||
|
||
if (Object.keys(colors).length === 0) { | ||
throw Error(`No colors found for prefix: ${prefix}`); | ||
} | ||
|
||
return { | ||
title: `${prefix}`, | ||
colors, | ||
}; | ||
}; | ||
|
||
const semanticColorCategories = { | ||
background: ['bgBasic', 'bgBrand', 'bgStatus'], | ||
text: ['textBasic', 'textBrand', 'textStatus'], | ||
line: ['lineBasic', 'lineStatus'], | ||
'button/box': ['buttonBoxPrimary', 'buttonBoxSecondary', 'buttonBoxTertiary'], | ||
'button/text': ['buttonTextPrimary', 'buttonTextSecondary'], | ||
'button/fab': ['buttonFabPrimary', 'buttonFabSecondary'], | ||
'button/radio': ['buttonRadio'], | ||
icon: ['iconBasic', 'iconBrand'], | ||
checkbox: ['checkbox'], | ||
chip: ['chip'], | ||
pagination: ['paginationBrand', 'paginationBasic'], | ||
}; | ||
|
||
return ( | ||
<> | ||
{Object.keys(semanticColorCategories).map((section) => { | ||
const colors = semanticColorCategories[section as keyof typeof semanticColorCategories].map( | ||
(category) => getSemanticColorPalette(category) | ||
); | ||
|
||
return ( | ||
<div> | ||
<h2>{section}</h2> | ||
<ColorPalette> | ||
{colors.map((color) => { | ||
return ( | ||
<ColorItem | ||
title={color.title} | ||
subtitle="theme.semantic.color" | ||
colors={color.colors} | ||
/> | ||
); | ||
})} | ||
</ColorPalette> | ||
<br /> | ||
<br /> | ||
</div> | ||
); | ||
})} | ||
</> | ||
); | ||
}; | ||
|
||
const ColorExample: StoryObj = { | ||
render: () => <StyledColorExample>Color 색상</StyledColorExample>, | ||
}; | ||
export default meta; | ||
export { ColorExample, AllThemeColors }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export * from './primitiveColor'; | ||
// export * from './semanticColor'; | ||
export * from './semanticColor'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
export type * from './primitiveColor.type'; | ||
export { primitiveColorPalette } from './primitiveColorPalette'; | ||
export type { PrimitiveColorPalette } from './primitiveColorPalette'; |
38 changes: 21 additions & 17 deletions
38
src/style/foundation/color/primitiveColor/primitiveColor.type.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,31 @@ | ||
// https://www.figma.com/design/gvwhMF6iNkuYKzxipKzkaG/Handy-v1-(demo)?node-id=636-131805&t=Wr7H8VzVaJXsyDQT-1 | ||
|
||
type PrimitiveVariousColor<ColorName extends string> = | ||
| `${ColorName}050` | ||
| `${ColorName}100` | ||
| `${ColorName}200` | ||
| `${ColorName}300` | ||
| `${ColorName}400` | ||
| `${ColorName}500` | ||
| `${ColorName}600` | ||
| `${ColorName}700` | ||
| `${ColorName}800` | ||
| `${ColorName}900` | ||
| `${ColorName}950`; | ||
import { MergeVariants } from '@/types/variant'; | ||
|
||
export type PrimitiveVioletColor = PrimitiveVariousColor<'violet'>; | ||
export type PrimitiveGrayColor = PrimitiveVariousColor<'gray'>; | ||
type PrimitiveColorSaturationVariant = | ||
| '050' | ||
| '100' | ||
| '200' | ||
| '300' | ||
| '400' | ||
| '500' | ||
| '600' | ||
| '700' | ||
| '800' | ||
| '900' | ||
| '950'; | ||
|
||
export type PrimitiveNeutralColor = 'neutralBlack' | 'neutralWhite' | 'neutralTransparent'; | ||
export type PrimitiveVioletColor = MergeVariants<'violet', PrimitiveColorSaturationVariant>; | ||
export type PrimitiveGrayColor = MergeVariants<'gray', PrimitiveColorSaturationVariant>; | ||
|
||
export type PrimitiveStatusColor = 'statusRedMain' | 'statusRedSub'; | ||
export type PrimitiveNeutralColor = MergeVariants<'neutral', 'black' | 'white' | 'transparent'>; | ||
|
||
export type PrimitiveColor = | ||
export type PrimitiveStatusColor = MergeVariants<'status', 'red', 'main' | 'sub'>; | ||
|
||
export type PrimitiveColorType = | ||
| PrimitiveVioletColor | ||
| PrimitiveGrayColor | ||
| PrimitiveNeutralColor | ||
| PrimitiveStatusColor; | ||
|
||
export type PrimitiveColorPalette = Readonly<Record<PrimitiveColorType, string>>; |
4 changes: 1 addition & 3 deletions
4
src/style/foundation/color/primitiveColor/primitiveColorPalette.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export type * from './semanticColor.type'; | ||
export { semanticColorPalette } from './semanticColorPalette'; |
121 changes: 121 additions & 0 deletions
121
src/style/foundation/color/semanticColor/semanticColor.type.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
import { MergeVariants } from '@/types/variant'; | ||
|
||
type StaticBasicVariant = 'primary' | 'secondary' | 'tertiary' | 'disabled' | 'white'; | ||
type StaticBrandVariant = 'primary' | 'secondary'; | ||
type StatusVariant = 'negative' | 'positive'; | ||
type InteractiveVariant = 'enabled' | 'pressed' | 'disabled'; | ||
type SelectableVariant = 'selected' | 'unselected'; | ||
type SelectableVariantWithDisabled = SelectableVariant | 'disabled'; | ||
|
||
export type SemanticBackgroundBasicColor = MergeVariants< | ||
'bg', | ||
'basic', | ||
'default' | 'light' | 'strong' | 'black' | ||
>; | ||
|
||
export type SemanticBackgroundBrandColor = MergeVariants<'bg', 'brand', StaticBrandVariant>; | ||
|
||
export type SemanticBackgroundStatusColor = MergeVariants<'bg', 'status', StatusVariant>; | ||
|
||
export type SemanticTextBasicColor = MergeVariants<'text', 'basic', StaticBasicVariant>; | ||
|
||
export type SemanticTextBrandColor = MergeVariants<'text', 'brand', StaticBrandVariant>; | ||
|
||
export type SemanticTextStatusColor = MergeVariants<'text', 'status', StatusVariant>; | ||
|
||
export type SemanticLineBasicColor = MergeVariants<'line', 'basic', 'light' | 'medium' | 'strong'>; | ||
|
||
export type SemanticLineStatusColor = MergeVariants<'line', 'status', StatusVariant>; | ||
|
||
export type SemanticButtonBoxPrimaryColor = MergeVariants< | ||
'button', | ||
'box', | ||
'primary', | ||
InteractiveVariant | ||
>; | ||
|
||
export type SemanticButtonBoxSecondaryColor = MergeVariants< | ||
'button', | ||
'box', | ||
'secondary', | ||
InteractiveVariant | ||
>; | ||
|
||
export type SemanticButtonBoxTertiaryColor = MergeVariants< | ||
'button', | ||
'box', | ||
'tertiary', | ||
InteractiveVariant | ||
>; | ||
|
||
export type SemanticButtonFabPrimaryColor = MergeVariants< | ||
'button', | ||
'fab', | ||
'primary', | ||
InteractiveVariant | ||
>; | ||
|
||
export type SemanticButtonFabSecondaryColor = MergeVariants< | ||
'button', | ||
'fab', | ||
'secondary', | ||
InteractiveVariant | ||
>; | ||
|
||
export type SemanticButtonTextPrimaryColor = MergeVariants< | ||
'button', | ||
'text', | ||
'primary', | ||
InteractiveVariant | ||
>; | ||
|
||
export type SemanticButtonTextSecondaryColor = MergeVariants< | ||
'button', | ||
'text', | ||
'secondary', | ||
InteractiveVariant | ||
>; | ||
|
||
export type SemanticButtonRadioColor = MergeVariants< | ||
'button', | ||
'radio', | ||
SelectableVariantWithDisabled | ||
>; | ||
|
||
export type SemanticIconBasicColor = MergeVariants<'icon', 'basic', StaticBasicVariant>; | ||
|
||
export type SemanticIconBrandColor = MergeVariants<'icon', 'brand', StaticBrandVariant>; | ||
|
||
export type SemanticCheckboxColor = MergeVariants<'checkbox', SelectableVariantWithDisabled>; | ||
|
||
export type SemanticChipColor = MergeVariants<'chip', SelectableVariantWithDisabled>; | ||
|
||
export type SemanticPaginationBrandColor = MergeVariants<'pagination', 'brand', 'pressed'>; | ||
|
||
export type SemanticPaginationBasicColor = MergeVariants<'pagination', 'basic', SelectableVariant>; | ||
|
||
export type SemanticColorType = | ||
| SemanticBackgroundBasicColor | ||
| SemanticBackgroundBrandColor | ||
| SemanticBackgroundStatusColor | ||
| SemanticTextBasicColor | ||
| SemanticTextBrandColor | ||
| SemanticTextStatusColor | ||
| SemanticLineBasicColor | ||
| SemanticLineStatusColor | ||
| SemanticButtonBoxPrimaryColor | ||
| SemanticButtonBoxSecondaryColor | ||
| SemanticButtonBoxTertiaryColor | ||
| SemanticButtonFabPrimaryColor | ||
| SemanticButtonFabSecondaryColor | ||
| SemanticButtonTextPrimaryColor | ||
| SemanticButtonTextSecondaryColor | ||
| SemanticButtonRadioColor | ||
| SemanticIconBasicColor | ||
| SemanticIconBrandColor | ||
| SemanticCheckboxColor | ||
| SemanticChipColor | ||
| SemanticPaginationBrandColor | ||
| SemanticPaginationBasicColor; | ||
|
||
export type SemanticColorPalette = Readonly<Record<SemanticColorType, string>>; |
Oops, something went wrong.