@nuskin/foundation-ui-components 1.19.3 → 1.19.4-cx130-1001.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 +1 -1
- package/src/common/button/NsButton.styled.tsx +1 -0
- package/src/common/card/CardButton.tsx +32 -13
- package/src/common/card/NsBrandCard.tsx +12 -13
- package/src/common/card/NsPost.tsx +25 -12
- package/src/common/card/NsSmallFullCard.tsx +7 -3
- package/src/common/card/cardSizes.ts +4 -4
- package/src/common/card/specs/NsBrandCard.spec.tsx +5 -5
- package/src/common/card/stories/NsSmallFullCard.stories.tsx +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuskin/foundation-ui-components",
|
|
3
|
-
"version": "1.19.
|
|
3
|
+
"version": "1.19.4-cx130-1001.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": {
|
|
@@ -1,5 +1,18 @@
|
|
|
1
|
+
import { Button } from '@mui/material';
|
|
1
2
|
import { NsButton, NsIcon } from '../';
|
|
2
3
|
import { NsCardButton } from './types';
|
|
4
|
+
import { styled } from '@nuskin/foundation-theme';
|
|
5
|
+
|
|
6
|
+
const ButtonTextVariant = styled(Button)(() => {
|
|
7
|
+
return {
|
|
8
|
+
padding: 0,
|
|
9
|
+
borderBottom: '1px solid black',
|
|
10
|
+
borderRadius: 0,
|
|
11
|
+
textTransform: 'none',
|
|
12
|
+
fontSize: '14px',
|
|
13
|
+
fontWeight: 600,
|
|
14
|
+
};
|
|
15
|
+
});
|
|
3
16
|
|
|
4
17
|
const CardButton = ({
|
|
5
18
|
url,
|
|
@@ -14,21 +27,27 @@ const CardButton = ({
|
|
|
14
27
|
if (showButton && url) {
|
|
15
28
|
return (
|
|
16
29
|
<div className="cta">
|
|
17
|
-
|
|
18
|
-
href={url}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
fullWidth={fullWidth}
|
|
22
|
-
endIcon={
|
|
23
|
-
showArrowWithText && buttonVariant === 'text' ? (
|
|
30
|
+
{buttonVariant === 'text' ? (
|
|
31
|
+
<ButtonTextVariant href={url}>
|
|
32
|
+
{buttonText}
|
|
33
|
+
{showArrowWithText ? (
|
|
24
34
|
<NsIcon name="arrowRight" size="small" color="primary" />
|
|
25
35
|
) : endIcon ? (
|
|
26
|
-
<NsIcon name={endIcon} color=
|
|
27
|
-
) : null
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
36
|
+
<NsIcon name={endIcon} size="small" color="primary" />
|
|
37
|
+
) : null}
|
|
38
|
+
</ButtonTextVariant>
|
|
39
|
+
) : (
|
|
40
|
+
<NsButton
|
|
41
|
+
href={url}
|
|
42
|
+
color={buttonColor}
|
|
43
|
+
variant={buttonVariant}
|
|
44
|
+
fullWidth={fullWidth}
|
|
45
|
+
endIcon={endIcon ? <NsIcon name={endIcon} color={buttonColor} /> : null}
|
|
46
|
+
className="cta-text"
|
|
47
|
+
>
|
|
48
|
+
{buttonText}
|
|
49
|
+
</NsButton>
|
|
50
|
+
)}
|
|
32
51
|
</div>
|
|
33
52
|
);
|
|
34
53
|
}
|
|
@@ -19,18 +19,18 @@ type NsBrandCardProps = {
|
|
|
19
19
|
|
|
20
20
|
const CardContainer = styled((props: any) => <Box {...props} />)(({ size }) => {
|
|
21
21
|
const { small, large } = cardSizes;
|
|
22
|
-
let
|
|
22
|
+
let maxWidth, maxHeight;
|
|
23
23
|
|
|
24
24
|
if (size === 'small') {
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
maxWidth = small.maxWidth;
|
|
26
|
+
maxHeight = small.maxHeight;
|
|
27
27
|
} else {
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
maxWidth = large.maxWidth;
|
|
29
|
+
maxHeight = large.maxHeight;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
return {
|
|
33
|
-
|
|
33
|
+
maxWidth,
|
|
34
34
|
display: 'flex',
|
|
35
35
|
alignItems: 'start',
|
|
36
36
|
justifyContent: 'center',
|
|
@@ -38,6 +38,9 @@ const CardContainer = styled((props: any) => <Box {...props} />)(({ size }) => {
|
|
|
38
38
|
flexDirection: 'column',
|
|
39
39
|
'.brand-title': {
|
|
40
40
|
marginTop: '15px',
|
|
41
|
+
fontSize: '18px',
|
|
42
|
+
fontWeight: 600,
|
|
43
|
+
lineHeight: '26px',
|
|
41
44
|
display: 'inline-block',
|
|
42
45
|
wordBreak: 'break-word',
|
|
43
46
|
},
|
|
@@ -46,13 +49,9 @@ const CardContainer = styled((props: any) => <Box {...props} />)(({ size }) => {
|
|
|
46
49
|
opacity: '0.7',
|
|
47
50
|
},
|
|
48
51
|
},
|
|
49
|
-
'.cta': {
|
|
50
|
-
marginTop: '15px',
|
|
51
|
-
width: '100%',
|
|
52
|
-
},
|
|
53
52
|
'.image': {
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
maxWidth,
|
|
54
|
+
maxHeight,
|
|
56
55
|
backgroundSize: 'cover',
|
|
57
56
|
backgroundPosition: 'center',
|
|
58
57
|
},
|
|
@@ -74,7 +73,7 @@ export default function NsBrandCard({
|
|
|
74
73
|
</NsBrandWrapper>
|
|
75
74
|
</NsBgCard>
|
|
76
75
|
{title ? (
|
|
77
|
-
<NsTypography
|
|
76
|
+
<NsTypography variant="h3" className="brand-title">
|
|
78
77
|
{title}
|
|
79
78
|
</NsTypography>
|
|
80
79
|
) : null}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Box from '@mui/material/Box';
|
|
2
|
-
import { NsImage
|
|
2
|
+
import { NsImage } from '../';
|
|
3
3
|
import { styled } from '@nuskin/foundation-theme';
|
|
4
4
|
|
|
5
5
|
type NsPostProps = {
|
|
@@ -18,27 +18,40 @@ const CardContainer = styled(Box)(() => {
|
|
|
18
18
|
wordWrap: 'break-word' as 'break-word',
|
|
19
19
|
position: 'relative',
|
|
20
20
|
overflow: 'hidden',
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
maxWidth: '165px',
|
|
22
|
+
height: '272px',
|
|
23
23
|
backgroundColor: '#fff',
|
|
24
|
+
'.image': {
|
|
25
|
+
height: '180px',
|
|
26
|
+
overflow: 'hidden',
|
|
27
|
+
objectFit: 'contain',
|
|
28
|
+
},
|
|
24
29
|
'.content': {
|
|
25
|
-
|
|
30
|
+
padding: '20px',
|
|
26
31
|
display: 'flex',
|
|
27
32
|
flexDirection: 'column',
|
|
28
|
-
minHeight: '
|
|
29
|
-
|
|
33
|
+
minHeight: '92px',
|
|
34
|
+
maxHeight: '92px',
|
|
35
|
+
justifyContent: 'space-around',
|
|
30
36
|
},
|
|
31
37
|
'.body-title': {
|
|
32
|
-
|
|
38
|
+
fontSize: '18px',
|
|
39
|
+
fontWeight: 600,
|
|
33
40
|
display: '-webkit-box',
|
|
34
41
|
'-webkit-box-orient': 'vertical',
|
|
35
|
-
'-webkit-line-clamp': '
|
|
42
|
+
'-webkit-line-clamp': '1',
|
|
36
43
|
overflow: 'hidden',
|
|
37
44
|
textOverflow: 'ellipsis',
|
|
38
45
|
},
|
|
39
46
|
'.body-text': {
|
|
47
|
+
fontSize: '12px',
|
|
48
|
+
fontWeight: 700,
|
|
49
|
+
display: '-webkit-box',
|
|
50
|
+
'-webkit-box-orient': 'vertical',
|
|
51
|
+
'-webkit-line-clamp': '1',
|
|
52
|
+
overflow: 'hidden',
|
|
53
|
+
textOverflow: 'ellipsis',
|
|
40
54
|
color: '#8C8C8C',
|
|
41
|
-
marginBottom: '5px',
|
|
42
55
|
},
|
|
43
56
|
};
|
|
44
57
|
});
|
|
@@ -47,11 +60,11 @@ const NsPost = ({ text, body, backgroundImageUrl, backgroundImageAlt, className
|
|
|
47
60
|
return (
|
|
48
61
|
<CardContainer className={className} data-testid="post-card">
|
|
49
62
|
<div className="image">
|
|
50
|
-
<NsImage height=
|
|
63
|
+
<NsImage height={'100%'} width={'auto'} alt={backgroundImageAlt} src={backgroundImageUrl} />
|
|
51
64
|
</div>
|
|
52
65
|
<div className="content">
|
|
53
|
-
<
|
|
54
|
-
<
|
|
66
|
+
<article className="body-title">{text}</article>
|
|
67
|
+
<article className="body-text">{body}</article>
|
|
55
68
|
</div>
|
|
56
69
|
</CardContainer>
|
|
57
70
|
);
|
|
@@ -17,8 +17,9 @@ const CardContainer = styled(Box)(() => {
|
|
|
17
17
|
return {
|
|
18
18
|
backgroundColor: '#fff',
|
|
19
19
|
display: 'flex',
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
maxHeight: '320px',
|
|
21
|
+
maxWidth: '375px',
|
|
22
|
+
overflow: 'hidden',
|
|
22
23
|
position: 'relative',
|
|
23
24
|
'.image': {
|
|
24
25
|
width: '100%',
|
|
@@ -49,12 +50,15 @@ const CardContainer = styled(Box)(() => {
|
|
|
49
50
|
},
|
|
50
51
|
'.title': {
|
|
51
52
|
color: '#fff',
|
|
52
|
-
fontSize: '
|
|
53
|
+
fontSize: '26px',
|
|
53
54
|
fontWeight: '400',
|
|
54
55
|
marginTop: '20px',
|
|
55
56
|
},
|
|
56
57
|
'.cta': {
|
|
57
58
|
marginTop: '20px',
|
|
59
|
+
maxWidth: '208px',
|
|
60
|
+
borderRadius: '4px',
|
|
61
|
+
overflow: 'hidden',
|
|
58
62
|
},
|
|
59
63
|
};
|
|
60
64
|
});
|
|
@@ -58,11 +58,11 @@ describe('NsBrandCard component', () => {
|
|
|
58
58
|
const cardContainer = container.firstChild;
|
|
59
59
|
const nsBgCardElement = cardContainer?.firstChild;
|
|
60
60
|
expect(cardContainer).toHaveStyle(`
|
|
61
|
-
|
|
61
|
+
maxWidth: 160px;
|
|
62
62
|
`);
|
|
63
63
|
expect(nsBgCardElement).toHaveStyle(`
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
maxWidth: 160px;
|
|
65
|
+
maxHeight: 179px;
|
|
66
66
|
`);
|
|
67
67
|
});
|
|
68
68
|
|
|
@@ -71,7 +71,7 @@ describe('NsBrandCard component', () => {
|
|
|
71
71
|
const cardContainer = screen.getByTestId('brand-card') as HTMLElement;
|
|
72
72
|
const computedStyles = window.getComputedStyle(cardContainer);
|
|
73
73
|
|
|
74
|
-
expect(computedStyles.
|
|
74
|
+
expect(computedStyles.maxWidth).toBe('190px');
|
|
75
75
|
});
|
|
76
76
|
|
|
77
77
|
it('7. renders with default styles when size is not provided', () => {
|
|
@@ -79,6 +79,6 @@ describe('NsBrandCard component', () => {
|
|
|
79
79
|
const cardContainer = screen.getByTestId('brand-card') as HTMLElement;
|
|
80
80
|
const computedStyles = window.getComputedStyle(cardContainer);
|
|
81
81
|
|
|
82
|
-
expect(computedStyles.
|
|
82
|
+
expect(computedStyles.maxWidth).toBe('190px');
|
|
83
83
|
});
|
|
84
84
|
});
|