@liner-fe/design-token 2.3.0 → 2.3.2
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.
- package/README.md +9 -1
- package/global.css +4 -0
- package/lib/generated/vars.d.ts +100 -98
- package/lib/index.cjs +1 -1
- package/lib/index.cjs.map +2 -2
- package/lib/index.mjs +1 -1
- package/lib/index.mjs.map +2 -2
- package/lib/scripts/create-css/constants/typography/index.d.ts +1 -1
- package/lib/types/color.d.ts +1 -1
- package/package.json +1 -1
- package/src/fonts/Merriweather-Black.ttf +0 -0
- package/src/fonts/Merriweather-Bold.ttf +0 -0
- package/src/fonts/Merriweather-Light.ttf +0 -0
- package/src/fonts/Merriweather-Regular.ttf +0 -0
- package/src/fonts/PretendardJPVariable.woff2 +0 -0
- package/src/fonts/PretendardVariable.woff2 +0 -0
- package/src/generated/vars.ts +1 -1
- package/src/scripts/create-css/constants/color/index.ts +29 -11
- package/src/scripts/create-css/constants/font/font.css +54 -0
- package/src/scripts/create-css/constants/index.ts +9 -0
- package/src/scripts/create-css/constants/opacity/index.ts +0 -1
- package/src/scripts/create-css/constants/typography/index.ts +0 -1
- package/src/scripts/create-css/index.ts +10 -18
- package/src/scripts/create-css/utils/convertFontFamily.ts +1 -3
- package/src/scripts/create-css/utils/fileToString.ts +9 -0
- package/src/scripts/create-css/utils/generateTokenMap.ts +14 -0
- package/src/scripts/create-css/utils/removeTokenPrefix.ts +16 -0
- package/src/types/color.ts +2 -0
|
@@ -7,24 +7,22 @@ import {
|
|
|
7
7
|
themeLight,
|
|
8
8
|
themeLightStorybook,
|
|
9
9
|
} from './constants/rootScheme';
|
|
10
|
-
import { radius } from './constants/radius';
|
|
11
|
-
import { iconSize } from './constants/icon';
|
|
12
|
-
import { opacity } from './constants/opacity';
|
|
13
|
-
import { padding } from './constants/padding';
|
|
14
|
-
import { size } from './constants/size';
|
|
15
|
-
import { gap } from './constants/gap';
|
|
16
10
|
import { PATH } from './constants/PATH';
|
|
17
11
|
import { makeDir } from './utils/makeDir';
|
|
18
12
|
import { replaceValuesWithKeys } from './utils/replaceValuesWithKeys';
|
|
19
|
-
import { shadow } from './constants/shadow';
|
|
20
|
-
import { typographyClassName } from './constants/typography';
|
|
21
13
|
import { createFile } from './utils/createFile';
|
|
14
|
+
import { generateTokenMap } from './utils/generateTokenMap';
|
|
15
|
+
import { gap, iconSize, opacity, padding, radius, shadow, size, typographyClassName } from './constants';
|
|
22
16
|
|
|
23
|
-
const
|
|
24
|
-
const cssFileStorybook = [primitiveRoot, themeDarkStorybook, themeLightStorybook, languageEnglish].join('\n');
|
|
17
|
+
const tokens = [{ radius }, { opacity }, { padding }, { size }, { gap }, { shadow }, { iconSize }];
|
|
25
18
|
|
|
26
|
-
const start = () => {
|
|
19
|
+
const start = async () => {
|
|
27
20
|
try {
|
|
21
|
+
// TODO: 폰트 파일을 번들링하는 번들러 로더 설정이 필요해 작업 후 반영 예정
|
|
22
|
+
// const fontCss = await fileToString('../constants/font/font.css');
|
|
23
|
+
const cssFile = [primitiveRoot, themeDark, themeLight, languageEnglish].join('\n');
|
|
24
|
+
const cssFileStorybook = [primitiveRoot, themeDarkStorybook, themeLightStorybook, languageEnglish].join('\n');
|
|
25
|
+
|
|
28
26
|
createFile('./global.css', cssFile);
|
|
29
27
|
createFile('./globalStorybook.css', cssFileStorybook);
|
|
30
28
|
|
|
@@ -34,13 +32,7 @@ const start = () => {
|
|
|
34
32
|
`${PATH.SRC_GENERATED}/vars.ts`,
|
|
35
33
|
`export const vars = ${JSON.stringify({
|
|
36
34
|
...replaceValuesWithKeys({ color: color.system.light }),
|
|
37
|
-
...
|
|
38
|
-
...replaceValuesWithKeys({ opacity }),
|
|
39
|
-
...replaceValuesWithKeys({ padding }),
|
|
40
|
-
...replaceValuesWithKeys({ size }),
|
|
41
|
-
...replaceValuesWithKeys({ gap }),
|
|
42
|
-
...replaceValuesWithKeys({ shadow }),
|
|
43
|
-
...replaceValuesWithKeys({ iconSize }),
|
|
35
|
+
...generateTokenMap(tokens),
|
|
44
36
|
})}`
|
|
45
37
|
);
|
|
46
38
|
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { FontFamily } from '../constants/typography';
|
|
2
2
|
|
|
3
3
|
export const convertFontFamily = (value: FontFamily) => {
|
|
4
|
-
if (value === 'lp-pri-font-family-
|
|
5
|
-
return '"Poppins", sans-serif';
|
|
6
|
-
} else if (value === 'lp-pri-font-family-variables-pretendard-jp') {
|
|
4
|
+
if (value === 'lp-pri-font-family-variables-pretendard-jp') {
|
|
7
5
|
return '"Pretendard JP Variable"';
|
|
8
6
|
} else if (value === 'lp-pri-font-family-merriweather') {
|
|
9
7
|
return '"Merriweather", serif';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { removeObjectPrefix } from './removeTokenPrefix';
|
|
2
|
+
import { replaceValuesWithKeys } from './replaceValuesWithKeys';
|
|
3
|
+
|
|
4
|
+
const tokenPrefixes = ['lp-sys-', 'lp-pri-'];
|
|
5
|
+
const tokenTypes = ['radius-', 'opacity-', 'padding-', 'size-', 'gap-', 'shadow-', 'icon-size-'];
|
|
6
|
+
const prefixCandidates = tokenPrefixes.map(prefix => tokenTypes.map(type => `${prefix}${type}`)).flat();
|
|
7
|
+
|
|
8
|
+
export const generateTokenMap = (tokens: Record<string, any>[]) => {
|
|
9
|
+
const tokenMaps = tokens.map(tokenMap => replaceValuesWithKeys(tokenMap));
|
|
10
|
+
const prefixRefinedTokenMaps = tokenMaps.map(token => removeObjectPrefix(token, prefixCandidates));
|
|
11
|
+
const tokenMap = prefixRefinedTokenMaps.reduce((acc, cur) => ({ ...acc, ...cur }), {});
|
|
12
|
+
|
|
13
|
+
return tokenMap;
|
|
14
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const removeObjectPrefix = <T extends Record<string, any>>(target: T, prefixes: string[]) => {
|
|
2
|
+
const result: Record<string, any> = {};
|
|
3
|
+
|
|
4
|
+
for (const key in target) {
|
|
5
|
+
const value = target[key];
|
|
6
|
+
|
|
7
|
+
if (typeof value === 'object' && value !== null && !Array.isArray(value)) {
|
|
8
|
+
result[key] = removeObjectPrefix(value, prefixes);
|
|
9
|
+
} else {
|
|
10
|
+
const prefix = prefixes.find(p => key.startsWith(p)) as string;
|
|
11
|
+
result[key.replace(prefix, '')] = target[key];
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return result;
|
|
16
|
+
};
|
package/src/types/color.ts
CHANGED
|
@@ -71,6 +71,8 @@ export type SystemKeys =
|
|
|
71
71
|
| 'function-container-negative'
|
|
72
72
|
| 'function-container-negative-hover'
|
|
73
73
|
| 'function-container-caution'
|
|
74
|
+
| 'function-container-highlight'
|
|
75
|
+
| 'function-container-selection'
|
|
74
76
|
| 'function-label-positive'
|
|
75
77
|
| 'function-label-negative'
|
|
76
78
|
| 'function-label-caution'
|