@nuskin/foundation-ui-components 1.6.1 → 1.7.0

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.
Files changed (43) hide show
  1. package/package.json +1 -1
  2. package/src/common/card/NsBrandCard.tsx +94 -0
  3. package/src/common/card/NsCheckoutCard.tsx +92 -0
  4. package/src/common/card/NsHeroCardLevel1.tsx +106 -0
  5. package/src/common/card/NsHeroCardLevel2.tsx +126 -0
  6. package/src/common/card/NsIconText.tsx +153 -0
  7. package/src/common/card/NsLargeCard.tsx +120 -0
  8. package/src/common/card/NsMediumCard.tsx +64 -0
  9. package/src/common/card/NsPost.tsx +60 -0
  10. package/src/common/card/NsSmallFullCard.tsx +90 -0
  11. package/src/common/card/NsXLargeCard.tsx +80 -0
  12. package/src/common/card/cardSizes.ts +12 -0
  13. package/src/common/card/index.ts +10 -2
  14. package/src/common/card/specs/BrandLogo.spec.tsx +1 -1
  15. package/src/common/card/specs/NsBgCard.spec.tsx +2 -2
  16. package/src/common/card/specs/NsBrandCard.spec.tsx +97 -0
  17. package/src/common/card/specs/NsCheckoutCard.spec.tsx +50 -0
  18. package/src/common/card/specs/NsHeroCardLevel1.spec.tsx +48 -0
  19. package/src/common/card/specs/NsHeroCardLevel2.spec.tsx +51 -0
  20. package/src/common/card/specs/NsIconText.spec.tsx +28 -0
  21. package/src/common/card/specs/NsLargeCard.spec.tsx +41 -0
  22. package/src/common/card/specs/NsMediumCard.spec.tsx +35 -0
  23. package/src/common/card/specs/NsPost.spec.tsx +31 -0
  24. package/src/common/card/specs/NsSmallFullCard.spec.tsx +36 -0
  25. package/src/common/card/specs/NsXLargeCard.spec.tsx +35 -0
  26. package/src/common/card/stories/{NsBrandProductCard.stories.tsx → NsBrandCard.stories.tsx} +9 -4
  27. package/src/common/card/stories/NsCheckoutCard.stories.tsx +24 -0
  28. package/src/common/card/stories/NsHeroCardLevel1.stories.tsx +45 -0
  29. package/src/common/card/stories/NsHeroCardLevel2.stories.tsx +50 -0
  30. package/src/common/card/stories/NsIconText.stories.tsx +36 -0
  31. package/src/common/card/stories/NsLargeCard.stories.tsx +32 -0
  32. package/src/common/card/stories/NsMediumCard.stories.tsx +29 -0
  33. package/src/common/card/stories/NsPost.stories.tsx +39 -0
  34. package/src/common/card/stories/NsSmallFullCard.stories.tsx +29 -0
  35. package/src/common/card/stories/NsXLargeCard.stories.tsx +29 -0
  36. package/src/common/carousal/RenderBrand.tsx +3 -2
  37. package/src/common/card/NsBrandProductCard.tsx +0 -47
  38. package/src/common/card/NsFfgCard.tsx +0 -24
  39. package/src/common/card/specs/NsBrandProductCard.spec.tsx +0 -32
  40. package/src/common/card/specs/NsFfgCard.spec.tsx +0 -33
  41. package/src/common/card/stories/NsBgCard.stories.tsx +0 -20
  42. package/src/common/card/stories/NsFfgCard.stories.tsx +0 -73
  43. package/src/common/card/styled/NsFfgStyled.tsx +0 -46
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuskin/foundation-ui-components",
3
- "version": "1.6.1",
3
+ "version": "1.7.0",
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": {
@@ -0,0 +1,94 @@
1
+ import { ShoppingCart } from '@mui/icons-material';
2
+ import Box from '@mui/material/Box';
3
+ import { styled } from '@nuskin/foundation-theme';
4
+ import { NsTypography } from '../';
5
+ import NsBrandWrapper from './NsBrandWrapper';
6
+ import NsBrandLogo from './NsBrandLogo';
7
+ import NsBgCard from './NsBgCard';
8
+ import NsButton from '../button/NsButton';
9
+ import cardSizes from './cardSizes';
10
+
11
+ type NsBrandCardProps = {
12
+ title?: string;
13
+ brandImageUrl: string;
14
+ backgroundImageUrl: string;
15
+ size?: 'small' | 'large';
16
+ button?: boolean;
17
+ onClick?: () => void;
18
+ };
19
+
20
+ const CardContainer = styled((props: any) => <Box {...props} />)(({ size }) => {
21
+ const { small, large } = cardSizes;
22
+ let width, height;
23
+
24
+ if (size === 'small') {
25
+ width = small.width;
26
+ height = small.height;
27
+ } else {
28
+ width = large.width;
29
+ height = large.height;
30
+ }
31
+
32
+ return {
33
+ width,
34
+ display: 'flex',
35
+ alignItems: 'start',
36
+ justifyContent: 'center',
37
+ position: 'relative',
38
+ flexDirection: 'column',
39
+ '.brand-title': {
40
+ marginTop: '15px',
41
+ fontSize: '20px',
42
+ display: 'inline-block',
43
+ wordBreak: 'break-word',
44
+ },
45
+ ':hover': {
46
+ '.brand-title': {
47
+ opacity: '0.7',
48
+ },
49
+ },
50
+ '.cta': {
51
+ marginTop: '15px',
52
+ },
53
+ '.image': {
54
+ width,
55
+ height,
56
+ backgroundSize: 'cover',
57
+ backgroundPosition: 'center',
58
+ },
59
+ };
60
+ });
61
+ export default function NsBrandCard({
62
+ title,
63
+ brandImageUrl,
64
+ backgroundImageUrl,
65
+ button,
66
+ size,
67
+ onClick,
68
+ }: NsBrandCardProps) {
69
+ return (
70
+ <CardContainer role="brand-card" component="div" data-testid="brand-card" size={size} onClick={onClick}>
71
+ <NsBgCard backgroundImageUrl={backgroundImageUrl} className="image">
72
+ <NsBrandWrapper>
73
+ <NsBrandLogo component="img" image={brandImageUrl} />
74
+ </NsBrandWrapper>
75
+ </NsBgCard>
76
+ {title ? (
77
+ <NsTypography variant="h3" className="brand-title">
78
+ {title}
79
+ </NsTypography>
80
+ ) : null}
81
+ {button ? (
82
+ <NsButton
83
+ className="cta"
84
+ darkModeEnabled={false}
85
+ variant="outlined"
86
+ fullWidth={true}
87
+ endIcon={<ShoppingCart />}
88
+ >
89
+ Add to Cart
90
+ </NsButton>
91
+ ) : null}
92
+ </CardContainer>
93
+ );
94
+ }
@@ -0,0 +1,92 @@
1
+ import Box from '@mui/material/Box';
2
+ import { styled } from '@nuskin/foundation-theme';
3
+ import { NsIcon, NsIconNameType, NsLink } from '../';
4
+ import { useState } from 'react';
5
+
6
+ type NsCheckoutCardProps = {
7
+ icon: NsIconNameType;
8
+ title: string;
9
+ address: string;
10
+ onClick: () => void;
11
+ };
12
+
13
+ const CardContainer = styled(Box)(() => {
14
+ return {
15
+ backgroundColor: '#fff',
16
+ display: 'flex',
17
+ width: '345px',
18
+ height: 'auto',
19
+ border: '2px solid #B2B2B2',
20
+ borderRadius: '2px',
21
+ '.left-bar': {
22
+ width: '4px',
23
+ height: 'auto',
24
+ backgroundColor: '#22D55C',
25
+ },
26
+ '.content': {
27
+ display: 'flex',
28
+ flexDirection: 'row',
29
+ gap: '10px',
30
+ margin: '10px',
31
+ width: '100%',
32
+ },
33
+ '.text-content': {
34
+ width: '100%',
35
+ },
36
+ '.title': {
37
+ fontSize: '14px',
38
+ fontWeight: '700',
39
+ },
40
+ '.address': {
41
+ fontSize: '13px',
42
+ fontWeight: '400',
43
+ },
44
+ '.action-link': {
45
+ color: '#7123D9',
46
+ fontSize: '14px',
47
+ fontWeight: '700',
48
+ letterSpacing: '0.7',
49
+ },
50
+ '.icon-right': {
51
+ marginLeft: 'auto',
52
+ },
53
+ '.icon': {
54
+ ':hover': {
55
+ cursor: 'pointer',
56
+ },
57
+ },
58
+ };
59
+ });
60
+
61
+ export default function NsCheckoutCard({ title, address, icon, onClick }: NsCheckoutCardProps) {
62
+ const [dropdownIcon, setDropdownIcon] = useState(false);
63
+ const handleClick = () => {
64
+ setDropdownIcon(!dropdownIcon);
65
+ };
66
+
67
+ return (
68
+ <CardContainer role="checkout-card" component="div" data-testid="checkout-card" onClick={onClick}>
69
+ <div className="left-bar"></div>
70
+ <div className="content">
71
+ <span>
72
+ <NsIcon name={icon} />
73
+ </span>
74
+ <div className="text-content">
75
+ <article className="title">{title}</article>
76
+ <article className="address">{address}</article>
77
+ <NsLink className="action-link" href={''}>
78
+ CHANGE
79
+ </NsLink>
80
+ </div>
81
+ <span className="icon-right">
82
+ <NsIcon
83
+ name={dropdownIcon ? 'arrowUp' : 'arrowDown'}
84
+ className="icon"
85
+ onClick={handleClick}
86
+ testId="dropdown-icon"
87
+ />
88
+ </span>
89
+ </div>
90
+ </CardContainer>
91
+ );
92
+ }
@@ -0,0 +1,106 @@
1
+ import { NsLink, NsImage } from '../';
2
+ import Box from '@mui/material/Box';
3
+ import { AdditionalProps } from '../common.types';
4
+ import { styled } from '@nuskin/foundation-theme';
5
+
6
+ type NsHeroCardLevel1Props = {
7
+ text: string;
8
+ body: string;
9
+ cardLink: { href: string; title: string };
10
+ backgroundImageUrl: string;
11
+ backgroundImageAlt: string;
12
+ onClick: () => void;
13
+ } & AdditionalProps;
14
+
15
+ const CardContainer = styled(Box)(() => {
16
+ return {
17
+ backgroundClip: 'border-box',
18
+ display: 'flex',
19
+ flexDirection: 'row' as 'row', // https://github.com/cssinjs/jss/issues/1344
20
+ wordWrap: 'break-word' as 'break-word',
21
+ position: 'relative',
22
+ overflow: 'hidden',
23
+ height: 'auto',
24
+ '.content': {
25
+ width: '50%',
26
+ height: '100%',
27
+ padding: '50px',
28
+ paddingLeft: '100px',
29
+ display: 'flex',
30
+ flexDirection: 'column' as 'column',
31
+ position: 'absolute',
32
+ top: 0,
33
+ left: 0,
34
+ boxSizing: 'border-box',
35
+ },
36
+ '.image': {
37
+ width: 'auto',
38
+ height: '100%',
39
+ display: 'block',
40
+ },
41
+ '.body-title': {
42
+ fontSize: '36px',
43
+ lineHeight: '44px',
44
+ marginBottom: '20px',
45
+ },
46
+ '.body-text': {
47
+ fontSize: '18px',
48
+ marginBottom: '20px',
49
+ },
50
+ '.action-link': {
51
+ display: 'flex',
52
+ height: '44px',
53
+ flexDirection: 'column',
54
+ justifyContent: 'center',
55
+ alignItems: 'center',
56
+ gap: '10px',
57
+ flexShrink: 0,
58
+ alignSelf: 'stretch',
59
+ backgroundColor: '#252525',
60
+ color: '#fff',
61
+ marginTop: '10px',
62
+ borderRadius: '4px',
63
+
64
+ ':hover': {
65
+ textDecoration: 'none',
66
+ backgroundColor: '#252w16',
67
+ },
68
+ },
69
+ '@media (max-width: 768px)': {
70
+ display: 'block',
71
+ height: 'auto',
72
+ backgroundColor: '#edece9',
73
+ '.content': {
74
+ position: 'static',
75
+ width: '100%',
76
+ padding: '20px',
77
+ },
78
+ },
79
+ };
80
+ });
81
+
82
+ const NsHeroCardLevel1 = ({
83
+ text,
84
+ body,
85
+ cardLink,
86
+ backgroundImageUrl,
87
+ backgroundImageAlt,
88
+ onClick,
89
+ additionalProps,
90
+ }: NsHeroCardLevel1Props) => {
91
+ return (
92
+ <CardContainer data-testid={additionalProps?.testid} onClick={onClick}>
93
+ <div className="image">
94
+ <NsImage height={'auto'} width={'100%'} alt={backgroundImageAlt} src={backgroundImageUrl} />
95
+ </div>
96
+ <div className="content">
97
+ <article className="body-title">{text}</article>
98
+ <article className="body-text">{body}</article>
99
+ <NsLink className="action-link" href={cardLink.href}>
100
+ {cardLink.title}
101
+ </NsLink>
102
+ </div>
103
+ </CardContainer>
104
+ );
105
+ };
106
+ export default NsHeroCardLevel1;
@@ -0,0 +1,126 @@
1
+ import { NsLink, NsImage, NsIcon, NsIconNameType } from '../';
2
+ import Box from '@mui/material/Box';
3
+ import { AdditionalProps } from '../common.types';
4
+ import { styled } from '@nuskin/foundation-theme';
5
+
6
+ type NsHeroCardLevel2Props = {
7
+ brand: string;
8
+ text: string;
9
+ body: string;
10
+ icon: NsIconNameType;
11
+ cardLink: { href: string; title: string };
12
+ backgroundImageUrl: string;
13
+ backgroundImageAlt: string;
14
+ onClick: () => void;
15
+ } & AdditionalProps;
16
+
17
+ const CardContainer = styled(Box)(() => {
18
+ return {
19
+ backgroundClip: 'border-box',
20
+ display: 'flex',
21
+ flexDirection: 'row' as 'row', // https://github.com/cssinjs/jss/issues/1344
22
+ wordWrap: 'break-word' as 'break-word',
23
+ position: 'relative',
24
+ overflow: 'hidden',
25
+ height: 'auto',
26
+ '.content': {
27
+ height: '100%',
28
+ padding: '50px',
29
+ display: 'flex',
30
+ flexDirection: 'column' as 'column',
31
+ position: 'absolute',
32
+ top: 0,
33
+ left: 0,
34
+ boxSizing: 'border-box',
35
+ },
36
+ '.image': {
37
+ width: 'auto',
38
+ height: '100%',
39
+ display: 'block',
40
+ },
41
+ '.brand-container': {
42
+ backgroundColor: '#fff',
43
+ width: 'fit-content',
44
+ paddingLeft: '10px',
45
+ paddingRight: '10px',
46
+ },
47
+ '.body-title': {
48
+ fontSize: '36px',
49
+ lineHeight: '44px',
50
+ marginBottom: '5px',
51
+ },
52
+ '.body-text': {
53
+ fontSize: '18px',
54
+ fontWeight: 700,
55
+ marginBottom: '5px',
56
+ },
57
+ '.cta': {
58
+ display: 'flex',
59
+ flexDirection: 'column' as 'column',
60
+ width: 'fit-content',
61
+ borderBottom: '1px solid black',
62
+ ':hover': {
63
+ opacity: '0.8',
64
+ },
65
+ },
66
+ '.action-link': {
67
+ display: 'flex',
68
+ fontWeight: 600,
69
+ ':hover': {
70
+ textDecoration: 'none',
71
+ },
72
+ },
73
+ '.icon': {
74
+ marginLeft: '10px',
75
+ },
76
+ '@media (max-width: 768px)': {
77
+ '.content': {
78
+ padding: '5%',
79
+ },
80
+ '.body-title': {
81
+ fontSize: '18px',
82
+ lineHeight: '44px',
83
+ marginBottom: '5px',
84
+ },
85
+ '.body-text': {
86
+ fontSize: '12px',
87
+ fontWeight: 700,
88
+ marginBottom: '5px',
89
+ },
90
+ },
91
+ };
92
+ });
93
+
94
+ const NsHeroCardLevel2 = ({
95
+ brand,
96
+ text,
97
+ body,
98
+ cardLink,
99
+ backgroundImageUrl,
100
+ backgroundImageAlt,
101
+ additionalProps,
102
+ icon,
103
+ onClick,
104
+ }: NsHeroCardLevel2Props) => {
105
+ return (
106
+ <CardContainer data-testid={additionalProps?.testid} onClick={onClick}>
107
+ <div className="image">
108
+ <NsImage height={'auto'} width={'100%'} alt={backgroundImageAlt} src={backgroundImageUrl} />
109
+ </div>
110
+ <div className="content">
111
+ <div className="brand-container">
112
+ <article>{brand}</article>
113
+ </div>
114
+ <article className="body-title">{text}</article>
115
+ <article className="body-text">{body}</article>
116
+ <div className="cta">
117
+ <NsLink className="action-link" href={cardLink.href}>
118
+ {cardLink.title}
119
+ <NsIcon className="icon" name={icon} />
120
+ </NsLink>
121
+ </div>
122
+ </div>
123
+ </CardContainer>
124
+ );
125
+ };
126
+ export default NsHeroCardLevel2;
@@ -0,0 +1,153 @@
1
+ import Box from '@mui/material/Box';
2
+ import { AdditionalProps } from '../common.types';
3
+ import { styled } from '@nuskin/foundation-theme';
4
+
5
+ type NsIconTextProps = {
6
+ text: string;
7
+ body: string;
8
+ } & AdditionalProps;
9
+
10
+ const CardContainer = styled(Box)(() => {
11
+ return {
12
+ backgroundClip: 'border-box',
13
+ display: 'flex',
14
+ flexDirection: 'column' as 'column',
15
+ wordWrap: 'break-word' as 'break-word',
16
+ position: 'relative',
17
+ overflow: 'hidden',
18
+ height: 'auto',
19
+ width: '222px',
20
+ backgroundColor: '#F5F5F5',
21
+ padding: '20px',
22
+ justifyContent: 'center',
23
+ gap: '30px',
24
+ '.icon': {
25
+ display: 'flex',
26
+ width: '100%',
27
+ },
28
+ '.divider': {
29
+ width: '182px',
30
+ height: '1px',
31
+ background: '#B2B2B2',
32
+ },
33
+ '.title': {
34
+ fontSize: '26px',
35
+ fontWeight: 400,
36
+ marginTop: '-10px',
37
+ },
38
+ '.text': {
39
+ fontWeight: 400,
40
+ fontSize: '14px',
41
+ },
42
+ };
43
+ });
44
+
45
+ const NsIconText = ({ text, body, additionalProps }: NsIconTextProps) => {
46
+ return (
47
+ <CardContainer data-testid={additionalProps?.testid}>
48
+ <div className="icon">
49
+ <svg xmlns="http://www.w3.org/2000/svg" width="80" height="80" viewBox="0 0 80 80" fill="none">
50
+ <path
51
+ d="M40 80C62.0914 80 80 62.0914 80 40C80 17.9086 62.0914 0 40 0C17.9086 0 0 17.9086 0 40C0 62.0914 17.9086 80 40 80Z"
52
+ fill="white"
53
+ />
54
+ <path
55
+ opacity="0.3"
56
+ d="M43.7138 75.6844C62.5411 73.4233 73.528 54.1872 57.8386 44.0119C46.8517 37.2284 19.7234 38.6174 17.646 51.4899C15.0035 67.8672 29.589 77.9456 43.7138 75.6844Z"
57
+ fill="#F56767"
58
+ />
59
+ <path
60
+ d="M2.66699 40.4277H77.5603"
61
+ stroke="#252525"
62
+ stroke-width="2"
63
+ stroke-linecap="round"
64
+ stroke-linejoin="round"
65
+ />
66
+ <path
67
+ d="M16 60H64"
68
+ stroke="#252525"
69
+ stroke-width="2"
70
+ stroke-linecap="round"
71
+ stroke-linejoin="round"
72
+ stroke-dasharray="5 5"
73
+ />
74
+ <path
75
+ d="M25.333 69.334L54.6663 69.334"
76
+ stroke="#252525"
77
+ stroke-width="2"
78
+ stroke-linecap="round"
79
+ stroke-linejoin="round"
80
+ stroke-dasharray="7 7"
81
+ />
82
+ <path
83
+ d="M8 48.9556C9.73125 51.1044 23.5567 54.3276 41.6428 49.4257C58.2309 44.9938 70.7303 46.8336 73.3333 48.5258"
84
+ stroke="#252525"
85
+ stroke-width="2"
86
+ stroke-linecap="round"
87
+ stroke-linejoin="round"
88
+ />
89
+ <path
90
+ d="M24 22.668V25.3346"
91
+ stroke="#252525"
92
+ stroke-width="2"
93
+ stroke-linecap="round"
94
+ stroke-linejoin="round"
95
+ />
96
+ <path
97
+ d="M24 33.334V36.0007"
98
+ stroke="#252525"
99
+ stroke-width="2"
100
+ stroke-linecap="round"
101
+ stroke-linejoin="round"
102
+ />
103
+ <path
104
+ d="M50.6665 12V14.6667"
105
+ stroke="#252525"
106
+ stroke-width="2"
107
+ stroke-linecap="round"
108
+ stroke-linejoin="round"
109
+ />
110
+ <path
111
+ d="M50.6665 22.666V25.3327"
112
+ stroke="#252525"
113
+ stroke-width="2"
114
+ stroke-linecap="round"
115
+ stroke-linejoin="round"
116
+ />
117
+ <path
118
+ d="M17.3335 29.332H20.0002"
119
+ stroke="#252525"
120
+ stroke-width="2"
121
+ stroke-linecap="round"
122
+ stroke-linejoin="round"
123
+ />
124
+ <path
125
+ d="M28 29.332H30.6667"
126
+ stroke="#252525"
127
+ stroke-width="2"
128
+ stroke-linecap="round"
129
+ stroke-linejoin="round"
130
+ />
131
+ <path
132
+ d="M44 18.668H46.6667"
133
+ stroke="#252525"
134
+ stroke-width="2"
135
+ stroke-linecap="round"
136
+ stroke-linejoin="round"
137
+ />
138
+ <path
139
+ d="M54.6665 18.668H57.3332"
140
+ stroke="#252525"
141
+ stroke-width="2"
142
+ stroke-linecap="round"
143
+ stroke-linejoin="round"
144
+ />
145
+ </svg>
146
+ </div>
147
+ <article className="title">{text}</article>
148
+ <div className="divider"></div>
149
+ <article className="text">{body}</article>
150
+ </CardContainer>
151
+ );
152
+ };
153
+ export default NsIconText;