@nuskin/foundation-ui-components 1.2.0 → 1.4.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.
- package/package.json +5 -5
- package/src/common/auth-dropdown/NsAuthDropdown.tsx +13 -9
- package/src/common/button/NsButton.stories.tsx +3 -2
- package/src/common/button/NsButton.tsx +27 -2
- package/src/common/button/types.d.ts +21 -17
- package/src/common/cart-icon/NsCartIcon.spec.tsx +3 -2
- package/src/common/cart-icon/NsCartIcon.stories.tsx +1 -1
- package/src/common/cart-icon/NsCartIcon.styled.tsx +14 -0
- package/src/common/cart-icon/NsCartIcon.tsx +1 -1
- package/src/common/cart-icon/types.d.ts +2 -2
- package/src/common/dropdown/NsDropdown.tsx +15 -11
- package/src/common/email-simple/NsEmailSimple.tsx +1 -1
- package/src/common/flag/NsFlag.spec.tsx +14 -2
- package/src/common/flag/NsFlag.styled.tsx +2 -5
- package/src/common/hooks/useOnClickOutside.tsx +14 -14
- package/src/common/icon/NsIcon.spec.tsx +21 -6
- package/src/common/icon/NsIcon.stories.tsx +2 -1
- package/src/common/icon/NsIcon.styled.tsx +13 -10
- package/src/common/icon/NsIcon.tsx +9 -6
- package/src/common/icon/NsIconVariants.ts +2 -0
- package/src/common/icon/icons/AlertErrorIcon.tsx +2 -1
- package/src/common/icon/icons/ArrowLeft.tsx +2 -2
- package/src/common/icon/icons/ArrowRight.tsx +2 -2
- package/src/common/icon/icons/CartBadge.tsx +2 -2
- package/src/common/icon/icons/Check.tsx +25 -0
- package/src/common/icon/icons/CloseIcon.tsx +1 -1
- package/src/common/icon/icons/ErrorIcon.tsx +3 -2
- package/src/common/icon/icons/SearchIcon.tsx +3 -2
- package/src/common/icon/icons/SuccessIcon.tsx +7 -1
- package/src/common/icon/icons/TrashIcon.tsx +2 -1
- package/src/common/icon/icons/UserIcon.tsx +8 -1
- package/src/common/icon/icons/UserOutline.tsx +4 -1
- package/src/common/icon/icons/WarningIcon.tsx +3 -2
- package/src/common/icon/types.d.ts +3 -2
- package/src/common/index.ts +8 -4
- package/src/common/progress/NsProgress.spec.tsx +2 -2
- package/src/common/progress/NsProgress.stories.tsx +10 -5
- package/src/common/progress/NsProgress.styled.tsx +30 -12
- package/src/common/progress/NsProgress.tsx +18 -16
- package/src/common/progress/types.d.ts +2 -2
- package/src/common/radiogroup/NsRadioGroup.spec.tsx +2 -2
- package/src/common/radiogroup/NsRadioGroup.stories.tsx +2 -2
- package/src/common/radiogroup/NsRadioGroup.tsx +5 -3
- package/src/common/radiogroup/types.d.ts +11 -12
- package/src/common/select/NsSelect.styled.tsx +38 -71
- package/src/common/select/NsSelect.tsx +86 -91
- package/src/common/select/NsSelectOption.tsx +10 -14
- package/src/common/select/specs/NsSelect.spec.tsx +183 -0
- package/src/common/select/specs/NsSelectOption.spec.tsx +32 -0
- package/src/common/select/stories/NsSelect.stories.tsx +25 -80
- package/src/common/select/stories/countries.ts +53 -0
- package/src/common/select/types.d.ts +21 -8
- package/src/common/table/NsTable.stories.tsx +1 -0
- package/src/common/cart-icon/NsCartIcon.styled.ts +0 -14
- package/src/common/select/NsSelect.spec.tsx +0 -274
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/* eslint-disable max-len */
|
|
2
|
+
|
|
3
|
+
import { SvgIcon, SvgIconProps } from '@mui/material';
|
|
4
|
+
|
|
5
|
+
const Check = (props: SvgIconProps) => {
|
|
6
|
+
return (
|
|
7
|
+
<SvgIcon
|
|
8
|
+
viewBox="0 0 21 20"
|
|
9
|
+
fill="none"
|
|
10
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
11
|
+
preserveAspectRatio="xMidYMid meet"
|
|
12
|
+
data-testid="check"
|
|
13
|
+
{...props}
|
|
14
|
+
>
|
|
15
|
+
<path
|
|
16
|
+
fillRule="evenodd"
|
|
17
|
+
clipRule="evenodd"
|
|
18
|
+
d="M20.0625 3.57806C20.3879 3.9035 20.3879 4.43114 20.0625 4.75657L8.39582 16.4232C8.23944 16.5796 8.02731 16.6674 7.80616 16.6673C7.585 16.6672 7.37296 16.5792 7.21673 16.4227L1.22007 10.4143C0.894947 10.0886 0.89546 9.56094 1.22121 9.23582C1.54697 8.9107 2.0746 8.91122 2.39972 9.23697L7.80714 14.6549L18.884 3.57806C19.2094 3.25263 19.737 3.25263 20.0625 3.57806Z"
|
|
19
|
+
fill={props.color}
|
|
20
|
+
/>
|
|
21
|
+
</SvgIcon>
|
|
22
|
+
);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export default Check;
|
|
@@ -12,7 +12,7 @@ const CloseIcon = (props: SvgIconProps) => {
|
|
|
12
12
|
{...props}
|
|
13
13
|
data-testid="close"
|
|
14
14
|
>
|
|
15
|
-
<g fill="none" stroke={props.color
|
|
15
|
+
<g fill="none" stroke={props.color} strokeWidth="1">
|
|
16
16
|
<path strokeLinecap="round" d="M 0 0 L 12 12 M 0 12 L 12 0" />
|
|
17
17
|
</g>
|
|
18
18
|
</SvgIcon>
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/* eslint-disable max-len */
|
|
2
2
|
import SvgIcon, { SvgIconProps } from '@mui/material/SvgIcon';
|
|
3
|
+
|
|
3
4
|
/**
|
|
4
|
-
*
|
|
5
|
+
* pass colorOverride = '#C81D1D'
|
|
5
6
|
* @param props { color: color to be filled for icon}
|
|
6
7
|
* @returns ErrorIcon, can be used in Input field, when input field is in error state
|
|
7
8
|
*/
|
|
@@ -18,7 +19,7 @@ const ErrorIcon = (props: SvgIconProps) => {
|
|
|
18
19
|
>
|
|
19
20
|
<path
|
|
20
21
|
d="M17.07 2.92999C15.4338 1.29429 13.2811 0.276523 10.9786 0.0501185C8.67611 -0.176286 6.36637 0.402675 4.44291 1.68835C2.51945 2.97403 1.1013 4.88687 0.430089 7.10094C-0.241121 9.31502 -0.123857 11.6933 0.761901 13.8306C1.64766 15.9679 3.24711 17.732 5.28771 18.8222C7.32831 19.9125 9.68381 20.2614 11.9528 19.8096C14.2219 19.3578 16.2641 18.1332 17.7314 16.3445C19.1988 14.5557 20.0005 12.3136 20 9.99999C19.9994 7.34804 18.9455 4.80491 17.07 2.92999ZM9 5.37999C9 5.11477 9.10536 4.86041 9.29289 4.67288C9.48043 4.48534 9.73478 4.37999 10 4.37999C10.2652 4.37999 10.5196 4.48534 10.7071 4.67288C10.8946 4.86041 11 5.11477 11 5.37999V10.6C11 10.8652 10.8946 11.1196 10.7071 11.3071C10.5196 11.4946 10.2652 11.6 10 11.6C9.73478 11.6 9.48043 11.4946 9.29289 11.3071C9.10536 11.1196 9 10.8652 9 10.6V5.37999ZM10 15.51C9.74684 15.51 9.49936 15.4349 9.28887 15.2943C9.07837 15.1536 8.91431 14.9537 8.81743 14.7198C8.72055 14.4859 8.6952 14.2286 8.74459 13.9803C8.79398 13.732 8.91589 13.5039 9.0949 13.3249C9.27391 13.1459 9.50199 13.024 9.75028 12.9746C9.99858 12.9252 10.2559 12.9505 10.4898 13.0474C10.7237 13.1443 10.9236 13.3084 11.0643 13.5189C11.2049 13.7294 11.28 13.9768 11.28 14.23C11.28 14.5695 11.1451 14.895 10.9051 15.1351C10.665 15.3751 10.3395 15.51 10 15.51Z"
|
|
21
|
-
fill={props.color
|
|
22
|
+
fill={props.color}
|
|
22
23
|
/>
|
|
23
24
|
</SvgIcon>
|
|
24
25
|
);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/* eslint-disable max-len */
|
|
2
2
|
import SvgIcon, { SvgIconProps } from '@mui/material/SvgIcon';
|
|
3
|
+
|
|
3
4
|
/**
|
|
4
|
-
*
|
|
5
|
+
* pass colorOverride = '#5F5F5F'
|
|
5
6
|
* @param props {fill: color to be filled for icon, color: color of the tick icon}
|
|
6
7
|
* @returns SearchIcon, can be used in Input field, when input field is in success state
|
|
7
8
|
*/
|
|
@@ -20,7 +21,7 @@ const SearchIcon = (props: SvgIconProps) => {
|
|
|
20
21
|
fillRule="evenodd"
|
|
21
22
|
clipRule="evenodd"
|
|
22
23
|
d="M0 9.98777C0 4.47167 4.46598 0 9.97505 0C15.4841 0 19.9501 4.47167 19.9501 9.98777C19.9501 11.7568 19.49 13.4205 18.6829 14.8629L23.2366 19.4844C24.2593 20.5223 24.2537 22.1921 23.2241 23.2231C22.1755 24.273 20.4704 24.2567 19.442 23.1869L15.0315 18.5988C13.5485 19.4736 11.8192 19.9755 9.97505 19.9755C4.46598 19.9755 0 15.5039 0 9.98777ZM16.6388 17.42L20.8646 21.8159C21.1265 22.0884 21.5608 22.0926 21.8279 21.8251C22.0902 21.5625 22.0916 21.1372 21.8311 20.8728L17.5309 16.5087C17.2531 16.8311 16.9551 17.1355 16.6388 17.42ZM9.97505 1.97696C5.55644 1.97696 1.97444 5.56352 1.97444 9.98777C1.97444 14.412 5.55644 17.9986 9.97505 17.9986C11.7025 17.9986 13.2995 17.4515 14.6063 16.5208C15.3948 15.9594 16.0773 15.2583 16.6179 14.454C17.4753 13.1784 17.9757 11.6431 17.9757 9.98777C17.9757 5.56352 14.3937 1.97696 9.97505 1.97696Z"
|
|
23
|
-
fill={props.color
|
|
24
|
+
fill={props.color}
|
|
24
25
|
/>
|
|
25
26
|
</SvgIcon>
|
|
26
27
|
);
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
/* eslint-disable max-len */
|
|
2
2
|
import SvgIcon, { SvgIconProps } from '@mui/material/SvgIcon';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* pass fill = '#fff' and colorOverride ='#5BAC85'
|
|
6
|
+
* @param props
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
3
9
|
const SuccessIcon = (props: SvgIconProps) => {
|
|
4
10
|
return (
|
|
5
11
|
<SvgIcon
|
|
@@ -12,7 +18,7 @@ const SuccessIcon = (props: SvgIconProps) => {
|
|
|
12
18
|
{...props}
|
|
13
19
|
>
|
|
14
20
|
<g id="Check Circle">
|
|
15
|
-
<circle id="Ellipse 70" cx="10" cy="10" r="10" fill={props.color
|
|
21
|
+
<circle id="Ellipse 70" cx="10" cy="10" r="10" fill={props.color} />
|
|
16
22
|
<g id="check 12px">
|
|
17
23
|
<g id="checkmark">
|
|
18
24
|
<path
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/* eslint-disable max-len */
|
|
2
2
|
import SvgIcon, { SvgIconProps } from '@mui/material/SvgIcon';
|
|
3
|
+
|
|
3
4
|
/**
|
|
4
5
|
*
|
|
5
6
|
* @param props {fill: color of the trash icon}
|
|
@@ -20,7 +21,7 @@ const TrashIcon = (props: SvgIconProps) => {
|
|
|
20
21
|
fillRule="evenodd"
|
|
21
22
|
clipRule="evenodd"
|
|
22
23
|
d="M10 0C10.5523 0 11 0.447715 11 1V2.5H19C19.5523 2.5 20 2.94772 20 3.5C20 4.05228 19.5523 4.5 19 4.5H17.5V18C17.5 19.6569 16.1569 21 14.5 21H5.5C3.84315 21 2.5 19.6569 2.5 18V4.5H1C0.447715 4.5 0 4.05228 0 3.5C0 2.94772 0.447715 2.5 1 2.5H9V1C9 0.447715 9.44771 0 10 0ZM4.5 4.5V18C4.5 18.5523 4.94772 19 5.5 19H14.5C15.0523 19 15.5 18.5523 15.5 18V4.5H4.5ZM6.5 5.5C7.05228 5.5 7.5 5.94772 7.5 6.5V17C7.5 17.5523 7.05228 18 6.5 18C5.94772 18 5.5 17.5523 5.5 17V6.5C5.5 5.94772 5.94772 5.5 6.5 5.5ZM10 5.5C10.5523 5.5 11 5.94772 11 6.5V17C11 17.5523 10.5523 18 10 18C9.44771 18 9 17.5523 9 17V6.5C9 5.94772 9.44771 5.5 10 5.5ZM13.5 5.5C14.0523 5.5 14.5 5.94772 14.5 6.5V17C14.5 17.5523 14.0523 18 13.5 18C12.9477 18 12.5 17.5523 12.5 17V6.5C12.5 5.94772 12.9477 5.5 13.5 5.5Z"
|
|
23
|
-
fill={props.color
|
|
24
|
+
fill={props.color}
|
|
24
25
|
/>
|
|
25
26
|
</SvgIcon>
|
|
26
27
|
);
|
|
@@ -6,7 +6,13 @@ import SvgIcon, { SvgIconProps } from '@mui/material/SvgIcon';
|
|
|
6
6
|
*/
|
|
7
7
|
const UserIcon = (props: SvgIconProps) => {
|
|
8
8
|
return (
|
|
9
|
-
<SvgIcon
|
|
9
|
+
<SvgIcon
|
|
10
|
+
viewBox="0 0 24 24"
|
|
11
|
+
data-testid="userIcon"
|
|
12
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
13
|
+
{...props}
|
|
14
|
+
fill="transparent"
|
|
15
|
+
>
|
|
10
16
|
<path
|
|
11
17
|
fillRule="evenodd"
|
|
12
18
|
clipRule="evenodd"
|
|
@@ -17,6 +23,7 @@ const UserIcon = (props: SvgIconProps) => {
|
|
|
17
23
|
<path
|
|
18
24
|
d="M19 20C18.9425 19.3229 19 17.5669 17.3793 17.2226C14.7126 16.6144 13.931 16.4078 14.1034 14.2272C15.8046 13.0796 15.7816 11.0252 15.7471 8.74139C15.7471 6.67508 14.0695 5 12 5C9.93052 5 8.25287 6.67508 8.25287 8.74139C8.25287 11.0367 8.25287 13.137 9.89655 14.2272C10.0575 16.4078 9.28736 16.6144 6.62069 17.2226C5 17.5669 5.05747 19.3229 5 20"
|
|
19
25
|
stroke={props.color}
|
|
26
|
+
fill={props.color}
|
|
20
27
|
strokeWidth="2"
|
|
21
28
|
strokeLinecap="round"
|
|
22
29
|
/>
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
/* eslint-disable max-len */
|
|
2
2
|
import SvgIcon, { SvgIconProps } from '@mui/material/SvgIcon';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* * pass colorOverride = '#272525'
|
|
6
|
+
*/
|
|
4
7
|
function UserOutline(props: SvgIconProps) {
|
|
5
8
|
return (
|
|
6
9
|
<SvgIcon
|
|
@@ -15,7 +18,7 @@ function UserOutline(props: SvgIconProps) {
|
|
|
15
18
|
fill-rule="evenodd"
|
|
16
19
|
clip-rule="evenodd"
|
|
17
20
|
d="M12 1.25C6.06294 1.25 1.25 6.06294 1.25 12C1.25 17.9371 6.06294 22.75 12 22.75C17.9371 22.75 22.75 17.9371 22.75 12C22.75 6.06294 17.9371 1.25 12 1.25ZM2.75 12C2.75 6.89137 6.89137 2.75 12 2.75C17.1086 2.75 21.25 6.89137 21.25 12C21.25 14.5514 20.217 16.8615 18.5465 18.535C18.5373 18.5053 18.5278 18.4757 18.5177 18.4462C18.2909 17.7811 17.7908 17.0816 16.7743 16.861C16.1976 16.7279 15.7597 16.6249 15.4126 16.5154C15.0619 16.4048 14.8722 16.3075 14.7621 16.2197C14.6519 16.1318 14.5229 15.9893 14.534 15.3824C15.2564 14.7722 15.6208 13.9828 15.7989 13.145C15.9917 12.2377 15.9765 11.218 15.9621 10.2575L15.9618 10.2367C15.9587 8.04108 14.1928 6.25 12 6.25C9.80523 6.25 8.03818 8.04427 8.03818 10.2425L8.03818 10.2902C8.03812 11.2492 8.03807 12.2685 8.23093 13.1685C8.40828 13.9961 8.76096 14.7856 9.46415 15.382C9.47219 15.9884 9.34391 16.1319 9.23338 16.2204C9.12398 16.3079 8.93522 16.4051 8.58559 16.5155C8.23946 16.6249 7.80232 16.728 7.22572 16.861C6.20921 17.0816 5.70909 17.7811 5.48226 18.4462C5.47222 18.4757 5.46266 18.5053 5.45354 18.535C3.78298 16.8615 2.75 14.5514 2.75 12ZM6.77658 19.6351C8.26295 20.6539 10.0619 21.25 12 21.25C13.9381 21.25 15.7371 20.6539 17.2234 19.6351C17.206 19.3999 17.1779 19.1646 17.098 18.9304C16.9903 18.6146 16.822 18.4054 16.4533 18.3262L16.4423 18.3239L16.4423 18.3238C15.8787 18.1938 15.3772 18.0771 14.9615 17.946C14.5483 17.8157 14.1512 17.6513 13.8266 17.3922C13.0849 16.8004 12.9768 15.9412 13.0552 14.9385L13.0833 14.58L13.3803 14.3774C13.9081 14.0173 14.1862 13.5172 14.3317 12.8331C14.4843 12.1148 14.477 11.265 14.4619 10.2537L14.4617 10.2425H14.4618C14.4618 8.8592 13.3529 7.75 12 7.75C10.6471 7.75 9.53818 8.8592 9.53818 10.2425C9.53818 11.259 9.54149 12.1256 9.69764 12.8542C9.84777 13.5548 10.1225 14.0439 10.6148 14.3741L10.9184 14.5777L10.9451 14.9423C11.0181 15.9429 10.9092 16.8005 10.1706 17.3915C9.84647 17.6509 9.45024 17.8154 9.03756 17.9458C8.62239 18.077 8.12144 18.1938 7.55771 18.3238L7.54669 18.3263L7.54667 18.3262C7.17801 18.4054 7.00968 18.6146 6.90197 18.9304C6.8221 19.1646 6.79403 19.3999 6.77658 19.6351Z"
|
|
18
|
-
fill={props.color
|
|
21
|
+
fill={props.color}
|
|
19
22
|
/>
|
|
20
23
|
</SvgIcon>
|
|
21
24
|
);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/* eslint-disable max-len */
|
|
2
2
|
import SvgIcon, { SvgIconProps } from '@mui/material/SvgIcon';
|
|
3
|
+
|
|
3
4
|
/**
|
|
4
|
-
*
|
|
5
|
+
* pass colorOverride = '#FEBD00'
|
|
5
6
|
* @param props { fill: color to be filled for icon, color: color of the tick icon}
|
|
6
7
|
* @returns ErrorIcon, can be used in Input field, when input field is in error state
|
|
7
8
|
*/
|
|
@@ -24,7 +25,7 @@ const WarningIcon = (props: SvgIconProps) => {
|
|
|
24
25
|
15.5143276 0.328282319,15.6093523 0.505163987,15.6123832 L17.5120236,15.6123832 C17.6889052,15.6093523 17.8513135,15.5143276 17.940195,15.3618609 C18.0290766,
|
|
25
26
|
15.2093943 18.0314841,15.0216954 17.9465423,14.8670135 Z"
|
|
26
27
|
id="Shape"
|
|
27
|
-
fill={props.color
|
|
28
|
+
fill={props.color}
|
|
28
29
|
fillRule="nonzero"
|
|
29
30
|
></path>
|
|
30
31
|
<path
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { FoundationTheme } from '@nuskin/foundation-theme';
|
|
2
|
+
import { HTMLProps } from 'react';
|
|
3
|
+
|
|
2
4
|
import { NsIconVariants } from '.';
|
|
3
5
|
|
|
4
6
|
export type NsIconSizeType = 'small' | 'medium' | 'large' | 'xLarge';
|
|
5
7
|
|
|
6
8
|
export type NsIconNameType = keyof typeof NsIconVariants;
|
|
7
9
|
|
|
8
|
-
export type NsIconProps = {
|
|
10
|
+
export type NsIconProps = HTMLProps & {
|
|
9
11
|
name: NsIconNameType;
|
|
10
12
|
size?: NsIconSizeType;
|
|
11
13
|
color?: FoundationTheme.PaletteColors;
|
|
12
14
|
testId?: string;
|
|
13
|
-
className?: string;
|
|
14
15
|
colorOverride?: string;
|
|
15
16
|
};
|
package/src/common/index.ts
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
export * from './accordion';
|
|
2
2
|
export * from './alert';
|
|
3
3
|
export * from './auth-dropdown';
|
|
4
|
+
export * from './autocomplete';
|
|
4
5
|
export * from './banner';
|
|
5
6
|
|
|
6
|
-
export * from './breadcrumb';
|
|
7
7
|
export * from './brand-components';
|
|
8
|
+
export * from './breadcrumb';
|
|
8
9
|
export * from './button';
|
|
9
10
|
export * from './card';
|
|
10
11
|
export * from './carousal';
|
|
11
12
|
export * from './cart-icon';
|
|
12
|
-
export * from './column-control';
|
|
13
13
|
export * from './checkbox';
|
|
14
14
|
export * from './common.types.d';
|
|
15
|
+
export * from './column-control';
|
|
15
16
|
export * from './dropdown';
|
|
16
17
|
export * from './email-simple';
|
|
17
18
|
export * from './flag';
|
|
@@ -22,11 +23,14 @@ export * from './input';
|
|
|
22
23
|
export * from './label';
|
|
23
24
|
export * from './link';
|
|
24
25
|
export * from './modal';
|
|
25
|
-
export * from './nav-tab';
|
|
26
26
|
export * from './nav-product-card';
|
|
27
|
+
export * from './nav-tab';
|
|
28
|
+
export * from './progress';
|
|
27
29
|
export * from './radiogroup';
|
|
30
|
+
export * from './select';
|
|
28
31
|
export * from './spinner';
|
|
29
|
-
export * from './text-strip';
|
|
30
32
|
export * from './table';
|
|
33
|
+
export * from './text-strip';
|
|
31
34
|
export * from './typography';
|
|
32
35
|
export * from './utility';
|
|
36
|
+
export * from './videos';
|
|
@@ -4,7 +4,7 @@ import Progress from './NsProgress';
|
|
|
4
4
|
|
|
5
5
|
describe(' NsProgress Component', () => {
|
|
6
6
|
test('should render Progress bar', () => {
|
|
7
|
-
render(<Progress
|
|
7
|
+
render(<Progress barColor="primary" value={10}></Progress>);
|
|
8
8
|
|
|
9
9
|
const pbar = screen.getByRole('progressbar');
|
|
10
10
|
|
|
@@ -16,7 +16,7 @@ describe(' NsProgress Component', () => {
|
|
|
16
16
|
const value = 50;
|
|
17
17
|
|
|
18
18
|
// Render the StyledProgress component with the value prop
|
|
19
|
-
const { container } = render(<Progress
|
|
19
|
+
const { container } = render(<Progress barColor="primary" value={value} />);
|
|
20
20
|
|
|
21
21
|
// Get the progress bar element
|
|
22
22
|
const progressBar = container.querySelector('.MuiLinearProgress-bar');
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { withCenterDecorator } from '@/stories/decorators/withCenterDecorator';
|
|
2
2
|
import type { StoryObj, Meta } from '@storybook/react';
|
|
3
3
|
import NsProgress from './NsProgress';
|
|
4
|
+
import { PaletteColors } from '@nuskin/foundation-theme';
|
|
4
5
|
|
|
5
6
|
type ComponentType = typeof NsProgress;
|
|
6
7
|
type Story = StoryObj<ComponentType>;
|
|
@@ -8,10 +9,12 @@ type MetaStory = Meta<ComponentType>;
|
|
|
8
9
|
|
|
9
10
|
export default {
|
|
10
11
|
component: NsProgress,
|
|
11
|
-
title: '
|
|
12
|
+
title: 'Components/Inputs/NsProgress',
|
|
12
13
|
decorators: [withCenterDecorator],
|
|
13
14
|
argTypes: {
|
|
14
|
-
|
|
15
|
+
barColor: {
|
|
16
|
+
control: 'select',
|
|
17
|
+
options: PaletteColors,
|
|
15
18
|
description: 'defines the color for the completed progress',
|
|
16
19
|
},
|
|
17
20
|
height: {
|
|
@@ -21,6 +24,8 @@ export default {
|
|
|
21
24
|
description: 'value of the progress done',
|
|
22
25
|
},
|
|
23
26
|
backgroundColor: {
|
|
27
|
+
control: 'select',
|
|
28
|
+
options: PaletteColors,
|
|
24
29
|
description: 'color of incomplete progress',
|
|
25
30
|
},
|
|
26
31
|
},
|
|
@@ -28,9 +33,9 @@ export default {
|
|
|
28
33
|
|
|
29
34
|
export const ProgressBar: Story = {
|
|
30
35
|
args: {
|
|
31
|
-
|
|
32
|
-
backgroundColor: '
|
|
33
|
-
value:
|
|
36
|
+
barColor: 'primary',
|
|
37
|
+
backgroundColor: 'secondary',
|
|
38
|
+
value: 40,
|
|
34
39
|
height: '10px',
|
|
35
40
|
body: <span>{'% Complete'}</span>,
|
|
36
41
|
},
|
|
@@ -2,8 +2,9 @@ import { styled, ColorUtils } from '@nuskin/foundation-theme';
|
|
|
2
2
|
import { LinearProgress } from '@mui/material';
|
|
3
3
|
import CheckCircleIcon from '@mui/icons-material/CheckCircle';
|
|
4
4
|
import { NsProgressProps } from './types';
|
|
5
|
+
import { NsTypography } from '../typography';
|
|
5
6
|
|
|
6
|
-
const { color } = ColorUtils;
|
|
7
|
+
const { color, paletteColor } = ColorUtils;
|
|
7
8
|
export const StyledCheckCircle = styled(CheckCircleIcon)`
|
|
8
9
|
color: ${color('neutral', '50')};
|
|
9
10
|
padding-top: 0.6em;
|
|
@@ -11,29 +12,46 @@ export const StyledCheckCircle = styled(CheckCircleIcon)`
|
|
|
11
12
|
justify-self: flex-end;
|
|
12
13
|
`;
|
|
13
14
|
|
|
14
|
-
export const
|
|
15
|
-
color: ${color('primary', '100')};
|
|
15
|
+
export const ProgressInfo = styled(NsTypography)`
|
|
16
16
|
display: flex;
|
|
17
17
|
justify-content: flex-end;
|
|
18
|
-
font-family: Inter;
|
|
19
|
-
font-size: 12px;
|
|
20
|
-
font-style: normal;
|
|
21
18
|
font-weight: 700;
|
|
22
19
|
text-transform: uppercase;
|
|
23
20
|
`;
|
|
24
21
|
|
|
25
22
|
export const StyledLinearProgress = styled(LinearProgress)<Omit<NsProgressProps, 'value'>>(
|
|
26
|
-
({ height, backgroundColor,
|
|
23
|
+
({ height, backgroundColor, barColor, theme }) => ({
|
|
27
24
|
width: '334px',
|
|
28
25
|
height,
|
|
29
|
-
backgroundColor,
|
|
30
|
-
borderRadius: '
|
|
26
|
+
backgroundColor: paletteColor(backgroundColor)({ theme }),
|
|
27
|
+
borderRadius: '8px',
|
|
31
28
|
display: 'inline-block',
|
|
32
29
|
|
|
33
30
|
'.MuiLinearProgress-bar': {
|
|
34
|
-
backgroundColor:
|
|
31
|
+
backgroundColor: paletteColor(barColor)({ theme }),
|
|
35
32
|
},
|
|
36
33
|
})
|
|
37
34
|
);
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
export const StyledProgress = styled('div')(() => {
|
|
36
|
+
return {
|
|
37
|
+
display: 'grid',
|
|
38
|
+
gridTemplateRows: '30px 30px',
|
|
39
|
+
'.progress-info': {
|
|
40
|
+
justifyContent: 'flex-end',
|
|
41
|
+
display: 'flex',
|
|
42
|
+
alignItems: 'center',
|
|
43
|
+
},
|
|
44
|
+
'.progress-bar': {
|
|
45
|
+
display: 'flex',
|
|
46
|
+
alignItems: 'center',
|
|
47
|
+
'.MuiSvgIcon-root': {
|
|
48
|
+
padding: '0',
|
|
49
|
+
margin: '0',
|
|
50
|
+
height: '100%',
|
|
51
|
+
position: 'relative',
|
|
52
|
+
left: '-4px',
|
|
53
|
+
scale: '1.3',
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
});
|
|
@@ -1,26 +1,28 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
3
|
import { NsProgressProps } from './types';
|
|
4
|
-
import StyledLinearProgress,
|
|
4
|
+
import { StyledLinearProgress, ProgressInfo, StyledCheckCircle, StyledProgress } from './NsProgress.styled';
|
|
5
5
|
|
|
6
6
|
const NsProgress = (props: NsProgressProps) => {
|
|
7
|
-
const {
|
|
7
|
+
const { barColor, backgroundColor, height, value, body } = props;
|
|
8
8
|
return (
|
|
9
|
-
|
|
10
|
-
<
|
|
9
|
+
<StyledProgress className="ns-progress">
|
|
10
|
+
<ProgressInfo variant="p-xs" className="progress-info">
|
|
11
11
|
{value}
|
|
12
|
-
{body}
|
|
13
|
-
</
|
|
14
|
-
<
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
12
|
+
<span>{body ?? ' % Complete'}</span>
|
|
13
|
+
</ProgressInfo>
|
|
14
|
+
<div className="progress-bar">
|
|
15
|
+
<StyledLinearProgress
|
|
16
|
+
variant="determinate"
|
|
17
|
+
role="progressbar"
|
|
18
|
+
value={value}
|
|
19
|
+
height={height}
|
|
20
|
+
barColor={barColor}
|
|
21
|
+
backgroundColor={backgroundColor}
|
|
22
|
+
/>
|
|
23
|
+
<StyledCheckCircle />
|
|
24
|
+
</div>
|
|
25
|
+
</StyledProgress>
|
|
24
26
|
);
|
|
25
27
|
};
|
|
26
28
|
|
|
@@ -13,8 +13,8 @@ declare module '@mui/material/LinearProgress' {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export type NsProgressProps = {
|
|
16
|
-
|
|
17
|
-
backgroundColor?:
|
|
16
|
+
barColor?: FoundationTheme.PaletteColors;
|
|
17
|
+
backgroundColor?: FoundationTheme.PaletteColors;
|
|
18
18
|
height?: string;
|
|
19
19
|
value: number;
|
|
20
20
|
body?: ReactNode;
|
|
@@ -16,7 +16,7 @@ describe('NsRadioGroup', () => {
|
|
|
16
16
|
name: 'test',
|
|
17
17
|
label: 'I choose to signup as',
|
|
18
18
|
color: '#272525' as FoundationTheme.PaletteColors,
|
|
19
|
-
|
|
19
|
+
helperText: 'help text for more information',
|
|
20
20
|
size: 24,
|
|
21
21
|
labelFontSize: 16,
|
|
22
22
|
additionalProps: {
|
|
@@ -35,7 +35,7 @@ describe('NsRadioGroup', () => {
|
|
|
35
35
|
});
|
|
36
36
|
});
|
|
37
37
|
it('2. renders options correctly without additional slot', () => {
|
|
38
|
-
render(<NsRadioGroup {...props} onChange={onChange}
|
|
38
|
+
render(<NsRadioGroup {...props} onChange={onChange} helperText={''} />);
|
|
39
39
|
|
|
40
40
|
options.forEach((option) => {
|
|
41
41
|
const radioOption = screen.getByLabelText(option.label) as HTMLInputElement;
|
|
@@ -33,7 +33,7 @@ export default {
|
|
|
33
33
|
labelFontSize: {
|
|
34
34
|
description: 'Used to change font-size of the label',
|
|
35
35
|
},
|
|
36
|
-
|
|
36
|
+
helperText: {
|
|
37
37
|
description: 'An additional slot allows for more text',
|
|
38
38
|
},
|
|
39
39
|
},
|
|
@@ -64,7 +64,7 @@ export const RadioGroup: Story = {
|
|
|
64
64
|
name: 'test',
|
|
65
65
|
label: 'I choose to signup as',
|
|
66
66
|
color: '#272525' as FoundationTheme.PaletteColors,
|
|
67
|
-
|
|
67
|
+
helperText: 'An additional slot allows for more text',
|
|
68
68
|
size: 10,
|
|
69
69
|
labelFontSize: 16,
|
|
70
70
|
additionalProps: {
|
|
@@ -14,7 +14,7 @@ import { NsRadioGroupProps } from './types';
|
|
|
14
14
|
const NsRadioGroup = (props: NsRadioGroupProps) => {
|
|
15
15
|
const {
|
|
16
16
|
items,
|
|
17
|
-
|
|
17
|
+
helperText,
|
|
18
18
|
label,
|
|
19
19
|
onChange,
|
|
20
20
|
color,
|
|
@@ -23,6 +23,7 @@ const NsRadioGroup = (props: NsRadioGroupProps) => {
|
|
|
23
23
|
additionalProps,
|
|
24
24
|
labelFontSize,
|
|
25
25
|
darkModeEnabled = true,
|
|
26
|
+
row,
|
|
26
27
|
} = props;
|
|
27
28
|
|
|
28
29
|
return (
|
|
@@ -30,6 +31,7 @@ const NsRadioGroup = (props: NsRadioGroupProps) => {
|
|
|
30
31
|
<FormControl data-testid={additionalProps?.testid}>
|
|
31
32
|
<NsLabel size={labelFontSize}>{label}</NsLabel>
|
|
32
33
|
<StyledRadioGroup
|
|
34
|
+
row={row}
|
|
33
35
|
aria-labelledby="radio-buttons-group-label"
|
|
34
36
|
defaultValue={items?.[0]?.value}
|
|
35
37
|
name="radio-buttons-group"
|
|
@@ -50,9 +52,9 @@ const NsRadioGroup = (props: NsRadioGroupProps) => {
|
|
|
50
52
|
))}
|
|
51
53
|
</StyledRadioGroup>
|
|
52
54
|
</FormControl>
|
|
53
|
-
{
|
|
55
|
+
{helperText ? (
|
|
54
56
|
<StyledHelperText className={`ml-${size}`}>
|
|
55
|
-
<StyledSpan className="text-sm">{
|
|
57
|
+
<StyledSpan className="text-sm">{helperText}</StyledSpan>
|
|
56
58
|
</StyledHelperText>
|
|
57
59
|
) : null}
|
|
58
60
|
</>
|
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import { FoundationTheme } from '@nuskin/foundation-theme';
|
|
2
|
+
import { RadioGroupProps } from '@mui/material';
|
|
2
3
|
import { AdditionalProps } from '../common.types';
|
|
3
4
|
|
|
4
|
-
export type NsRadioGroupProps = {
|
|
5
|
-
disable
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
items: RadioItems[] ;
|
|
5
|
+
export type NsRadioGroupProps = Pick<RadioGroupProps, 'name' | 'onChange' | 'value' | 'defaultValue' | 'row'> & {
|
|
6
|
+
disable: boolean;
|
|
7
|
+
helperText: string;
|
|
8
|
+
label: string;
|
|
9
|
+
items: RadioItems[];
|
|
10
10
|
color: FoundationTheme.PaletteColors;
|
|
11
|
-
size
|
|
12
|
-
labelFontSize:number
|
|
13
|
-
onChange : () => void;
|
|
11
|
+
size: number;
|
|
12
|
+
labelFontSize: number;
|
|
14
13
|
} & AdditionalProps;
|
|
15
14
|
|
|
16
15
|
export type RadioItems = {
|
|
17
|
-
label
|
|
18
|
-
value
|
|
16
|
+
label: string;
|
|
17
|
+
value: string | number;
|
|
19
18
|
id: string | number;
|
|
20
|
-
}
|
|
19
|
+
};
|