cpk-ui 0.4.2 → 0.5.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { Text } from 'react-native';
|
|
2
2
|
import { CpkTheme } from '../../../utils/theme';
|
|
3
|
+
type FontFamilyOptions = {
|
|
4
|
+
normal: string;
|
|
5
|
+
thin?: string;
|
|
6
|
+
bold?: string;
|
|
7
|
+
};
|
|
8
|
+
type FontFamilyConfig = {
|
|
9
|
+
heading?: FontFamilyOptions;
|
|
10
|
+
body?: FontFamilyOptions;
|
|
11
|
+
};
|
|
3
12
|
export declare const Typography: {
|
|
4
13
|
Title: import("kstyled").StyledComponent<typeof Text, {
|
|
5
14
|
theme?: CpkTheme;
|
|
@@ -84,14 +93,7 @@ export declare const TypographyInverted: {
|
|
|
84
93
|
$fontWeight?: "normal" | "bold" | "thin";
|
|
85
94
|
}, {}>;
|
|
86
95
|
};
|
|
87
|
-
export declare const setFontFamily: (fontFamilies:
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
bold?: string;
|
|
91
|
-
}) => void;
|
|
92
|
-
export declare const getFontFamilies: () => {
|
|
93
|
-
normal: string;
|
|
94
|
-
thin: string;
|
|
95
|
-
bold: string;
|
|
96
|
-
};
|
|
96
|
+
export declare const setFontFamily: (fontFamilies: FontFamilyConfig) => void;
|
|
97
|
+
export declare const getFontFamilies: (isHeading: boolean) => FontFamilyOptions;
|
|
98
|
+
export {};
|
|
97
99
|
//# sourceMappingURL=Typography.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Typography.d.ts","sourceRoot":"","sources":["../../../../src/components/uis/Typography/Typography.tsx"],"names":[],"mappings":"AACA,OAAO,EAAY,IAAI,EAAY,MAAM,cAAc,CAAC;AACxD,OAAO,EAAC,QAAQ,EAAgB,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"Typography.d.ts","sourceRoot":"","sources":["../../../../src/components/uis/Typography/Typography.tsx"],"names":[],"mappings":"AACA,OAAO,EAAY,IAAI,EAAY,MAAM,cAAc,CAAC;AACxD,OAAO,EAAC,QAAQ,EAAgB,MAAM,sBAAsB,CAAC;AAK7D,KAAK,iBAAiB,GAAG;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,KAAK,gBAAgB,GAAG;IACtB,OAAO,CAAC,EAAE,iBAAiB,CAAC;IAC5B,IAAI,CAAC,EAAE,iBAAiB,CAAC;CAC1B,CAAC;AAuNF,eAAO,MAAM,UAAU;;gBAjNI,QAAQ;sBAAgB,QAAQ,GAAG,MAAM,GAAG,MAAM;;;gBAAlD,QAAQ;sBAAgB,QAAQ,GAAG,MAAM,GAAG,MAAM;;;gBAAlD,QAAQ;sBAAgB,QAAQ,GAAG,MAAM,GAAG,MAAM;;;gBAAlD,QAAQ;sBAAgB,QAAQ,GAAG,MAAM,GAAG,MAAM;;;gBAAlD,QAAQ;sBAAgB,QAAQ,GAAG,MAAM,GAAG,MAAM;;;gBAAlD,QAAQ;sBAAgB,QAAQ,GAAG,MAAM,GAAG,MAAM;;;gBAAlD,QAAQ;sBAAgB,QAAQ,GAAG,MAAM,GAAG,MAAM;;;gBAAlD,QAAQ;sBAAgB,QAAQ,GAAG,MAAM,GAAG,MAAM;;;gBAAlD,QAAQ;sBAAgB,QAAQ,GAAG,MAAM,GAAG,MAAM;;;gBAAlD,QAAQ;sBAAgB,QAAQ,GAAG,MAAM,GAAG,MAAM;;CA4N5E,CAAC;AAEF,eAAO,MAAM,kBAAkB;;gBA9NJ,QAAQ;sBAAgB,QAAQ,GAAG,MAAM,GAAG,MAAM;;;gBAAlD,QAAQ;sBAAgB,QAAQ,GAAG,MAAM,GAAG,MAAM;;;gBAAlD,QAAQ;sBAAgB,QAAQ,GAAG,MAAM,GAAG,MAAM;;;gBAAlD,QAAQ;sBAAgB,QAAQ,GAAG,MAAM,GAAG,MAAM;;;gBAAlD,QAAQ;sBAAgB,QAAQ,GAAG,MAAM,GAAG,MAAM;;;gBAAlD,QAAQ;sBAAgB,QAAQ,GAAG,MAAM,GAAG,MAAM;;;gBAAlD,QAAQ;sBAAgB,QAAQ,GAAG,MAAM,GAAG,MAAM;;;gBAAlD,QAAQ;sBAAgB,QAAQ,GAAG,MAAM,GAAG,MAAM;;;gBAAlD,QAAQ;sBAAgB,QAAQ,GAAG,MAAM,GAAG,MAAM;;;gBAAlD,QAAQ;sBAAgB,QAAQ,GAAG,MAAM,GAAG,MAAM;;CAyO5E,CAAC;AAeF,eAAO,MAAM,aAAa,GAAI,cAAc,gBAAgB,KAAG,IAiF9D,CAAC;AAGF,eAAO,MAAM,eAAe,GAAI,WAAW,OAAO,KAAG,iBAOpD,CAAC"}
|
|
@@ -4,9 +4,10 @@ import { Text, TextInput } from 'react-native';
|
|
|
4
4
|
import { isEmptyObject } from '../../../utils/theme';
|
|
5
5
|
import { light } from '../../../utils/colors';
|
|
6
6
|
import { styled, css } from 'kstyled';
|
|
7
|
-
const createBaseText = (colorResolver, fallbackColor) => styled(Text) `
|
|
7
|
+
const createBaseText = (colorResolver, fallbackColor, isHeading) => styled(Text) `
|
|
8
8
|
font-family: ${({ $fontWeight }) => {
|
|
9
|
-
const
|
|
9
|
+
const fontFamilies = getFontFamilies(isHeading);
|
|
10
|
+
const { normal, thin = normal, bold = normal } = fontFamilies;
|
|
10
11
|
switch ($fontWeight) {
|
|
11
12
|
case 'bold':
|
|
12
13
|
return bold;
|
|
@@ -36,117 +37,119 @@ const createTextComponent = ({ BaseText, fontSize, lineHeight, fontWeight, }) =>
|
|
|
36
37
|
], [style]);
|
|
37
38
|
return (_jsx(BaseText, { ...props, "$fontWeight": fontWeight, style: textStyle, children: children }));
|
|
38
39
|
});
|
|
39
|
-
const
|
|
40
|
-
const
|
|
40
|
+
const StandardHeadingBaseText = createBaseText((theme) => theme.text.basic, 'gray', true);
|
|
41
|
+
const StandardBodyBaseText = createBaseText((theme) => theme.text.basic, 'gray', false);
|
|
42
|
+
const InvertedHeadingBaseText = createBaseText((theme) => theme.text.contrast, light.text.contrast, true);
|
|
43
|
+
const InvertedBodyBaseText = createBaseText((theme) => theme.text.contrast, light.text.contrast, false);
|
|
41
44
|
const Title = createTextComponent({
|
|
42
|
-
BaseText:
|
|
45
|
+
BaseText: StandardHeadingBaseText,
|
|
43
46
|
fontSize: 36,
|
|
44
47
|
lineHeight: 50.4,
|
|
45
48
|
fontWeight: 'bold',
|
|
46
49
|
});
|
|
47
50
|
const Heading1 = createTextComponent({
|
|
48
|
-
BaseText:
|
|
51
|
+
BaseText: StandardHeadingBaseText,
|
|
49
52
|
fontSize: 28,
|
|
50
53
|
lineHeight: 39.2,
|
|
51
54
|
fontWeight: 'bold',
|
|
52
55
|
});
|
|
53
56
|
const Heading2 = createTextComponent({
|
|
54
|
-
BaseText:
|
|
57
|
+
BaseText: StandardHeadingBaseText,
|
|
55
58
|
fontSize: 26,
|
|
56
59
|
lineHeight: 36.4,
|
|
57
60
|
fontWeight: 'bold',
|
|
58
61
|
});
|
|
59
62
|
const Heading3 = createTextComponent({
|
|
60
|
-
BaseText:
|
|
63
|
+
BaseText: StandardHeadingBaseText,
|
|
61
64
|
fontSize: 24,
|
|
62
65
|
lineHeight: 33.6,
|
|
63
66
|
fontWeight: 'bold',
|
|
64
67
|
});
|
|
65
68
|
const Heading4 = createTextComponent({
|
|
66
|
-
BaseText:
|
|
69
|
+
BaseText: StandardHeadingBaseText,
|
|
67
70
|
fontSize: 22,
|
|
68
71
|
lineHeight: 30.8,
|
|
69
72
|
fontWeight: 'bold',
|
|
70
73
|
});
|
|
71
74
|
const Heading5 = createTextComponent({
|
|
72
|
-
BaseText:
|
|
75
|
+
BaseText: StandardHeadingBaseText,
|
|
73
76
|
fontSize: 20,
|
|
74
77
|
lineHeight: 28,
|
|
75
78
|
fontWeight: 'bold',
|
|
76
79
|
});
|
|
77
80
|
const Body1 = createTextComponent({
|
|
78
|
-
BaseText:
|
|
81
|
+
BaseText: StandardBodyBaseText,
|
|
79
82
|
fontSize: 18,
|
|
80
83
|
lineHeight: 25.2,
|
|
81
84
|
});
|
|
82
85
|
const Body2 = createTextComponent({
|
|
83
|
-
BaseText:
|
|
86
|
+
BaseText: StandardBodyBaseText,
|
|
84
87
|
fontSize: 16,
|
|
85
88
|
lineHeight: 22.4,
|
|
86
89
|
});
|
|
87
90
|
const Body3 = createTextComponent({
|
|
88
|
-
BaseText:
|
|
91
|
+
BaseText: StandardBodyBaseText,
|
|
89
92
|
fontSize: 14,
|
|
90
93
|
lineHeight: 19.6,
|
|
91
94
|
});
|
|
92
95
|
const Body4 = createTextComponent({
|
|
93
|
-
BaseText:
|
|
96
|
+
BaseText: StandardBodyBaseText,
|
|
94
97
|
fontSize: 12,
|
|
95
98
|
lineHeight: 16.4,
|
|
96
99
|
});
|
|
97
100
|
const InvertedTitle = createTextComponent({
|
|
98
|
-
BaseText:
|
|
101
|
+
BaseText: InvertedHeadingBaseText,
|
|
99
102
|
fontSize: 36,
|
|
100
103
|
lineHeight: 50.4,
|
|
101
104
|
fontWeight: 'bold',
|
|
102
105
|
});
|
|
103
106
|
const InvertedHeading1 = createTextComponent({
|
|
104
|
-
BaseText:
|
|
107
|
+
BaseText: InvertedHeadingBaseText,
|
|
105
108
|
fontSize: 28,
|
|
106
109
|
lineHeight: 39.2,
|
|
107
110
|
fontWeight: 'bold',
|
|
108
111
|
});
|
|
109
112
|
const InvertedHeading2 = createTextComponent({
|
|
110
|
-
BaseText:
|
|
113
|
+
BaseText: InvertedHeadingBaseText,
|
|
111
114
|
fontSize: 26,
|
|
112
115
|
lineHeight: 36.4,
|
|
113
116
|
fontWeight: 'bold',
|
|
114
117
|
});
|
|
115
118
|
const InvertedHeading3 = createTextComponent({
|
|
116
|
-
BaseText:
|
|
119
|
+
BaseText: InvertedHeadingBaseText,
|
|
117
120
|
fontSize: 24,
|
|
118
121
|
lineHeight: 33.6,
|
|
119
122
|
fontWeight: 'bold',
|
|
120
123
|
});
|
|
121
124
|
const InvertedHeading4 = createTextComponent({
|
|
122
|
-
BaseText:
|
|
125
|
+
BaseText: InvertedHeadingBaseText,
|
|
123
126
|
fontSize: 22,
|
|
124
127
|
lineHeight: 30.8,
|
|
125
128
|
fontWeight: 'bold',
|
|
126
129
|
});
|
|
127
130
|
const InvertedHeading5 = createTextComponent({
|
|
128
|
-
BaseText:
|
|
131
|
+
BaseText: InvertedHeadingBaseText,
|
|
129
132
|
fontSize: 20,
|
|
130
133
|
lineHeight: 28,
|
|
131
134
|
fontWeight: 'bold',
|
|
132
135
|
});
|
|
133
136
|
const InvertedBody1 = createTextComponent({
|
|
134
|
-
BaseText:
|
|
137
|
+
BaseText: InvertedBodyBaseText,
|
|
135
138
|
fontSize: 18,
|
|
136
139
|
lineHeight: 25.2,
|
|
137
140
|
});
|
|
138
141
|
const InvertedBody2 = createTextComponent({
|
|
139
|
-
BaseText:
|
|
142
|
+
BaseText: InvertedBodyBaseText,
|
|
140
143
|
fontSize: 16,
|
|
141
144
|
lineHeight: 22.4,
|
|
142
145
|
});
|
|
143
146
|
const InvertedBody3 = createTextComponent({
|
|
144
|
-
BaseText:
|
|
147
|
+
BaseText: InvertedBodyBaseText,
|
|
145
148
|
fontSize: 14,
|
|
146
149
|
lineHeight: 19.6,
|
|
147
150
|
});
|
|
148
151
|
const InvertedBody4 = createTextComponent({
|
|
149
|
-
BaseText:
|
|
152
|
+
BaseText: InvertedBodyBaseText,
|
|
150
153
|
fontSize: 12,
|
|
151
154
|
lineHeight: 16.4,
|
|
152
155
|
});
|
|
@@ -175,24 +178,48 @@ export const TypographyInverted = {
|
|
|
175
178
|
Body4: InvertedBody4,
|
|
176
179
|
};
|
|
177
180
|
let currentFontFamilies = {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
+
heading: {
|
|
182
|
+
normal: 'Pretendard',
|
|
183
|
+
thin: 'Pretendard-Thin',
|
|
184
|
+
bold: 'Pretendard-Bold',
|
|
185
|
+
},
|
|
186
|
+
body: {
|
|
187
|
+
normal: 'Pretendard',
|
|
188
|
+
thin: 'Pretendard-Thin',
|
|
189
|
+
bold: 'Pretendard-Bold',
|
|
190
|
+
},
|
|
181
191
|
};
|
|
182
192
|
export const setFontFamily = (fontFamilies) => {
|
|
183
|
-
|
|
193
|
+
if (fontFamilies.heading) {
|
|
194
|
+
currentFontFamilies.heading = {
|
|
195
|
+
...currentFontFamilies.heading,
|
|
196
|
+
...fontFamilies.heading,
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
if (fontFamilies.body) {
|
|
200
|
+
currentFontFamilies.body = {
|
|
201
|
+
...currentFontFamilies.body,
|
|
202
|
+
...fontFamilies.body,
|
|
203
|
+
};
|
|
204
|
+
}
|
|
184
205
|
// Memoize font family getter function
|
|
185
|
-
const getFontFamily = (fontWeight) => {
|
|
206
|
+
const getFontFamily = (fontWeight, userFontFamily, isHeading) => {
|
|
207
|
+
// If user explicitly set fontFamily, use it (override)
|
|
208
|
+
if (userFontFamily) {
|
|
209
|
+
return userFontFamily;
|
|
210
|
+
}
|
|
211
|
+
const fontFamilies = isHeading ? currentFontFamilies.heading : currentFontFamilies.body;
|
|
212
|
+
const { normal, thin = normal, bold = normal } = fontFamilies;
|
|
186
213
|
switch (fontWeight) {
|
|
187
214
|
case 'bold':
|
|
188
215
|
case '700':
|
|
189
|
-
return
|
|
216
|
+
return bold;
|
|
190
217
|
case '100':
|
|
191
218
|
case '200':
|
|
192
219
|
case '300':
|
|
193
|
-
return
|
|
220
|
+
return thin;
|
|
194
221
|
default:
|
|
195
|
-
return
|
|
222
|
+
return normal;
|
|
196
223
|
}
|
|
197
224
|
};
|
|
198
225
|
const applyFontFamily = (Component) => {
|
|
@@ -201,10 +228,26 @@ export const setFontFamily = (fontFamilies) => {
|
|
|
201
228
|
// @ts-ignore
|
|
202
229
|
Component.render = function (...args) {
|
|
203
230
|
const origin = oldRender.call(this, ...args);
|
|
204
|
-
|
|
231
|
+
// Check if style is an array or object
|
|
232
|
+
let flatStyle = {};
|
|
233
|
+
if (Array.isArray(origin.props.style)) {
|
|
234
|
+
// Flatten array of styles
|
|
235
|
+
origin.props.style.forEach((s) => {
|
|
236
|
+
if (s) {
|
|
237
|
+
flatStyle = { ...flatStyle, ...s };
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
else if (origin.props.style) {
|
|
242
|
+
flatStyle = origin.props.style;
|
|
243
|
+
}
|
|
244
|
+
const fontWeight = flatStyle?.fontWeight;
|
|
245
|
+
const userFontFamily = flatStyle?.fontFamily;
|
|
246
|
+
// Determine if this is a heading component (heuristic: bold fontWeight or fontSize > 18)
|
|
247
|
+
const isHeading = fontWeight === 'bold' || fontWeight === '700' || (flatStyle?.fontSize && flatStyle.fontSize > 18);
|
|
205
248
|
const updatedStyle = [
|
|
206
249
|
{
|
|
207
|
-
fontFamily: getFontFamily(fontWeight),
|
|
250
|
+
fontFamily: getFontFamily(fontWeight, userFontFamily, isHeading),
|
|
208
251
|
includeFontPadding: false,
|
|
209
252
|
},
|
|
210
253
|
origin.props.style,
|
|
@@ -218,4 +261,11 @@ export const setFontFamily = (fontFamilies) => {
|
|
|
218
261
|
applyFontFamily(TextInput);
|
|
219
262
|
};
|
|
220
263
|
// Memoize font families getter
|
|
221
|
-
export const getFontFamilies = () =>
|
|
264
|
+
export const getFontFamilies = (isHeading) => {
|
|
265
|
+
const fontFamilies = isHeading ? currentFontFamilies.heading : currentFontFamilies.body;
|
|
266
|
+
return fontFamilies || {
|
|
267
|
+
normal: 'Pretendard',
|
|
268
|
+
thin: 'Pretendard-Thin',
|
|
269
|
+
bold: 'Pretendard-Bold',
|
|
270
|
+
};
|
|
271
|
+
};
|
package/package.json
CHANGED
|
@@ -11,12 +11,19 @@ type FontFamilyOptions = {
|
|
|
11
11
|
bold?: string;
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
+
type FontFamilyConfig = {
|
|
15
|
+
heading?: FontFamilyOptions;
|
|
16
|
+
body?: FontFamilyOptions;
|
|
17
|
+
};
|
|
18
|
+
|
|
14
19
|
const createBaseText = (
|
|
15
20
|
colorResolver: (theme: CpkTheme) => string,
|
|
16
21
|
fallbackColor: string,
|
|
22
|
+
isHeading: boolean,
|
|
17
23
|
) => styled(Text)<{theme?: CpkTheme; $fontWeight?: 'normal' | 'bold' | 'thin'}>`
|
|
18
24
|
font-family: ${({$fontWeight}) => {
|
|
19
|
-
const
|
|
25
|
+
const fontFamilies = getFontFamilies(isHeading);
|
|
26
|
+
const {normal, thin = normal, bold = normal} = fontFamilies;
|
|
20
27
|
switch ($fontWeight) {
|
|
21
28
|
case 'bold':
|
|
22
29
|
return bold;
|
|
@@ -77,140 +84,147 @@ const createTextComponent = ({
|
|
|
77
84
|
);
|
|
78
85
|
}) as unknown as TextComponentType;
|
|
79
86
|
|
|
80
|
-
const
|
|
81
|
-
const
|
|
87
|
+
const StandardHeadingBaseText = createBaseText((theme) => theme.text.basic, 'gray', true);
|
|
88
|
+
const StandardBodyBaseText = createBaseText((theme) => theme.text.basic, 'gray', false);
|
|
89
|
+
const InvertedHeadingBaseText = createBaseText(
|
|
90
|
+
(theme) => theme.text.contrast,
|
|
91
|
+
light.text.contrast,
|
|
92
|
+
true,
|
|
93
|
+
);
|
|
94
|
+
const InvertedBodyBaseText = createBaseText(
|
|
82
95
|
(theme) => theme.text.contrast,
|
|
83
96
|
light.text.contrast,
|
|
97
|
+
false,
|
|
84
98
|
);
|
|
85
99
|
|
|
86
100
|
const Title = createTextComponent({
|
|
87
|
-
BaseText:
|
|
101
|
+
BaseText: StandardHeadingBaseText,
|
|
88
102
|
fontSize: 36,
|
|
89
103
|
lineHeight: 50.4,
|
|
90
104
|
fontWeight: 'bold',
|
|
91
105
|
});
|
|
92
106
|
|
|
93
107
|
const Heading1 = createTextComponent({
|
|
94
|
-
BaseText:
|
|
108
|
+
BaseText: StandardHeadingBaseText,
|
|
95
109
|
fontSize: 28,
|
|
96
110
|
lineHeight: 39.2,
|
|
97
111
|
fontWeight: 'bold',
|
|
98
112
|
});
|
|
99
113
|
|
|
100
114
|
const Heading2 = createTextComponent({
|
|
101
|
-
BaseText:
|
|
115
|
+
BaseText: StandardHeadingBaseText,
|
|
102
116
|
fontSize: 26,
|
|
103
117
|
lineHeight: 36.4,
|
|
104
118
|
fontWeight: 'bold',
|
|
105
119
|
});
|
|
106
120
|
|
|
107
121
|
const Heading3 = createTextComponent({
|
|
108
|
-
BaseText:
|
|
122
|
+
BaseText: StandardHeadingBaseText,
|
|
109
123
|
fontSize: 24,
|
|
110
124
|
lineHeight: 33.6,
|
|
111
125
|
fontWeight: 'bold',
|
|
112
126
|
});
|
|
113
127
|
|
|
114
128
|
const Heading4 = createTextComponent({
|
|
115
|
-
BaseText:
|
|
129
|
+
BaseText: StandardHeadingBaseText,
|
|
116
130
|
fontSize: 22,
|
|
117
131
|
lineHeight: 30.8,
|
|
118
132
|
fontWeight: 'bold',
|
|
119
133
|
});
|
|
120
134
|
|
|
121
135
|
const Heading5 = createTextComponent({
|
|
122
|
-
BaseText:
|
|
136
|
+
BaseText: StandardHeadingBaseText,
|
|
123
137
|
fontSize: 20,
|
|
124
138
|
lineHeight: 28,
|
|
125
139
|
fontWeight: 'bold',
|
|
126
140
|
});
|
|
127
141
|
|
|
128
142
|
const Body1 = createTextComponent({
|
|
129
|
-
BaseText:
|
|
143
|
+
BaseText: StandardBodyBaseText,
|
|
130
144
|
fontSize: 18,
|
|
131
145
|
lineHeight: 25.2,
|
|
132
146
|
});
|
|
133
147
|
|
|
134
148
|
const Body2 = createTextComponent({
|
|
135
|
-
BaseText:
|
|
149
|
+
BaseText: StandardBodyBaseText,
|
|
136
150
|
fontSize: 16,
|
|
137
151
|
lineHeight: 22.4,
|
|
138
152
|
});
|
|
139
153
|
|
|
140
154
|
const Body3 = createTextComponent({
|
|
141
|
-
BaseText:
|
|
155
|
+
BaseText: StandardBodyBaseText,
|
|
142
156
|
fontSize: 14,
|
|
143
157
|
lineHeight: 19.6,
|
|
144
158
|
});
|
|
145
159
|
|
|
146
160
|
const Body4 = createTextComponent({
|
|
147
|
-
BaseText:
|
|
161
|
+
BaseText: StandardBodyBaseText,
|
|
148
162
|
fontSize: 12,
|
|
149
163
|
lineHeight: 16.4,
|
|
150
164
|
});
|
|
151
165
|
|
|
152
166
|
const InvertedTitle = createTextComponent({
|
|
153
|
-
BaseText:
|
|
167
|
+
BaseText: InvertedHeadingBaseText,
|
|
154
168
|
fontSize: 36,
|
|
155
169
|
lineHeight: 50.4,
|
|
156
170
|
fontWeight: 'bold',
|
|
157
171
|
});
|
|
158
172
|
|
|
159
173
|
const InvertedHeading1 = createTextComponent({
|
|
160
|
-
BaseText:
|
|
174
|
+
BaseText: InvertedHeadingBaseText,
|
|
161
175
|
fontSize: 28,
|
|
162
176
|
lineHeight: 39.2,
|
|
163
177
|
fontWeight: 'bold',
|
|
164
178
|
});
|
|
165
179
|
|
|
166
180
|
const InvertedHeading2 = createTextComponent({
|
|
167
|
-
BaseText:
|
|
181
|
+
BaseText: InvertedHeadingBaseText,
|
|
168
182
|
fontSize: 26,
|
|
169
183
|
lineHeight: 36.4,
|
|
170
184
|
fontWeight: 'bold',
|
|
171
185
|
});
|
|
172
186
|
|
|
173
187
|
const InvertedHeading3 = createTextComponent({
|
|
174
|
-
BaseText:
|
|
188
|
+
BaseText: InvertedHeadingBaseText,
|
|
175
189
|
fontSize: 24,
|
|
176
190
|
lineHeight: 33.6,
|
|
177
191
|
fontWeight: 'bold',
|
|
178
192
|
});
|
|
179
193
|
|
|
180
194
|
const InvertedHeading4 = createTextComponent({
|
|
181
|
-
BaseText:
|
|
195
|
+
BaseText: InvertedHeadingBaseText,
|
|
182
196
|
fontSize: 22,
|
|
183
197
|
lineHeight: 30.8,
|
|
184
198
|
fontWeight: 'bold',
|
|
185
199
|
});
|
|
186
200
|
|
|
187
201
|
const InvertedHeading5 = createTextComponent({
|
|
188
|
-
BaseText:
|
|
202
|
+
BaseText: InvertedHeadingBaseText,
|
|
189
203
|
fontSize: 20,
|
|
190
204
|
lineHeight: 28,
|
|
191
205
|
fontWeight: 'bold',
|
|
192
206
|
});
|
|
193
207
|
|
|
194
208
|
const InvertedBody1 = createTextComponent({
|
|
195
|
-
BaseText:
|
|
209
|
+
BaseText: InvertedBodyBaseText,
|
|
196
210
|
fontSize: 18,
|
|
197
211
|
lineHeight: 25.2,
|
|
198
212
|
});
|
|
199
213
|
|
|
200
214
|
const InvertedBody2 = createTextComponent({
|
|
201
|
-
BaseText:
|
|
215
|
+
BaseText: InvertedBodyBaseText,
|
|
202
216
|
fontSize: 16,
|
|
203
217
|
lineHeight: 22.4,
|
|
204
218
|
});
|
|
205
219
|
|
|
206
220
|
const InvertedBody3 = createTextComponent({
|
|
207
|
-
BaseText:
|
|
221
|
+
BaseText: InvertedBodyBaseText,
|
|
208
222
|
fontSize: 14,
|
|
209
223
|
lineHeight: 19.6,
|
|
210
224
|
});
|
|
211
225
|
|
|
212
226
|
const InvertedBody4 = createTextComponent({
|
|
213
|
-
BaseText:
|
|
227
|
+
BaseText: InvertedBodyBaseText,
|
|
214
228
|
fontSize: 12,
|
|
215
229
|
lineHeight: 16.4,
|
|
216
230
|
});
|
|
@@ -241,31 +255,54 @@ export const TypographyInverted = {
|
|
|
241
255
|
Body4: InvertedBody4,
|
|
242
256
|
};
|
|
243
257
|
|
|
244
|
-
let currentFontFamilies = {
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
258
|
+
let currentFontFamilies: FontFamilyConfig = {
|
|
259
|
+
heading: {
|
|
260
|
+
normal: 'Pretendard',
|
|
261
|
+
thin: 'Pretendard-Thin',
|
|
262
|
+
bold: 'Pretendard-Bold',
|
|
263
|
+
},
|
|
264
|
+
body: {
|
|
265
|
+
normal: 'Pretendard',
|
|
266
|
+
thin: 'Pretendard-Thin',
|
|
267
|
+
bold: 'Pretendard-Bold',
|
|
268
|
+
},
|
|
248
269
|
};
|
|
249
270
|
|
|
250
|
-
export const setFontFamily = (fontFamilies: {
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
271
|
+
export const setFontFamily = (fontFamilies: FontFamilyConfig): void => {
|
|
272
|
+
if (fontFamilies.heading) {
|
|
273
|
+
currentFontFamilies.heading = {
|
|
274
|
+
...currentFontFamilies.heading,
|
|
275
|
+
...fontFamilies.heading,
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
if (fontFamilies.body) {
|
|
280
|
+
currentFontFamilies.body = {
|
|
281
|
+
...currentFontFamilies.body,
|
|
282
|
+
...fontFamilies.body,
|
|
283
|
+
};
|
|
284
|
+
}
|
|
256
285
|
|
|
257
286
|
// Memoize font family getter function
|
|
258
|
-
const getFontFamily = (fontWeight: string | undefined): string => {
|
|
287
|
+
const getFontFamily = (fontWeight: string | undefined, userFontFamily: string | undefined, isHeading: boolean): string => {
|
|
288
|
+
// If user explicitly set fontFamily, use it (override)
|
|
289
|
+
if (userFontFamily) {
|
|
290
|
+
return userFontFamily;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
const fontFamilies = isHeading ? currentFontFamilies.heading! : currentFontFamilies.body!;
|
|
294
|
+
const {normal, thin = normal, bold = normal} = fontFamilies;
|
|
295
|
+
|
|
259
296
|
switch (fontWeight) {
|
|
260
297
|
case 'bold':
|
|
261
298
|
case '700':
|
|
262
|
-
return
|
|
299
|
+
return bold;
|
|
263
300
|
case '100':
|
|
264
301
|
case '200':
|
|
265
302
|
case '300':
|
|
266
|
-
return
|
|
303
|
+
return thin;
|
|
267
304
|
default:
|
|
268
|
-
return
|
|
305
|
+
return normal;
|
|
269
306
|
}
|
|
270
307
|
};
|
|
271
308
|
|
|
@@ -277,11 +314,28 @@ export const setFontFamily = (fontFamilies: {
|
|
|
277
314
|
Component.render = function (...args: any) {
|
|
278
315
|
const origin = oldRender.call(this, ...args);
|
|
279
316
|
|
|
280
|
-
|
|
317
|
+
// Check if style is an array or object
|
|
318
|
+
let flatStyle: any = {};
|
|
319
|
+
if (Array.isArray(origin.props.style)) {
|
|
320
|
+
// Flatten array of styles
|
|
321
|
+
origin.props.style.forEach((s: any) => {
|
|
322
|
+
if (s) {
|
|
323
|
+
flatStyle = {...flatStyle, ...s};
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
} else if (origin.props.style) {
|
|
327
|
+
flatStyle = origin.props.style;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
const fontWeight = flatStyle?.fontWeight;
|
|
331
|
+
const userFontFamily = flatStyle?.fontFamily;
|
|
332
|
+
|
|
333
|
+
// Determine if this is a heading component (heuristic: bold fontWeight or fontSize > 18)
|
|
334
|
+
const isHeading = fontWeight === 'bold' || fontWeight === '700' || (flatStyle?.fontSize && flatStyle.fontSize > 18);
|
|
281
335
|
|
|
282
336
|
const updatedStyle = [
|
|
283
337
|
{
|
|
284
|
-
fontFamily: getFontFamily(fontWeight),
|
|
338
|
+
fontFamily: getFontFamily(fontWeight, userFontFamily, isHeading),
|
|
285
339
|
includeFontPadding: false,
|
|
286
340
|
},
|
|
287
341
|
origin.props.style,
|
|
@@ -298,4 +352,11 @@ export const setFontFamily = (fontFamilies: {
|
|
|
298
352
|
};
|
|
299
353
|
|
|
300
354
|
// Memoize font families getter
|
|
301
|
-
export const getFontFamilies = () =>
|
|
355
|
+
export const getFontFamilies = (isHeading: boolean): FontFamilyOptions => {
|
|
356
|
+
const fontFamilies = isHeading ? currentFontFamilies.heading : currentFontFamilies.body;
|
|
357
|
+
return fontFamilies || {
|
|
358
|
+
normal: 'Pretendard',
|
|
359
|
+
thin: 'Pretendard-Thin',
|
|
360
|
+
bold: 'Pretendard-Bold',
|
|
361
|
+
};
|
|
362
|
+
};
|