Skip to content

Commit 7c951ef

Browse files
authored
Support new colors in text formatting (#3492)
1 parent 68f0dbc commit 7c951ef

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

.changeset/brave-mugs-worry.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"gitbook": patch
3+
---
4+
5+
'Support new colors in text formatting

packages/gitbook/src/components/DocumentView/Text.tsx

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,22 +126,50 @@ function Color(props: MarkedLeafProps<DocumentMarkColor>) {
126126
);
127127
}
128128

129-
const textColorToStyle: { [color in DocumentMarkColor['data']['text']]: ClassValue } = {
129+
/**
130+
* @TODO replace by DocumentMarkColor['data']['text'] and DocumentMarkColor['data']['background']
131+
* once the API is updated.
132+
*/
133+
type DocumentMarkColorValue =
134+
| 'default'
135+
| 'green'
136+
| 'blue'
137+
| 'red'
138+
| 'orange'
139+
| 'yellow'
140+
| 'purple'
141+
| '$primary'
142+
| '$info'
143+
| '$success'
144+
| '$warning'
145+
| '$danger';
146+
147+
const textColorToStyle: { [color in DocumentMarkColorValue]: ClassValue } = {
130148
default: [],
131149
blue: ['text-blue-500'],
132150
red: ['text-red-500'],
133151
green: ['text-green-500'],
134152
yellow: ['text-yellow-600'],
135153
purple: ['text-purple-500'],
136154
orange: ['text-orange-500'],
155+
$primary: ['text-primary'],
156+
$info: ['text-info'],
157+
$success: ['text-success'],
158+
$warning: ['text-warning'],
159+
$danger: ['text-danger'],
137160
};
138161

139-
const backgroundColorToStyle: { [color in DocumentMarkColor['data']['background']]: ClassValue } = {
162+
const backgroundColorToStyle: { [color in DocumentMarkColorValue]: ClassValue } = {
140163
default: [],
141164
blue: ['bg-mark-blue'],
142165
red: ['bg-mark-red'],
143166
green: ['bg-mark-green'],
144167
yellow: ['bg-mark-yellow'],
145168
purple: ['bg-mark-purple'],
146169
orange: ['bg-mark-orange'],
170+
$primary: ['bg-primary'],
171+
$info: ['bg-info'],
172+
$success: ['bg-success'],
173+
$warning: ['bg-warning'],
174+
$danger: ['bg-danger'],
147175
};

0 commit comments

Comments
 (0)