Skip to content

Commit 4f0e66d

Browse files
committed
feat: notion color 지정
1 parent e06cf1e commit 4f0e66d

File tree

3 files changed

+145
-8
lines changed

3 files changed

+145
-8
lines changed

packages/notion-to-jsx/src/components/Renderer/components/RichText/RichTexts.tsx

Lines changed: 51 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,28 @@
11
import React from 'react';
22
import { richText, link } from './styles.css';
33

4+
// 지원하는 Notion 색상 타입 정의
5+
type NotionColor =
6+
| 'default'
7+
| 'gray'
8+
| 'brown'
9+
| 'orange'
10+
| 'yellow'
11+
| 'green'
12+
| 'blue'
13+
| 'purple'
14+
| 'pink'
15+
| 'red'
16+
| 'gray_background'
17+
| 'brown_background'
18+
| 'orange_background'
19+
| 'yellow_background'
20+
| 'green_background'
21+
| 'blue_background'
22+
| 'purple_background'
23+
| 'pink_background'
24+
| 'red_background';
25+
426
export interface RichTextItem {
527
type: 'text' | 'mention' | string;
628
annotations: {
@@ -43,7 +65,7 @@ const RichTexts: React.FC<RichTextProps> = ({ richTexts }) => {
4365
return (
4466
<>
4567
{richTexts.map((text, index) => {
46-
const { bold, italic, strikethrough, underline, code } =
68+
const { bold, italic, strikethrough, underline, code, color } =
4769
text.annotations;
4870

4971
// 컨텐츠 렌더링 로직
@@ -75,13 +97,33 @@ const RichTexts: React.FC<RichTextProps> = ({ richTexts }) => {
7597
}
7698
}
7799

78-
// TODO: NOTION COLOR 적용
79-
// const colorValue =
80-
// color === 'default'
81-
// ? 'inherit'
82-
// : color?.includes('_background')
83-
// ? `var(--notion-${color})`
84-
// : `var(--notion-${color})`;
100+
// NOTION COLOR 적용
101+
// color 값이 지원하는 색상이 아닌 경우 undefined로 처리하여 타입 에러 방지
102+
const notionColors: NotionColor[] = [
103+
'default',
104+
'gray',
105+
'brown',
106+
'orange',
107+
'yellow',
108+
'green',
109+
'blue',
110+
'purple',
111+
'pink',
112+
'red',
113+
'gray_background',
114+
'brown_background',
115+
'orange_background',
116+
'yellow_background',
117+
'green_background',
118+
'blue_background',
119+
'purple_background',
120+
'pink_background',
121+
'red_background',
122+
];
123+
124+
const safeColor = notionColors.includes(color as NotionColor)
125+
? (color as NotionColor)
126+
: undefined;
85127

86128
return (
87129
<span
@@ -92,6 +134,7 @@ const RichTexts: React.FC<RichTextProps> = ({ richTexts }) => {
92134
strikethrough,
93135
underline,
94136
code,
137+
color: safeColor,
95138
})}
96139
>
97140
{content}

packages/notion-to-jsx/src/components/Renderer/components/RichText/styles.css.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,37 @@ export const richText = recipe({
4141
verticalAlign: 'middle',
4242
},
4343
},
44+
color: {
45+
default: {},
46+
gray: { color: vars.colors.notion.gray },
47+
brown: { color: vars.colors.notion.brown },
48+
orange: { color: vars.colors.notion.orange },
49+
yellow: { color: vars.colors.notion.yellow },
50+
green: { color: vars.colors.notion.green },
51+
blue: { color: vars.colors.notion.blue },
52+
purple: { color: vars.colors.notion.purple },
53+
pink: { color: vars.colors.notion.pink },
54+
red: { color: vars.colors.notion.red },
55+
gray_background: { backgroundColor: vars.colors.notion.gray_background },
56+
brown_background: {
57+
backgroundColor: vars.colors.notion.brown_background,
58+
},
59+
orange_background: {
60+
backgroundColor: vars.colors.notion.orange_background,
61+
},
62+
yellow_background: {
63+
backgroundColor: vars.colors.notion.yellow_background,
64+
},
65+
green_background: {
66+
backgroundColor: vars.colors.notion.green_background,
67+
},
68+
blue_background: { backgroundColor: vars.colors.notion.blue_background },
69+
purple_background: {
70+
backgroundColor: vars.colors.notion.purple_background,
71+
},
72+
pink_background: { backgroundColor: vars.colors.notion.pink_background },
73+
red_background: { backgroundColor: vars.colors.notion.red_background },
74+
},
4475
},
4576

4677
compoundVariants: [

packages/notion-to-jsx/src/styles/theme.css.ts

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,27 @@ export const vars = createThemeContract({
2121
inline: null,
2222
inlineBackground: null,
2323
},
24+
// Notion 색상 변수
25+
notion: {
26+
gray: null,
27+
brown: null,
28+
orange: null,
29+
yellow: null,
30+
green: null,
31+
blue: null,
32+
purple: null,
33+
pink: null,
34+
red: null,
35+
gray_background: null,
36+
brown_background: null,
37+
orange_background: null,
38+
yellow_background: null,
39+
green_background: null,
40+
blue_background: null,
41+
purple_background: null,
42+
pink_background: null,
43+
red_background: null,
44+
},
2445
},
2546
typography: {
2647
fontFamily: {
@@ -140,6 +161,27 @@ export const lightTheme = createTheme(vars, {
140161
inline: '#EB5757',
141162
inlineBackground: 'rgba(135,131,120,.15)',
142163
},
164+
// Notion 색상 - 라이트 테마
165+
notion: {
166+
gray: '#787774',
167+
brown: '#9F6B53',
168+
orange: '#D9730D',
169+
yellow: '#CB912F',
170+
green: '#448361',
171+
blue: '#337EA9',
172+
purple: '#9065B0',
173+
pink: '#C14C8A',
174+
red: '#D44C47',
175+
gray_background: '#EBECED',
176+
brown_background: '#E9E5E3',
177+
orange_background: '#FAEBDD',
178+
yellow_background: '#FBF3DB',
179+
green_background: '#EDF3EC',
180+
blue_background: '#E1F0F5',
181+
purple_background: '#F4EEFF',
182+
pink_background: '#F9EEF3',
183+
red_background: '#FDEBEC',
184+
},
143185
},
144186
shadows: {
145187
sm: '0 1px 2px 0 rgba(0, 0, 0, 0.05)',
@@ -167,6 +209,27 @@ export const darkTheme = createTheme(vars, {
167209
inline: '#EB5757',
168210
inlineBackground: '#161b22',
169211
},
212+
// Notion 색상 - 다크 테마
213+
notion: {
214+
gray: '#999999',
215+
brown: '#BA9A88',
216+
orange: '#E78A4E',
217+
yellow: '#DBAB4C',
218+
green: '#68A678',
219+
blue: '#529CCA',
220+
purple: '#B185DB',
221+
pink: '#D668A4',
222+
red: '#E66A65',
223+
gray_background: '#3F3F3F',
224+
brown_background: '#434040',
225+
orange_background: '#443227',
226+
yellow_background: '#434027',
227+
green_background: '#293D34',
228+
blue_background: '#25404E',
229+
purple_background: '#362C48',
230+
pink_background: '#40242E',
231+
red_background: '#442C2B',
232+
},
170233
},
171234
shadows: {
172235
sm: '0 1px 2px 0 rgba(0, 0, 0, 0.05)',

0 commit comments

Comments
 (0)