@remember-web/mixin 0.0.0-alpha.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.
- package/.eslintrc.js +11 -0
- package/package.json +61 -0
- package/rollup.config.mjs +105 -0
- package/src/colors/index.ts +2 -0
- package/src/colors/theme.ts +73 -0
- package/src/colors/types.ts +30 -0
- package/src/colors/utils.ts +68 -0
- package/src/colors/variables.ts +43 -0
- package/src/index.ts +3 -0
- package/src/mediaQuery/const.ts +2 -0
- package/src/mediaQuery/index.ts +50 -0
- package/src/typography/const.ts +109 -0
- package/src/typography/index.ts +66 -0
- package/src/typography/types.ts +3 -0
- package/tsconfig.alias.json +11 -0
- package/tsconfig.eslint.json +4 -0
- package/tsconfig.json +14 -0
package/.eslintrc.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@remember-web/mixin",
|
|
3
|
+
"version": "0.0.0-alpha.1",
|
|
4
|
+
"description": "RUI Mixin",
|
|
5
|
+
"homepage": "https://dramancompany.github.io/rui/",
|
|
6
|
+
"author": "Remember",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"sideEffects": false,
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/dramancompany/rui.git"
|
|
12
|
+
},
|
|
13
|
+
"publishConfig": {
|
|
14
|
+
"registry": "https://registry.npmjs.org/"
|
|
15
|
+
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "rollup -c && yarn fix:dts-alias",
|
|
18
|
+
"fix:dts-alias": "yarn tsc-alias -p tsconfig.alias.json"
|
|
19
|
+
},
|
|
20
|
+
"type": "module",
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"import": "./dist/index.js",
|
|
24
|
+
"require": "./dist/index.cjs",
|
|
25
|
+
"types": "./dist/index.d.ts"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@babel/runtime": "^7"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@babel/core": "^7.20.12",
|
|
33
|
+
"@babel/plugin-transform-runtime": "^7.19.6",
|
|
34
|
+
"@babel/preset-env": "^7.22.9",
|
|
35
|
+
"@babel/preset-typescript": "^7.22.5",
|
|
36
|
+
"@rollup/plugin-babel": "^6.0.4",
|
|
37
|
+
"@rollup/plugin-commonjs": "^25.0.7",
|
|
38
|
+
"@rollup/plugin-node-resolve": "^15.0.1",
|
|
39
|
+
"@rollup/plugin-terser": "^0.4.0",
|
|
40
|
+
"@svgr/rollup": "^6.5.1",
|
|
41
|
+
"eslint-config-rui": "workspace:*",
|
|
42
|
+
"rollup": "^4.13.0",
|
|
43
|
+
"rollup-plugin-copy": "^3.4.0",
|
|
44
|
+
"rollup-plugin-delete": "^2.0.0",
|
|
45
|
+
"rollup-plugin-dts": "^6.1.0",
|
|
46
|
+
"rollup-plugin-generate-package-json": "^3.2.0",
|
|
47
|
+
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
48
|
+
"rollup-plugin-preserve-directives": "^0.4.0",
|
|
49
|
+
"rollup-plugin-ts": "^3.4.5",
|
|
50
|
+
"rollup-plugin-typescript2": "^0.36.0",
|
|
51
|
+
"rollup-plugin-visualizer": "^5.9.0",
|
|
52
|
+
"styled-components": ">=6",
|
|
53
|
+
"tsc-alias": "^1.8.8",
|
|
54
|
+
"tsconfig": "workspace:*",
|
|
55
|
+
"typescript": "^5.4.3",
|
|
56
|
+
"@remember-web/shared": "workspace:^"
|
|
57
|
+
},
|
|
58
|
+
"peerDependencies": {
|
|
59
|
+
"styled-components": ">=6"
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { DEFAULT_EXTENSIONS } from '@babel/core';
|
|
2
|
+
import babel from '@rollup/plugin-babel';
|
|
3
|
+
import commonjs from '@rollup/plugin-commonjs';
|
|
4
|
+
import nodeResolve from '@rollup/plugin-node-resolve';
|
|
5
|
+
import fs from 'fs';
|
|
6
|
+
import path from 'path';
|
|
7
|
+
import { defineConfig } from 'rollup';
|
|
8
|
+
import ts from 'rollup-plugin-ts';
|
|
9
|
+
import peerDepsExternal from 'rollup-plugin-peer-deps-external';
|
|
10
|
+
import preserveDirectives from 'rollup-plugin-preserve-directives';
|
|
11
|
+
import typescript from 'rollup-plugin-typescript2';
|
|
12
|
+
|
|
13
|
+
const PACKAGE_DIST_DIR = './dist';
|
|
14
|
+
const SOURCE_DIR = './src';
|
|
15
|
+
|
|
16
|
+
const extensions = [...DEFAULT_EXTENSIONS, '.ts', '.tsx', '.json', '.mts'];
|
|
17
|
+
|
|
18
|
+
const defaultPlugins = [
|
|
19
|
+
peerDepsExternal({ includeDependencies: true }),
|
|
20
|
+
nodeResolve({
|
|
21
|
+
extensions,
|
|
22
|
+
}),
|
|
23
|
+
commonjs({
|
|
24
|
+
sourceMap: true,
|
|
25
|
+
}),
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
export default async () => {
|
|
29
|
+
// ./dist 폴더가 없다면 생성, 있다면 제거
|
|
30
|
+
if (fs.existsSync(PACKAGE_DIST_DIR)) {
|
|
31
|
+
fs.rmSync(PACKAGE_DIST_DIR, { recursive: true });
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return defineConfig([
|
|
35
|
+
{
|
|
36
|
+
plugins: [
|
|
37
|
+
...defaultPlugins,
|
|
38
|
+
typescript({
|
|
39
|
+
tsconfigOverride: {
|
|
40
|
+
compilerOptions: {
|
|
41
|
+
noEmit: true,
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
}),
|
|
45
|
+
babel({
|
|
46
|
+
sourceMap: true,
|
|
47
|
+
extensions,
|
|
48
|
+
// babelHelper를 번들에 포함하지 않고 런타임에서 사용하는 시점에 불러오도록 설정
|
|
49
|
+
babelHelpers: 'runtime',
|
|
50
|
+
presets: ['@babel/preset-env', '@babel/preset-typescript'],
|
|
51
|
+
plugins: ['@babel/plugin-transform-runtime'],
|
|
52
|
+
}),
|
|
53
|
+
preserveDirectives(),
|
|
54
|
+
],
|
|
55
|
+
input: path.join(SOURCE_DIR, 'index.ts'),
|
|
56
|
+
output: getOutputOption('cjs'),
|
|
57
|
+
external: [/@babel\/runtime/],
|
|
58
|
+
onwarn(warning, warn) {
|
|
59
|
+
if (warning.code !== 'MODULE_LEVEL_DIRECTIVE') {
|
|
60
|
+
warn(warning);
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
plugins: [
|
|
66
|
+
defaultPlugins,
|
|
67
|
+
ts({
|
|
68
|
+
transpiler: 'typescript',
|
|
69
|
+
browserslist: false,
|
|
70
|
+
tsconfig: (tsconfig) => ({
|
|
71
|
+
...tsconfig,
|
|
72
|
+
declaration: true,
|
|
73
|
+
emitDeclarationOnly: true,
|
|
74
|
+
declarationDir: './dist',
|
|
75
|
+
sourceMap: true,
|
|
76
|
+
declarationMap: true,
|
|
77
|
+
}),
|
|
78
|
+
}),
|
|
79
|
+
preserveDirectives(),
|
|
80
|
+
],
|
|
81
|
+
input: path.join(SOURCE_DIR, 'index.ts'),
|
|
82
|
+
output: getOutputOption('esm'),
|
|
83
|
+
onwarn(warning, warn) {
|
|
84
|
+
if (warning.code !== 'MODULE_LEVEL_DIRECTIVE') {
|
|
85
|
+
warn(warning);
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
]);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
/** @type {(type: 'esm' | 'cjs') => import('rollup').OutputOptions} */
|
|
93
|
+
function getOutputOption(format) {
|
|
94
|
+
const extension = { esm: 'js', cjs: 'cjs' }[format];
|
|
95
|
+
return {
|
|
96
|
+
dir: PACKAGE_DIST_DIR,
|
|
97
|
+
sourcemap: true,
|
|
98
|
+
format,
|
|
99
|
+
entryFileNames: `[name].${extension}`,
|
|
100
|
+
chunkFileNames: `chunks/[hash]/[name].${extension}`,
|
|
101
|
+
interop: 'auto',
|
|
102
|
+
preserveModules: true,
|
|
103
|
+
preserveModulesRoot: SOURCE_DIR,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { RUIColorThemeType } from './types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* {@link https://www.figma.com/file/2qQ5eJPRTiAKyz6Q1IzfMJ/WEB?node-id=2570%3A12136&viewport=347%2C475%2C0.47}
|
|
5
|
+
*/
|
|
6
|
+
export const RUI_COLOR_THEME: RUIColorThemeType = {
|
|
7
|
+
light: {
|
|
8
|
+
'--rui-primary100': '#000000',
|
|
9
|
+
'--rui-primary200': '#FFFFFF',
|
|
10
|
+
'--rui-secondary100': '#FF6A0D',
|
|
11
|
+
'--rui-contents000': '#000000',
|
|
12
|
+
'--rui-contents100': '#424242',
|
|
13
|
+
'--rui-contents150': '#808080',
|
|
14
|
+
'--rui-contents200': '#BDBDBD',
|
|
15
|
+
'--rui-contents300': '#D4D4D4',
|
|
16
|
+
'--rui-contents999': '#FFFFFF',
|
|
17
|
+
'--rui-disabled': '#D4D4D4',
|
|
18
|
+
'--rui-disabled-role-red': '#F7ABAB',
|
|
19
|
+
'--rui-disabled-secondary': '#FFE3D1',
|
|
20
|
+
'--rui-role-red': '#ED4E4E',
|
|
21
|
+
'--rui-role-yellow': '#EDC84E',
|
|
22
|
+
'--rui-role-blue': '#2679ED',
|
|
23
|
+
'--rui-role-green': '#21C798',
|
|
24
|
+
'--rui-bg100': '#FFFFFF',
|
|
25
|
+
'--rui-bg200': '#FAFAFA',
|
|
26
|
+
'--rui-bg300': '#F2F2F2',
|
|
27
|
+
'--rui-bg-modal100': '#FFFFFF',
|
|
28
|
+
'--rui-bg-modal200': '#FAFAFA',
|
|
29
|
+
'--rui-bg-role-red': '#FFF5F5',
|
|
30
|
+
'--rui-bg-secondary100': '#FFF4ED',
|
|
31
|
+
'--rui-bg-highlight': '#FCF5DC',
|
|
32
|
+
'--rui-bg-role-yellow': '#FFFDF5',
|
|
33
|
+
'--rui-bg-role-blue': '#EDF4FF',
|
|
34
|
+
'--rui-bg-role-green': '#D9FCF2',
|
|
35
|
+
'--rui-divider': '#D4D4D4',
|
|
36
|
+
'--rui-fixed-white': '#FFFFFF',
|
|
37
|
+
'--rui-fixed-black': '#000000',
|
|
38
|
+
'--rui-fixed-bg-white': '#FFFFFF',
|
|
39
|
+
},
|
|
40
|
+
dark: {
|
|
41
|
+
'--rui-primary100': '#FFFFFF',
|
|
42
|
+
'--rui-primary200': '#000000',
|
|
43
|
+
'--rui-secondary100': '#FF6A0D',
|
|
44
|
+
'--rui-contents000': '#FFFFFF',
|
|
45
|
+
'--rui-contents100': '#EBEBEB',
|
|
46
|
+
'--rui-contents150': '#D4D4D4',
|
|
47
|
+
'--rui-contents200': '#BDBDBD',
|
|
48
|
+
'--rui-contents300': '#808080',
|
|
49
|
+
'--rui-contents999': '#000000',
|
|
50
|
+
'--rui-disabled': '#808080',
|
|
51
|
+
'--rui-disabled-role-red': '#6B2424',
|
|
52
|
+
'--rui-disabled-secondary': '#4D2A14',
|
|
53
|
+
'--rui-role-red': '#D13636',
|
|
54
|
+
'--rui-role-yellow': '#D1AD36',
|
|
55
|
+
'--rui-role-blue': '#085DD4',
|
|
56
|
+
'--rui-role-green': '#22B28A',
|
|
57
|
+
'--rui-bg100': '#1A1A1A',
|
|
58
|
+
'--rui-bg200': '#000000',
|
|
59
|
+
'--rui-bg300': '#000000',
|
|
60
|
+
'--rui-bg-modal100': '#2E2E2E',
|
|
61
|
+
'--rui-bg-modal200': '#424242',
|
|
62
|
+
'--rui-bg-role-red': '#381515',
|
|
63
|
+
'--rui-bg-secondary100': '#331D0F',
|
|
64
|
+
'--rui-bg-highlight': '#383015',
|
|
65
|
+
'--rui-bg-role-yellow': '#383015',
|
|
66
|
+
'--rui-bg-role-blue': '#002861',
|
|
67
|
+
'--rui-bg-role-green': '#15382E',
|
|
68
|
+
'--rui-divider': '#424242',
|
|
69
|
+
'--rui-fixed-white': '#FFFFFF',
|
|
70
|
+
'--rui-fixed-black': '#000000',
|
|
71
|
+
'--rui-fixed-bg-white': '#FFFFFF',
|
|
72
|
+
},
|
|
73
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export type GetVariableName<C> = C extends `var(${infer R})` ? R : never;
|
|
2
|
+
|
|
3
|
+
export type ThemeType = 'light' | 'dark';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Variable = CSS변수로 사용되는 명칭
|
|
7
|
+
* VariableName = CSS변수로 사용되는 명칭에서 `var()`를 제거한 실제명칭
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export type ColorVariable<V extends string = string> = `var(--rui-${V})`;
|
|
11
|
+
export type ColorVariableName<V extends string = string> = GetVariableName<
|
|
12
|
+
ColorVariable<V>
|
|
13
|
+
>;
|
|
14
|
+
export type ColorSet = Record<ColorVariableName, string>;
|
|
15
|
+
|
|
16
|
+
export type RUIColorType = typeof import('./variables');
|
|
17
|
+
export type RUIColorName = keyof RUIColorType;
|
|
18
|
+
|
|
19
|
+
export type RUIColorVariable = RUIColorType[RUIColorName];
|
|
20
|
+
export type RUIColorVariableName = GetVariableName<RUIColorVariable>;
|
|
21
|
+
export type RUIColorSet = Record<RUIColorVariableName, string>;
|
|
22
|
+
|
|
23
|
+
export type ColorThemeType = {
|
|
24
|
+
[key in ThemeType]: ColorSet;
|
|
25
|
+
};
|
|
26
|
+
export type RUIColorThemeType = {
|
|
27
|
+
[key in ThemeType]: RUIColorSet;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { isSSR } from '@remember-web/shared/utils/common';
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
ColorVariable,
|
|
5
|
+
ColorVariableName,
|
|
6
|
+
RUIColorVariable,
|
|
7
|
+
ThemeType,
|
|
8
|
+
} from './types';
|
|
9
|
+
import { RUI_COLOR_THEME } from './theme';
|
|
10
|
+
|
|
11
|
+
/** var(color)로 된 string을 color로 변경해줄 때 사용 */
|
|
12
|
+
export function getColorVariableName<V extends string = string>(
|
|
13
|
+
color: ColorVariable<V>
|
|
14
|
+
) {
|
|
15
|
+
return color.slice(4, -1) as ColorVariableName<V>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** RDS컬러의 rgb값이 필요할 때 사용ValidityState
|
|
19
|
+
* @example css`color: rgba(${getRgb(contents000)},0.5)`
|
|
20
|
+
*/
|
|
21
|
+
export function getRgb(color: ColorVariable) {
|
|
22
|
+
return `var(${getColorVariableName(color)}__rgb)`;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** RDS컬러를 통해서 css의 rgba함수를 사용
|
|
26
|
+
* @example css`color: ${getRgb(contents000, 0.5)}`
|
|
27
|
+
* @example css`box-shadow: 0 0 0 5px ${getRgb(contents000, 0.5)}`
|
|
28
|
+
*/
|
|
29
|
+
export function getRgba(color: ColorVariable, opacity: number | `${number}%`) {
|
|
30
|
+
return `rgba(${getRgb(color)},${opacity})`;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** hex로 된 컬러값을 rgb값으로 변경해줌 */
|
|
34
|
+
export function hexToRgb(colorHex: string) {
|
|
35
|
+
let hexWithoutHash = colorHex.replace('#', '');
|
|
36
|
+
|
|
37
|
+
if (hexWithoutHash.length !== 3 && hexWithoutHash.length !== 6) {
|
|
38
|
+
throw new Error('Invalid hex color');
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (hexWithoutHash.length === 3) {
|
|
42
|
+
hexWithoutHash = [...hexWithoutHash].map((hex) => hex.repeat(2)).join();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const [, r, g, b] = hexWithoutHash
|
|
46
|
+
.split(/(..)(..)(..)/)
|
|
47
|
+
.map((hex) => parseInt(hex, 16));
|
|
48
|
+
|
|
49
|
+
return `${r},${g},${b}`;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function getBrowserTheme(): ThemeType {
|
|
53
|
+
if (!isSSR() && window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
|
54
|
+
return 'dark';
|
|
55
|
+
}
|
|
56
|
+
return 'light';
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** css variable을 hex로 반환 */
|
|
60
|
+
export function getHexFromRuiCssVariable({
|
|
61
|
+
colorVariable,
|
|
62
|
+
theme,
|
|
63
|
+
}: {
|
|
64
|
+
theme: ThemeType;
|
|
65
|
+
colorVariable: RUIColorVariable;
|
|
66
|
+
}) {
|
|
67
|
+
return RUI_COLOR_THEME[theme][getColorVariableName(colorVariable)];
|
|
68
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export const primary100 = 'var(--rui-primary100)';
|
|
2
|
+
export const primary200 = 'var(--rui-primary200)';
|
|
3
|
+
export const secondary100 = 'var(--rui-secondary100)';
|
|
4
|
+
|
|
5
|
+
// Contents txt/ label/ border/ divider
|
|
6
|
+
export const contents000 = 'var(--rui-contents000)';
|
|
7
|
+
export const contents100 = 'var(--rui-contents100)';
|
|
8
|
+
export const contents150 = 'var(--rui-contents150)';
|
|
9
|
+
export const contents200 = 'var(--rui-contents200)';
|
|
10
|
+
export const contents300 = 'var(--rui-contents300)';
|
|
11
|
+
export const contents999 = 'var(--rui-contents999)';
|
|
12
|
+
|
|
13
|
+
// Disable disabled CTA
|
|
14
|
+
export const disabled = 'var(--rui-disabled)';
|
|
15
|
+
export const disabledRoleRed = 'var(--rui-disabled-role-red)';
|
|
16
|
+
export const disabledSecondary = 'var(--rui-disabled-secondary)';
|
|
17
|
+
|
|
18
|
+
// Accent Error/ Link/
|
|
19
|
+
export const roleRed = 'var(--rui-role-red)';
|
|
20
|
+
export const roleYellow = 'var(--rui-role-yellow)';
|
|
21
|
+
export const roleBlue = 'var(--rui-role-blue)';
|
|
22
|
+
export const roleGreen = 'var(--rui-role-green)';
|
|
23
|
+
|
|
24
|
+
// Background
|
|
25
|
+
export const bg100 = 'var(--rui-bg100)';
|
|
26
|
+
export const bg200 = 'var(--rui-bg200)';
|
|
27
|
+
export const bg300 = 'var(--rui-bg300)';
|
|
28
|
+
export const bgModal100 = 'var(--rui-bg-modal100)';
|
|
29
|
+
export const bgModal200 = 'var(--rui-bg-modal200)';
|
|
30
|
+
export const bgRoleRed = 'var(--rui-bg-role-red)';
|
|
31
|
+
export const bgSecondary100 = 'var(--rui-bg-secondary100)';
|
|
32
|
+
export const bgHighlight = 'var(--rui-bg-highlight)';
|
|
33
|
+
export const bgRoleYellow = 'var(--rui-bg-role-yellow)';
|
|
34
|
+
export const bgRoleBlue = 'var(--rui-bg-role-blue)';
|
|
35
|
+
export const bgRoleGreen = 'var(--rui-bg-role-green)';
|
|
36
|
+
|
|
37
|
+
// Divider
|
|
38
|
+
export const divider = 'var(--rui-divider)';
|
|
39
|
+
|
|
40
|
+
// Fixed
|
|
41
|
+
export const fixedWhite = 'var(--rui-fixed-white)';
|
|
42
|
+
export const fixedBgWhite = 'var(--rui-fixed-bg-white)';
|
|
43
|
+
export const fixedBlack = 'var(--rui-fixed-black)';
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { css } from 'styled-components';
|
|
4
|
+
import type { CSSProp } from 'styled-components';
|
|
5
|
+
|
|
6
|
+
import { DESKTOP_WIDTH, PHONE_WIDTH } from './const';
|
|
7
|
+
|
|
8
|
+
export * from './const';
|
|
9
|
+
|
|
10
|
+
export function getDeviceWidthMediaQuery({
|
|
11
|
+
maxWidth,
|
|
12
|
+
minWidth,
|
|
13
|
+
}: {
|
|
14
|
+
maxWidth?: number | string;
|
|
15
|
+
minWidth?: number | string;
|
|
16
|
+
}) {
|
|
17
|
+
const mediaQueries: string[] = [];
|
|
18
|
+
|
|
19
|
+
if (maxWidth) {
|
|
20
|
+
mediaQueries.push(
|
|
21
|
+
`(max-width: ${
|
|
22
|
+
typeof maxWidth === 'string' ? maxWidth : `${maxWidth}px`
|
|
23
|
+
})`
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (minWidth) {
|
|
28
|
+
mediaQueries.push(
|
|
29
|
+
`(min-width: ${
|
|
30
|
+
typeof minWidth === 'string' ? minWidth : `${minWidth}px`
|
|
31
|
+
})`
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return (cssInterpolation: CSSProp) => css`
|
|
36
|
+
@media ${mediaQueries.join(' and ')} {
|
|
37
|
+
${cssInterpolation}
|
|
38
|
+
}
|
|
39
|
+
`;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export const mobileOnly = getDeviceWidthMediaQuery({
|
|
43
|
+
maxWidth: DESKTOP_WIDTH - 1,
|
|
44
|
+
});
|
|
45
|
+
export const desktopOnly = getDeviceWidthMediaQuery({
|
|
46
|
+
minWidth: DESKTOP_WIDTH,
|
|
47
|
+
});
|
|
48
|
+
export const phoneOnly = getDeviceWidthMediaQuery({
|
|
49
|
+
maxWidth: PHONE_WIDTH,
|
|
50
|
+
});
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2
|
+
|
|
3
|
+
const LEGACY_TYPOGRAPHY_STYLES = {
|
|
4
|
+
Headline2_B: {
|
|
5
|
+
fontSize: 24,
|
|
6
|
+
lineHeight: 34,
|
|
7
|
+
fontWeight: 600,
|
|
8
|
+
},
|
|
9
|
+
Headline3_B: {
|
|
10
|
+
fontSize: 20,
|
|
11
|
+
lineHeight: 26,
|
|
12
|
+
fontWeight: 600,
|
|
13
|
+
},
|
|
14
|
+
Headline4_B: {
|
|
15
|
+
fontSize: 16,
|
|
16
|
+
lineHeight: 26,
|
|
17
|
+
fontWeight: 600,
|
|
18
|
+
},
|
|
19
|
+
Headline4_M: {
|
|
20
|
+
fontSize: 16,
|
|
21
|
+
lineHeight: 26,
|
|
22
|
+
fontWeight: 400,
|
|
23
|
+
},
|
|
24
|
+
Body1_B: {
|
|
25
|
+
fontSize: 14,
|
|
26
|
+
lineHeight: 24,
|
|
27
|
+
fontWeight: 600,
|
|
28
|
+
},
|
|
29
|
+
Body1_M: {
|
|
30
|
+
fontSize: 14,
|
|
31
|
+
lineHeight: 24,
|
|
32
|
+
fontWeight: 400,
|
|
33
|
+
},
|
|
34
|
+
Body2_B: {
|
|
35
|
+
fontSize: 12,
|
|
36
|
+
lineHeight: 19,
|
|
37
|
+
fontWeight: 600,
|
|
38
|
+
},
|
|
39
|
+
Body2_M: {
|
|
40
|
+
fontSize: 12,
|
|
41
|
+
lineHeight: 19,
|
|
42
|
+
fontWeight: 400,
|
|
43
|
+
},
|
|
44
|
+
Caption_B: {
|
|
45
|
+
fontSize: 10,
|
|
46
|
+
lineHeight: 14,
|
|
47
|
+
fontWeight: 600,
|
|
48
|
+
},
|
|
49
|
+
} as const;
|
|
50
|
+
|
|
51
|
+
export const TYPOGRAPHY_STYLES = {
|
|
52
|
+
...LEGACY_TYPOGRAPHY_STYLES,
|
|
53
|
+
Headline: {
|
|
54
|
+
fontSize: 24,
|
|
55
|
+
lineHeight: 34,
|
|
56
|
+
fontWeight: 600,
|
|
57
|
+
},
|
|
58
|
+
Title1: {
|
|
59
|
+
fontSize: 20,
|
|
60
|
+
lineHeight: 26,
|
|
61
|
+
fontWeight: 600,
|
|
62
|
+
},
|
|
63
|
+
Display: {
|
|
64
|
+
fontSize: 20,
|
|
65
|
+
lineHeight: 26,
|
|
66
|
+
fontWeight: 400,
|
|
67
|
+
},
|
|
68
|
+
Title2: {
|
|
69
|
+
fontSize: 16,
|
|
70
|
+
lineHeight: 26,
|
|
71
|
+
fontWeight: 600,
|
|
72
|
+
},
|
|
73
|
+
ArticleBody: {
|
|
74
|
+
fontSize: 16,
|
|
75
|
+
lineHeight: 26,
|
|
76
|
+
fontWeight: 400,
|
|
77
|
+
},
|
|
78
|
+
Subtitle1: {
|
|
79
|
+
fontSize: 14,
|
|
80
|
+
lineHeight: 24,
|
|
81
|
+
fontWeight: 600,
|
|
82
|
+
},
|
|
83
|
+
Body1: {
|
|
84
|
+
fontSize: 14,
|
|
85
|
+
lineHeight: 24,
|
|
86
|
+
fontWeight: 400,
|
|
87
|
+
},
|
|
88
|
+
Subtitle2: {
|
|
89
|
+
fontSize: 12,
|
|
90
|
+
lineHeight: 19,
|
|
91
|
+
fontWeight: 600,
|
|
92
|
+
},
|
|
93
|
+
Body2: {
|
|
94
|
+
fontSize: 12,
|
|
95
|
+
lineHeight: 19,
|
|
96
|
+
fontWeight: 400,
|
|
97
|
+
},
|
|
98
|
+
Caption: {
|
|
99
|
+
fontSize: 10,
|
|
100
|
+
lineHeight: 14,
|
|
101
|
+
fontWeight: 600,
|
|
102
|
+
},
|
|
103
|
+
} as const;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* {@link https://github.com/orioncactus/pretendard#html-1}
|
|
107
|
+
*/
|
|
108
|
+
export const PRETENDARD_FONT_FAMILY =
|
|
109
|
+
"Pretendard, -apple-system, BlinkMacSystemFont, system-ui, Roboto, 'Helvetica Neue', 'Segoe UI', 'Apple SD Gothic Neo', 'Noto Sans KR', 'Malgun Gothic', 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', sans-serif";
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { css } from 'styled-components';
|
|
4
|
+
|
|
5
|
+
import { PRETENDARD_FONT_FAMILY, TYPOGRAPHY_STYLES } from './const';
|
|
6
|
+
import type { TypographyStyle } from './types';
|
|
7
|
+
|
|
8
|
+
export * from './const';
|
|
9
|
+
export * from './types';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* 해당 스타일명에 해당하는 css 조각을 반환
|
|
13
|
+
* @see TYPOGRAPHY_STYLES
|
|
14
|
+
*/
|
|
15
|
+
export const getTypographyStyles = (typographyStyle: TypographyStyle) => {
|
|
16
|
+
const { fontSize, lineHeight, fontWeight } =
|
|
17
|
+
TYPOGRAPHY_STYLES[typographyStyle];
|
|
18
|
+
return css`
|
|
19
|
+
font-family: ${PRETENDARD_FONT_FAMILY};
|
|
20
|
+
font-size: ${fontSize}px;
|
|
21
|
+
line-height: ${lineHeight}px;
|
|
22
|
+
font-weight: ${fontWeight};
|
|
23
|
+
`;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 말줄임표 표시 (1줄)
|
|
28
|
+
*
|
|
29
|
+
* white-space: nowrap; \
|
|
30
|
+
* overflow: hidden; \
|
|
31
|
+
* text-overflow: ellipsis;
|
|
32
|
+
*/
|
|
33
|
+
export const textEllipsis = css`
|
|
34
|
+
white-space: nowrap;
|
|
35
|
+
overflow: hidden;
|
|
36
|
+
text-overflow: ellipsis;
|
|
37
|
+
`;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* 말줄임표 표시
|
|
41
|
+
*
|
|
42
|
+
* line = 1 인 경우, \
|
|
43
|
+
* white-space: nowrap; \
|
|
44
|
+
* overflow: hidden; \
|
|
45
|
+
* text-overflow: ellipsis;
|
|
46
|
+
*
|
|
47
|
+
* line > 1 인 경우, \
|
|
48
|
+
* overflow: hidden; \
|
|
49
|
+
* text-overflow: ellipsis; \
|
|
50
|
+
* display: -webkit-box; \
|
|
51
|
+
* -webkit-box-orient: vertical; \
|
|
52
|
+
* -webkit-line-clamp: ${line};
|
|
53
|
+
*/
|
|
54
|
+
export const ellipsis = (line = 1) => {
|
|
55
|
+
if (line === 1) {
|
|
56
|
+
return textEllipsis;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return css`
|
|
60
|
+
overflow: hidden;
|
|
61
|
+
text-overflow: ellipsis;
|
|
62
|
+
display: -webkit-box;
|
|
63
|
+
-webkit-box-orient: vertical;
|
|
64
|
+
-webkit-line-clamp: ${line};
|
|
65
|
+
`;
|
|
66
|
+
};
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "tsconfig/base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"lib": ["DOM", "DOM.Iterable"],
|
|
5
|
+
"jsx": "react-jsx",
|
|
6
|
+
"moduleResolution": "Bundler",
|
|
7
|
+
"baseUrl": ".",
|
|
8
|
+
"paths": {
|
|
9
|
+
"@/*": ["./src/*"]
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"include": ["./src/**/*"],
|
|
13
|
+
"exclude": ["node_modules", "rollup.config.mjs"]
|
|
14
|
+
}
|