@nuskin/foundation-ui-components 1.15.0 → 1.16.0-cx130-990.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuskin/foundation-ui-components",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.16.0-cx130-990.1",
|
|
4
4
|
"description": "It is a foundation library written in react, that provides common components to all UI pages",
|
|
5
5
|
"main": "src/common/index.ts",
|
|
6
6
|
"repository": {
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"@mui/material": "5.14.16",
|
|
47
47
|
"@mui/utils": "^5.14.16",
|
|
48
48
|
"@next/font": "13.5.6",
|
|
49
|
-
"@nuskin/foundation-theme": "1.
|
|
49
|
+
"@nuskin/foundation-theme": "1.3.0-cx130-596.3",
|
|
50
50
|
"@types/react": "^18.2.34",
|
|
51
51
|
"@types/react-dom": "^18.2.14",
|
|
52
52
|
"cliui": "^8.0.1",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable max-len */
|
|
2
|
-
import { styled,
|
|
2
|
+
import { styled, ColorUtils, FoundationTheme } from '@nuskin/foundation-theme';
|
|
3
3
|
|
|
4
4
|
const { color } = ColorUtils;
|
|
5
5
|
|
|
@@ -43,12 +43,6 @@ export const AlertContainer = styled.div<AlertContainerParams>`
|
|
|
43
43
|
}
|
|
44
44
|
text-align: left;
|
|
45
45
|
`;
|
|
46
|
-
//[Todo-Arun] - Fonts should be driven through @next/font and according to theme
|
|
47
|
-
const fontFamilyStyles = css`
|
|
48
|
-
font-family: 'proxima-nova', 'OpenSans', 'Pridi', 'NotoSans', 'NotoSansSC', 'NotoSansHebrew', 'NotoSansJapanese',
|
|
49
|
-
'Hiragino Kaku Gothic Pro', 'Yu Gothic Medium', 'Yu Gothic', Meiryo, 'source-han-sans-japanese',
|
|
50
|
-
'source-han-sans-korean', 'source-han-sans-simplified-c', Helvetica, Arial, sans-serif;
|
|
51
|
-
`;
|
|
52
46
|
|
|
53
47
|
export const Alert = styled.div<AlertParams>`
|
|
54
48
|
position: relative;
|
|
@@ -90,12 +84,8 @@ export const AlertHead = styled.div`
|
|
|
90
84
|
display: flex;
|
|
91
85
|
flex-direction: column;
|
|
92
86
|
justify-content: center;
|
|
93
|
-
|
|
94
|
-
${fontFamilyStyles}
|
|
87
|
+
.alert-head-title {
|
|
95
88
|
color: ${color('primary', 'black')};
|
|
96
|
-
font-weight: 600;
|
|
97
|
-
font-size: 18px;
|
|
98
|
-
line-height: 20px;
|
|
99
89
|
}
|
|
100
90
|
`;
|
|
101
91
|
|
|
@@ -110,14 +100,14 @@ export const AlertFoot = styled.div<{ type: AlertType }>`
|
|
|
110
100
|
margin-top: 8px;
|
|
111
101
|
color: ${color('primary', 'black')};
|
|
112
102
|
display: ${({ type }) => TypeMap?.[type]?.['footDisplay']};
|
|
113
|
-
${
|
|
103
|
+
font-family: ${({ theme }) => theme?.fonts?.sectionFonts?.body};
|
|
114
104
|
font-weight: 300;
|
|
115
105
|
font-size: 14px;
|
|
116
106
|
line-height: 18px;
|
|
117
107
|
`;
|
|
118
108
|
|
|
119
109
|
export const AlertBody = styled.div`
|
|
120
|
-
${
|
|
110
|
+
font-family: ${({ theme }) => theme?.fonts?.sectionFonts?.body};
|
|
121
111
|
font-weight: 300;
|
|
122
112
|
font-size: 16px;
|
|
123
113
|
line-height: 21px;
|
|
@@ -15,6 +15,7 @@ import type { NsAlertProps, ContextType, AlertType } from './types.d';
|
|
|
15
15
|
import { NsIcon } from '../icon';
|
|
16
16
|
import Header, { colorMap, iconMap } from './Header';
|
|
17
17
|
import useWindowSize from '../hooks/useWindowSize';
|
|
18
|
+
import { NsTypography } from '../typography';
|
|
18
19
|
|
|
19
20
|
export default function NsAlert({
|
|
20
21
|
context = 'info',
|
|
@@ -57,7 +58,11 @@ export default function NsAlert({
|
|
|
57
58
|
/>
|
|
58
59
|
</AlertIcon>
|
|
59
60
|
<AlertHead>
|
|
60
|
-
<Header head={
|
|
61
|
+
<Header head={
|
|
62
|
+
<NsTypography variant="body-xl" className='alert-head-title' weight="bold" noSpacing>
|
|
63
|
+
{title}
|
|
64
|
+
</NsTypography>
|
|
65
|
+
}>{head}</Header>
|
|
61
66
|
</AlertHead>
|
|
62
67
|
{hasDismissListener && (
|
|
63
68
|
<AlertCloseButton data-testid="alert-close-button" onClick={onDismiss}>
|
|
@@ -24,7 +24,7 @@ describe('GlobalFontInter', () => {
|
|
|
24
24
|
weight="bold"
|
|
25
25
|
className="mt-2"
|
|
26
26
|
decoration="underline"
|
|
27
|
-
|
|
27
|
+
|
|
28
28
|
color="primary"
|
|
29
29
|
>
|
|
30
30
|
{text}
|
|
@@ -41,7 +41,6 @@ describe('GlobalFontInter', () => {
|
|
|
41
41
|
weight="bold"
|
|
42
42
|
className="mt-2"
|
|
43
43
|
decoration="underline"
|
|
44
|
-
fontStyle="italic"
|
|
45
44
|
color="accentColorA"
|
|
46
45
|
>
|
|
47
46
|
{text}
|
|
@@ -1,125 +1,153 @@
|
|
|
1
|
-
import { styled, ColorUtils } from '@nuskin/foundation-theme';
|
|
1
|
+
import { styled, ColorUtils, FoundationTheme } from '@nuskin/foundation-theme';
|
|
2
2
|
import { NsTypographyProps } from './types.d';
|
|
3
3
|
|
|
4
4
|
const { paletteColor } = ColorUtils;
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
type TypographyConfig = {
|
|
7
|
+
fontFamily: string;
|
|
8
|
+
fontSize?: number;
|
|
9
|
+
lineHeight?: number;
|
|
10
|
+
letterSpacingPercentage?: number;
|
|
11
|
+
paragraphSpacing?: number;
|
|
12
|
+
fontWeight?: number;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const defaultFont = 'Roboto';
|
|
16
|
+
const defaultTypographyStyles = {
|
|
7
17
|
h1: {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
18
|
+
fontFamily: defaultFont,
|
|
19
|
+
fontSize: 42,
|
|
20
|
+
lineHeight: 48,
|
|
21
|
+
letterSpacingPercentage: 0,
|
|
22
|
+
paragraphSpacing: 0,
|
|
12
23
|
},
|
|
13
24
|
h2: {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
25
|
+
fontFamily: defaultFont,
|
|
26
|
+
fontSize: 36,
|
|
27
|
+
lineHeight: 42,
|
|
28
|
+
letterSpacingPercentage: 0,
|
|
29
|
+
paragraphSpacing: 0,
|
|
18
30
|
},
|
|
19
31
|
h3: {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
32
|
+
fontFamily: defaultFont,
|
|
33
|
+
fontSize: 32,
|
|
34
|
+
lineHeight: 38,
|
|
35
|
+
letterSpacingPercentage: 0,
|
|
36
|
+
paragraphSpacing: 0,
|
|
24
37
|
},
|
|
25
38
|
h4: {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
39
|
+
fontFamily: defaultFont,
|
|
40
|
+
fontSize: 26,
|
|
41
|
+
lineHeight: 34,
|
|
42
|
+
letterSpacingPercentage: 0,
|
|
43
|
+
paragraphSpacing: 0,
|
|
30
44
|
},
|
|
31
45
|
h5: {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
46
|
+
fontFamily: defaultFont,
|
|
47
|
+
fontSize: 22,
|
|
48
|
+
lineHeight: 28,
|
|
49
|
+
letterSpacingPercentage: 0,
|
|
50
|
+
fontWeight: 700,
|
|
51
|
+
paragraphSpacing: 0,
|
|
37
52
|
},
|
|
38
53
|
h6: {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
54
|
+
fontFamily: defaultFont,
|
|
55
|
+
fontSize: 18,
|
|
56
|
+
lineHeight: 24,
|
|
57
|
+
letterSpacingPercentage: 0,
|
|
58
|
+
fontWeight: 600,
|
|
59
|
+
paragraphSpacing: 0,
|
|
44
60
|
},
|
|
45
61
|
'title-l': {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
62
|
+
fontFamily: defaultFont,
|
|
63
|
+
fontSize: 22,
|
|
64
|
+
lineHeight: 28,
|
|
65
|
+
letterSpacingPercentage: 2,
|
|
66
|
+
fontWeight: 700,
|
|
67
|
+
paragraphSpacing: 0,
|
|
51
68
|
},
|
|
52
69
|
'title-m': {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
70
|
+
fontFamily: defaultFont,
|
|
71
|
+
fontSize: 16,
|
|
72
|
+
lineHeight: 20,
|
|
73
|
+
letterSpacingPercentage: 4,
|
|
74
|
+
fontWeight: 700,
|
|
75
|
+
paragraphSpacing: 0,
|
|
58
76
|
},
|
|
59
77
|
'title-s': {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
78
|
+
fontFamily: defaultFont,
|
|
79
|
+
fontSize: 16,
|
|
80
|
+
lineHeight: 16,
|
|
81
|
+
letterSpacingPercentage: 4,
|
|
82
|
+
fontWeight: 700,
|
|
83
|
+
paragraphSpacing: 0,
|
|
65
84
|
},
|
|
66
85
|
'label-l': {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
86
|
+
fontFamily: defaultFont,
|
|
87
|
+
fontSize: 20,
|
|
88
|
+
lineHeight: 26,
|
|
89
|
+
letterSpacingPercentage: 0,
|
|
90
|
+
fontWeight: 600,
|
|
91
|
+
paragraphSpacing: 8,
|
|
72
92
|
},
|
|
73
93
|
'label-m': {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
94
|
+
fontFamily: defaultFont,
|
|
95
|
+
fontSize: 16,
|
|
96
|
+
lineHeight: 22,
|
|
97
|
+
letterSpacingPercentage: 0,
|
|
98
|
+
fontWeight: 600,
|
|
99
|
+
paragraphSpacing: 8,
|
|
79
100
|
},
|
|
80
101
|
'label-s': {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
102
|
+
fontFamily: defaultFont,
|
|
103
|
+
fontSize: 14,
|
|
104
|
+
lineHeight: 20,
|
|
105
|
+
letterSpacingPercentage: 0,
|
|
106
|
+
fontWeight: 700,
|
|
107
|
+
paragraphSpacing: 6,
|
|
86
108
|
},
|
|
87
109
|
'body-xl': {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
110
|
+
fontFamily: defaultFont,
|
|
111
|
+
fontSize: 18,
|
|
112
|
+
lineHeight: 22,
|
|
113
|
+
letterSpacingPercentage: 0,
|
|
114
|
+
paragraphSpacing: 22,
|
|
92
115
|
},
|
|
93
116
|
'body-l': {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
117
|
+
fontFamily: defaultFont,
|
|
118
|
+
fontSize: 16,
|
|
119
|
+
lineHeight: 22,
|
|
120
|
+
letterSpacingPercentage: 0,
|
|
121
|
+
paragraphSpacing: 20,
|
|
98
122
|
},
|
|
99
123
|
'body-m': {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
124
|
+
fontFamily: defaultFont,
|
|
125
|
+
fontSize: 14,
|
|
126
|
+
lineHeight: 20,
|
|
127
|
+
letterSpacingPercentage: 0,
|
|
128
|
+
paragraphSpacing: 18,
|
|
104
129
|
},
|
|
105
130
|
'body-s': {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
131
|
+
fontFamily: defaultFont,
|
|
132
|
+
fontSize: 12,
|
|
133
|
+
lineHeight: 16,
|
|
134
|
+
letterSpacingPercentage: 1,
|
|
135
|
+
paragraphSpacing: 16,
|
|
110
136
|
},
|
|
111
137
|
'body-xs': {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
138
|
+
fontFamily: defaultFont,
|
|
139
|
+
fontSize: 10,
|
|
140
|
+
lineHeight: 14,
|
|
141
|
+
letterSpacingPercentage: 2,
|
|
142
|
+
paragraphSpacing: 14,
|
|
116
143
|
},
|
|
117
144
|
CTA: {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
145
|
+
fontFamily: defaultFont,
|
|
146
|
+
fontSize: 14,
|
|
147
|
+
lineHeight: 20,
|
|
148
|
+
letterSpacingPercentage: 0.14,
|
|
149
|
+
fontWeight: 600,
|
|
150
|
+
paragraphSpacing: 0,
|
|
123
151
|
},
|
|
124
152
|
};
|
|
125
153
|
|
|
@@ -129,17 +157,37 @@ const fontWeightMap = {
|
|
|
129
157
|
bold: 600,
|
|
130
158
|
};
|
|
131
159
|
|
|
160
|
+
const getVariantStyle = (
|
|
161
|
+
themeTypographyVariants: Record<FoundationTheme.TypographyVariants, TypographyConfig>,
|
|
162
|
+
variant: FoundationTheme.TypographyVariants
|
|
163
|
+
) => {
|
|
164
|
+
const variantStyles = themeTypographyVariants[variant as FoundationTheme.TypographyVariants];
|
|
165
|
+
if (variantStyles) {
|
|
166
|
+
return variantStyles;
|
|
167
|
+
}
|
|
168
|
+
return defaultTypographyStyles[variant as FoundationTheme.TypographyVariants];
|
|
169
|
+
};
|
|
170
|
+
|
|
132
171
|
export const StyledTypography = styled('div')<NsTypographyProps>(
|
|
133
|
-
({ theme, weight
|
|
134
|
-
const fontStyles =
|
|
172
|
+
({ theme, weight, variant, noSpacing, decoration, color, colorOverride }) => {
|
|
173
|
+
const fontStyles: TypographyConfig = getVariantStyle(theme.fonts.typographyVariants, variant) || {};
|
|
135
174
|
if (noSpacing) {
|
|
136
|
-
fontStyles.
|
|
175
|
+
fontStyles.paragraphSpacing = 0;
|
|
176
|
+
}
|
|
177
|
+
if (weight) {
|
|
178
|
+
fontStyles.fontWeight = fontWeightMap[weight] || fontWeightMap.normal;
|
|
137
179
|
}
|
|
180
|
+
const updatedFontStyle = {
|
|
181
|
+
fontFamily: fontStyles?.fontFamily || defaultFont,
|
|
182
|
+
fontSize: `${fontStyles?.fontSize || 16}px`,
|
|
183
|
+
lineHeight: `${fontStyles?.lineHeight || 16}px`,
|
|
184
|
+
margin: fontStyles?.paragraphSpacing || 0,
|
|
185
|
+
fontWeight: fontStyles?.fontWeight || 400,
|
|
186
|
+
letterSpacing: fontStyles?.letterSpacingPercentage || 0,
|
|
187
|
+
};
|
|
138
188
|
return {
|
|
139
|
-
...
|
|
140
|
-
fontFamily: 'Inter',
|
|
189
|
+
...updatedFontStyle,
|
|
141
190
|
textDecorationLine: decoration,
|
|
142
|
-
fontWeight: fontWeightMap[weight],
|
|
143
191
|
color: colorOverride?.startsWith('#') ? colorOverride : paletteColor(color)({ theme }),
|
|
144
192
|
};
|
|
145
193
|
}
|