@nuskin/foundation-ui-components 1.0.0-cft-35.13 → 1.0.0-develop.10

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 (247) hide show
  1. package/package.json +21 -11
  2. package/src/common/accordion/NsAccordion.tsx +69 -0
  3. package/src/common/accordion/NsAccordionHeader.tsx +77 -0
  4. package/src/common/accordion/NsAccordionItem.tsx +59 -0
  5. package/src/common/accordion/NsCollapse.tsx +110 -0
  6. package/src/common/accordion/NsToggleSection.tsx +43 -0
  7. package/src/common/accordion/ToggleSection.styled.tsx +32 -0
  8. package/src/common/accordion/colorMap.ts +117 -0
  9. package/src/common/accordion/enums.ts +8 -0
  10. package/src/common/accordion/index.ts +7 -0
  11. package/src/common/accordion/specs/NsAccordion.spec.tsx +163 -0
  12. package/src/common/accordion/specs/NsAccordionHeader.spec.tsx +130 -0
  13. package/src/common/accordion/specs/NsAccordionItem.spec.tsx +79 -0
  14. package/src/common/accordion/specs/NsCollapse.spec.tsx +129 -0
  15. package/src/common/accordion/specs/NsToggleSection.spec.tsx +74 -0
  16. package/src/common/accordion/stories/NsAccordion.stories.tsx +65 -0
  17. package/src/common/accordion/stories/NsAccordionHeader.stories.tsx +44 -0
  18. package/src/common/accordion/stories/NsAccordionItem.stories.tsx +45 -0
  19. package/src/common/accordion/stories/NsCollapse.stories.tsx +50 -0
  20. package/src/common/accordion/stories/NsToggleSection.stories.tsx +26 -0
  21. package/src/common/accordion/stories/data.tsx +143 -0
  22. package/src/common/accordion/types.d.ts +81 -0
  23. package/src/common/alert/Header.tsx +29 -0
  24. package/src/common/alert/NsAlert.spec.tsx +62 -29
  25. package/src/common/alert/NsAlert.stories.tsx +18 -17
  26. package/src/common/alert/NsAlert.styled.tsx +124 -0
  27. package/src/common/alert/NsAlert.tsx +27 -110
  28. package/src/common/alert/index.ts +2 -2
  29. package/src/common/alert/types.d.ts +23 -23
  30. package/src/common/auth-dropdown/NsAuthDropdown.spec.tsx +24 -6
  31. package/src/common/auth-dropdown/NsAuthDropdown.stories.tsx +2 -2
  32. package/src/common/auth-dropdown/NsAuthDropdown.styled.ts +21 -16
  33. package/src/common/auth-dropdown/NsAuthDropdown.tsx +7 -6
  34. package/src/common/auth-dropdown/index.ts +1 -1
  35. package/src/common/auth-dropdown/types.d.ts +3 -1
  36. package/src/common/autocomplete/NsAutocomplete.spec.tsx +69 -24
  37. package/src/common/autocomplete/NsAutocomplete.stories.tsx +64 -7
  38. package/src/common/autocomplete/NsAutocomplete.styled.tsx +12 -0
  39. package/src/common/autocomplete/NsAutocomplete.tsx +100 -46
  40. package/src/common/autocomplete/index.ts +2 -1
  41. package/src/common/autocomplete/mock/MockData.ts +50 -7
  42. package/src/common/autocomplete/mock/MockUI.tsx +2 -1
  43. package/src/common/autocomplete/{types.ts → types.d.ts} +18 -8
  44. package/src/common/banner/NsBanner.spec.tsx +13 -4
  45. package/src/common/banner/NsBanner.stories.tsx +2 -2
  46. package/src/common/banner/NsBanner.styled.tsx +1 -1
  47. package/src/common/banner/NsBanner.tsx +1 -1
  48. package/src/common/banner/index.ts +1 -1
  49. package/src/common/brand-components/NsBrand.stories.tsx +2 -2
  50. package/src/common/brand-components/NsBrandComponent.tsx +6 -3
  51. package/src/common/brand-components/index.ts +1 -1
  52. package/src/common/breadcrumb/NsBreadcrumb.spec.tsx +8 -9
  53. package/src/common/breadcrumb/NsBreadcrumb.stories.tsx +3 -5
  54. package/src/common/breadcrumb/NsBreadcrumb.tsx +5 -3
  55. package/src/common/breadcrumb/data.ts +10 -0
  56. package/src/common/breadcrumb/index.ts +1 -1
  57. package/src/common/button/NsButton.spec.tsx +66 -51
  58. package/src/common/button/NsButton.stories.tsx +61 -4
  59. package/src/common/button/NsButton.styled.tsx +54 -72
  60. package/src/common/button/NsButton.tsx +9 -3
  61. package/src/common/button/helper.ts +82 -0
  62. package/src/common/button/index.ts +1 -1
  63. package/src/common/button/types.d.ts +3 -0
  64. package/src/common/card/NsFfgCard.tsx +14 -8
  65. package/src/common/card/specs/NsFfgCard.spec.tsx +33 -0
  66. package/src/common/card/stories/NsBgCard.stories.tsx +2 -4
  67. package/src/common/card/stories/NsBrandProductCard.stories.tsx +2 -2
  68. package/src/common/card/stories/NsFfgCard.stories.tsx +49 -16
  69. package/src/common/card/stories/{data.js → data.ts} +1 -25
  70. package/src/common/card/styled/NsFfgStyled.tsx +9 -7
  71. package/src/common/card/types.d.ts +7 -4
  72. package/src/common/carousal/NsScrollingCarousal.tsx +61 -0
  73. package/src/common/carousal/index.ts +3 -0
  74. package/src/common/carousal/{tests → specs}/NsCarousal.spec.tsx +2 -2
  75. package/src/common/carousal/specs/NsScrollingCarousal.spec.tsx +61 -0
  76. package/src/common/carousal/stories/NSCarousal.stories.tsx +2 -2
  77. package/src/common/carousal/stories/NsScrollingCarousal.stories.tsx +52 -0
  78. package/src/common/carousal/types.d.ts +23 -0
  79. package/src/common/cart-icon/NsCartIcon.spec.tsx +1 -1
  80. package/src/common/cart-icon/NsCartIcon.stories.tsx +2 -2
  81. package/src/common/cart-icon/NsCartIcon.tsx +1 -1
  82. package/src/common/cart-icon/index.ts +1 -1
  83. package/src/common/checkbox/NsCheckbox.spec.tsx +2 -2
  84. package/src/common/checkbox/NsCheckbox.stories.tsx +2 -2
  85. package/src/common/checkbox/NsCheckbox.styled.tsx +15 -16
  86. package/src/common/checkbox/NsCheckbox.tsx +2 -2
  87. package/src/common/checkbox/index.ts +1 -1
  88. package/src/common/checkbox/types.d.ts +1 -7
  89. package/src/common/column-control/NsColumnControl.tsx +1 -1
  90. package/src/common/column-control/NsFlexColumns.tsx +22 -0
  91. package/src/common/column-control/NsGridColumns.tsx +22 -0
  92. package/src/common/column-control/index.ts +3 -1
  93. package/src/common/column-control/{NsColumnControl.spec.tsx → specs/NsColumnControl.spec.tsx} +3 -3
  94. package/src/common/column-control/specs/NsFlexColumns.spec.tsx +24 -0
  95. package/src/common/column-control/specs/NsGridColumns.spec.tsx +24 -0
  96. package/src/common/column-control/stories/DivArray.stories.tsx +18 -0
  97. package/src/common/column-control/stories/DivArray.tsx +63 -0
  98. package/src/common/column-control/{NsColumnControl.stories.tsx → stories/NsColumnControl.stories.tsx} +9 -16
  99. package/src/common/column-control/stories/NsFlexColumns.stories.tsx +63 -0
  100. package/src/common/column-control/stories/NsGridColumns.stories.tsx +63 -0
  101. package/src/common/column-control/stories/common.tsx +14 -0
  102. package/src/common/column-control/styled/StyledFlex.tsx +45 -0
  103. package/src/common/column-control/styled/StyledGrid.tsx +40 -0
  104. package/src/common/column-control/styled/common.ts +27 -0
  105. package/src/common/column-control/types.d.ts +15 -16
  106. package/src/common/column-control/utils.ts +5 -5
  107. package/src/common/common.types.d.ts +21 -0
  108. package/src/common/dropdown/NsDropdown.spec.tsx +1 -1
  109. package/src/common/dropdown/NsDropdown.styled.tsx +23 -18
  110. package/src/common/dropdown/NsDropdown.tsx +1 -1
  111. package/src/common/dropdown/NsDropdownOption.tsx +1 -1
  112. package/src/common/dropdown/index.ts +1 -1
  113. package/src/common/dropdown/stories/NsDropdown.stories.tsx +2 -2
  114. package/src/common/dropdown/stories/NsDropdownCountry.stories.tsx +2 -2
  115. package/src/common/dropdown/types.d.ts +3 -1
  116. package/src/common/email-simple/NsEmailSimple.spec.tsx +145 -0
  117. package/src/common/email-simple/NsEmailSimple.stories.tsx +61 -0
  118. package/src/common/email-simple/NsEmailSimple.tsx +71 -0
  119. package/src/common/email-simple/index.ts +2 -0
  120. package/src/common/email-simple/types.d.ts +14 -0
  121. package/src/common/flag/NsFlag.spec.tsx +5 -25
  122. package/src/common/flag/NsFlag.stories.tsx +2 -2
  123. package/src/common/flag/NsFlag.styled.tsx +7 -9
  124. package/src/common/flag/NsFlag.tsx +1 -3
  125. package/src/common/flag/index.ts +1 -1
  126. package/src/common/flag/types.d.ts +0 -2
  127. package/src/common/hooks/index.ts +2 -0
  128. package/src/common/hooks/specs/useWindowSize.spec.tsx +19 -0
  129. package/src/common/hooks/useAccordionMap.tsx +39 -0
  130. package/src/common/hooks/useWindowSize.tsx +30 -0
  131. package/src/common/icon/NsIcon.spec.tsx +1 -1
  132. package/src/common/icon/NsIcon.stories.tsx +2 -2
  133. package/src/common/icon/NsIcon.styled.tsx +1 -1
  134. package/src/common/icon/NsIcon.tsx +1 -1
  135. package/src/common/icon/NsIconVariants.ts +9 -4
  136. package/src/common/icon/icons/AlertErrorIcon.tsx +15 -6
  137. package/src/common/icon/icons/HamburgerIcon.tsx +29 -0
  138. package/src/common/icon/icons/UserIcon.tsx +30 -0
  139. package/src/common/icon/icons/WarningIcon.tsx +14 -5
  140. package/src/common/icon/index.ts +1 -1
  141. package/src/common/icon/types.d.ts +1 -0
  142. package/src/common/image/NsImage.spec.tsx +57 -7
  143. package/src/common/image/NsImage.stories.tsx +2 -2
  144. package/src/common/image/NsImage.tsx +24 -12
  145. package/src/common/image/NsNextImage.spec.tsx +1 -1
  146. package/src/common/image/NsNextImage.stories.tsx +2 -2
  147. package/src/common/image/NsNextImage.tsx +1 -1
  148. package/src/common/image/index.ts +1 -1
  149. package/src/common/image/types.d.ts +1 -0
  150. package/src/common/index.ts +14 -10
  151. package/src/common/input/InputFieldWrapper.tsx +4 -4
  152. package/src/common/input/InputWrapper.tsx +12 -7
  153. package/src/common/input/NsInputField.stories.tsx +13 -10
  154. package/src/common/input/NsInputField.tsx +13 -6
  155. package/src/common/input/getAdornmentProps.tsx +5 -1
  156. package/src/common/input/index.ts +1 -1
  157. package/src/common/input/types.d.ts +18 -1
  158. package/src/common/label/NsLabel.stories.tsx +6 -1
  159. package/src/common/label/NsLabel.tsx +21 -20
  160. package/src/common/label/index.ts +1 -1
  161. package/src/common/label/types.d.ts +2 -1
  162. package/src/common/link/NsLink.spec.tsx +1 -1
  163. package/src/common/link/NsLink.stories.tsx +2 -2
  164. package/src/common/link/NsLink.tsx +1 -1
  165. package/src/common/link/index.ts +1 -1
  166. package/src/common/modal/NsModal.spec.tsx +46 -0
  167. package/src/common/modal/NsModal.styled.tsx +28 -0
  168. package/src/common/modal/NsModal.tsx +37 -0
  169. package/src/common/modal/helper-component/NsModalContentBox.tsx +32 -0
  170. package/src/common/modal/helper-component/NsModalDefault.tsx +25 -0
  171. package/src/common/modal/helper-component/NsModalStatus.tsx +15 -0
  172. package/src/common/modal/helper-component/NsModalStatusIcon.tsx +14 -0
  173. package/src/common/modal/helper-component/NsModalTitle.tsx +26 -0
  174. package/src/common/modal/index.ts +2 -0
  175. package/src/common/modal/model/NsModalVariantMap.tsx +24 -0
  176. package/src/common/modal/stories/NsModal.stories.tsx +86 -0
  177. package/src/common/modal/stories/mock.tsx +46 -0
  178. package/src/common/modal/types.ts +56 -0
  179. package/src/common/nav-product-card/NsNavProductCard.spec.tsx +1 -1
  180. package/src/common/nav-product-card/NsNavProductCard.stories.tsx +2 -2
  181. package/src/common/nav-product-card/NsNavProductCard.tsx +1 -1
  182. package/src/common/nav-product-card/index.ts +1 -1
  183. package/src/common/nav-tab/NsNavTab.spec.tsx +2 -7
  184. package/src/common/nav-tab/NsNavTab.stories.tsx +2 -2
  185. package/src/common/nav-tab/NsNavTab.styled.tsx +7 -4
  186. package/src/common/nav-tab/NsNavTab.tsx +1 -1
  187. package/src/common/nav-tab/index.ts +1 -1
  188. package/src/common/nav-tab/types.d.ts +2 -2
  189. package/src/common/radiogroup/NsRadioGroup.spec.tsx +63 -0
  190. package/src/common/radiogroup/NsRadioGroup.stories.tsx +84 -0
  191. package/src/common/radiogroup/NsRadioGroup.styled.tsx +52 -0
  192. package/src/common/radiogroup/NsRadioGroup.tsx +62 -0
  193. package/src/common/radiogroup/index.ts +2 -0
  194. package/src/common/radiogroup/types.d.ts +20 -0
  195. package/src/common/search-bar/NsSeachBar.spec.tsx +1 -1
  196. package/src/common/search-bar/NsSearchBar.tsx +1 -3
  197. package/src/common/select/NsSelect.spec.tsx +193 -0
  198. package/src/common/select/NsSelect.styled.tsx +104 -0
  199. package/src/common/select/NsSelect.tsx +117 -0
  200. package/src/common/select/NsSelectOption.tsx +30 -0
  201. package/src/common/select/index.ts +3 -0
  202. package/src/common/select/stories/NsSelect.stories.tsx +134 -0
  203. package/src/common/select/types.d.ts +34 -0
  204. package/src/common/spinner/NsSpinner.spec.tsx +21 -0
  205. package/src/common/spinner/NsSpinner.stories.tsx +26 -0
  206. package/src/common/spinner/NsSpinner.styled.tsx +344 -0
  207. package/src/common/spinner/NsSpinner.tsx +14 -0
  208. package/src/common/spinner/icons/Spinner.tsx +161 -0
  209. package/src/common/spinner/index.ts +2 -0
  210. package/src/common/spinner/types.ts +5 -0
  211. package/src/common/table/NsExpandableRow.tsx +68 -0
  212. package/src/common/table/NsTable.spec.tsx +174 -0
  213. package/src/common/table/NsTable.stories.tsx +161 -0
  214. package/src/common/table/NsTable.styled.ts +127 -0
  215. package/src/common/table/NsTable.tsx +133 -0
  216. package/src/common/table/NsTableHeader.tsx +41 -0
  217. package/src/common/table/NsTablePagination.tsx +28 -0
  218. package/src/common/table/helper.ts +33 -0
  219. package/src/common/table/index.ts +2 -0
  220. package/src/common/table/types.d.ts +57 -0
  221. package/src/common/text-strip/NsTextStrip.spec.tsx +30 -0
  222. package/src/common/text-strip/NsTextStrip.stories.tsx +33 -0
  223. package/src/common/text-strip/NsTextStrip.tsx +47 -0
  224. package/src/common/text-strip/index.ts +2 -0
  225. package/src/common/text-strip/types.d.ts +17 -0
  226. package/src/common/typography/NsTypography.stories.tsx +2 -2
  227. package/src/common/typography/NsTypography.tsx +1 -1
  228. package/src/common/typography/Typography.styled.tsx +4 -4
  229. package/src/common/typography/index.ts +1 -1
  230. package/src/common/util.ts +1 -0
  231. package/src/common/utility/Show.tsx +13 -0
  232. package/src/common/utility/index.ts +1 -0
  233. package/src/common/validations/regex.ts +3 -0
  234. package/src/common/videos/NsVideo.stories.tsx +2 -2
  235. package/src/common/videos/NsVideo.tsx +1 -1
  236. package/src/common/videos/index.ts +1 -1
  237. package/src/common/videos/types.d.ts +1 -1
  238. package/src/common/alert/NsAlert.styled.ts +0 -124
  239. package/src/common/card/tests/NsFfgCard.spec.tsx +0 -23
  240. package/src/common/column-control/NDivs.story.tsx +0 -35
  241. package/src/common/common.types.ts +0 -10
  242. /package/src/common/brand-components/{NsBrandContanier.styled.tsx → NsBrandContainer.styled.tsx} +0 -0
  243. /package/src/common/card/{tests → specs}/BrandLogo.spec.tsx +0 -0
  244. /package/src/common/card/{tests → specs}/NsBgCard.spec.tsx +0 -0
  245. /package/src/common/card/{tests → specs}/NsBrandProductCard.spec.tsx +0 -0
  246. /package/src/common/carousal/{tests → specs}/Chevron.spec.tsx +0 -0
  247. /package/src/common/carousal/{tests → specs}/RenderBrand.spec.tsx +0 -0
@@ -0,0 +1,86 @@
1
+ import type { StoryObj, Meta } from '@storybook/react';
2
+ import { withCenterDecorator } from '@/stories/decorators/withCenterDecorator';
3
+ import NsModal from '../NsModal';
4
+ import { NsButton } from '../../button';
5
+ import { Grid, Typography } from '@mui/material';
6
+ import { useState } from 'react';
7
+ import { NsModalProps } from '../types';
8
+ import { NsModalData } from './mock';
9
+
10
+ type ComponentType = typeof NsModal;
11
+ type Story = StoryObj<ComponentType>;
12
+ type MetaStory = Meta<ComponentType>;
13
+
14
+ export default {
15
+ title: 'Components/NsModal',
16
+ component: NsModal,
17
+ decorators: [withCenterDecorator],
18
+ argTypes: {},
19
+ args: {
20
+ ...NsModalData,
21
+ },
22
+ } as MetaStory;
23
+
24
+ const RenderNsModal = (args: NsModalProps) => {
25
+ const [isOpen, setOpen] = useState(false);
26
+
27
+ const onModalHandler = () => {
28
+ setOpen(!isOpen);
29
+ };
30
+
31
+ return (
32
+ <>
33
+ <NsButton onClick={onModalHandler}>Open Modal</NsButton>
34
+ <NsModal {...args} open={isOpen} handleClose={onModalHandler} />
35
+ </>
36
+ );
37
+ };
38
+
39
+ export const Modal: Story = {
40
+ args: {
41
+ header: {
42
+ ...NsModalData?.header,
43
+ isCloseIcon: false,
44
+ },
45
+ } as NsModalProps,
46
+ render: RenderNsModal,
47
+ };
48
+
49
+ export const WithCloseIcon: Story = {
50
+ render: RenderNsModal,
51
+ };
52
+
53
+ export const ImageWidthText: Story = {
54
+ args: {
55
+ header: {
56
+ show: true,
57
+ isCloseIcon: true,
58
+ },
59
+ body: {
60
+ show: true,
61
+ children: (
62
+ <Grid container spacing={2}>
63
+ <Grid xs={6}>
64
+ <img
65
+ src="https://www.nuskin.com/content/products/01/55/00/01550014/_jcr_content/fullImage.img.160.160.png.64.64.png"
66
+ alt={'NsImage'}
67
+ />
68
+ </Grid>
69
+ <Grid xs={6} className="p-5">
70
+ <Typography gutterBottom variant="h5" component="div">
71
+ Lizard
72
+ </Typography>
73
+ <Typography variant="body2" color="text.secondary">
74
+ Lizards are a widespread group of squamate reptiles, with over 6,000 species, ranging across
75
+ all continents except Antarctica
76
+ </Typography>
77
+ </Grid>
78
+ </Grid>
79
+ ),
80
+ },
81
+ footer: {
82
+ show: false,
83
+ },
84
+ },
85
+ render: RenderNsModal,
86
+ };
@@ -0,0 +1,46 @@
1
+ import { NsButton } from '../../button';
2
+ import { NsTypography } from '../../typography';
3
+
4
+ export const NsModalData = {
5
+ open: true,
6
+ handleClose: () => {},
7
+ variant: 'default',
8
+ header: {
9
+ show: true,
10
+ children: (
11
+ <NsTypography variant="h4" weight="bold">
12
+ Dialog with hero icon
13
+ </NsTypography>
14
+ ),
15
+ isCloseIcon: true,
16
+ iconName: 'infoOutlined',
17
+ },
18
+ body: {
19
+ show: true,
20
+ children: (
21
+ <NsTypography variant="p-s">
22
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquet sed odio donec tellus nibh dictum quis.
23
+ Dis tempus aliquam tristique auctor justo, lacus in pellentesque. Quam semper facilisi posuere hendrerit
24
+ scelerisque sed.
25
+ </NsTypography>
26
+ ),
27
+ },
28
+ statusInfo: {
29
+ title: 'Are you sure you want to delete your account?',
30
+ description: `Lorem ipsum dolor sit amet, consectetur adipiscing elit,
31
+ sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.`,
32
+ },
33
+ footer: {
34
+ show: true,
35
+ children: (
36
+ <>
37
+ <NsButton onClick={() => {}} variant="outlined">
38
+ Cancel
39
+ </NsButton>
40
+ <NsButton onClick={() => {}} variant="contained">
41
+ Confirm
42
+ </NsButton>
43
+ </>
44
+ ),
45
+ },
46
+ };
@@ -0,0 +1,56 @@
1
+ import { ReactNode } from 'react';
2
+ import { NsIconNameType } from '../icon';
3
+
4
+ export interface DialogTitleProps {
5
+ id: string;
6
+ children?: ReactNode;
7
+ onClose: () => void;
8
+ }
9
+
10
+ export interface NsModalProps extends NsModalComponentProps {
11
+ open: boolean;
12
+ }
13
+
14
+ export interface NsModalComponentProps {
15
+ handleClose?: () => void;
16
+ additionalProps?: NsModalAdditionalProps;
17
+ variant?: NsModalVariant | 'default';
18
+ header?: NsModalContentProps;
19
+ body?: NsModalContentProps;
20
+ footer?: NsModalContentProps;
21
+ statusInfo?: NsModalStatusProps;
22
+ }
23
+
24
+ export interface NsModalContentProps {
25
+ show?: boolean;
26
+ children?: string | ReactNode;
27
+ isCloseIcon?: boolean;
28
+ iconName?: NsIconNameType;
29
+ }
30
+
31
+ export interface NsModalStatusProps {
32
+ title: string;
33
+ description: string;
34
+ }
35
+
36
+ export interface NsModalAdditionalProps {
37
+ className?: string;
38
+ scrollType?: 'paper' | 'body';
39
+ ariaLabel?: NsModalAriaLabelProps;
40
+ dividers?: boolean;
41
+ }
42
+
43
+ export interface NsModalAriaLabelProps {
44
+ ariaLabelledby?: string;
45
+ ariaDescribedby?: string;
46
+ }
47
+
48
+ export type NsModalVariant = 'success' | 'warning' | 'error' | 'info';
49
+
50
+ export interface StatusIconMapProps {
51
+ success: string;
52
+ warning: string;
53
+ error: string;
54
+ info: string;
55
+ default?: string;
56
+ }
@@ -1,5 +1,5 @@
1
1
  import { NsNavProductCard } from '.';
2
- import { render } from '../../../test-utils';
2
+ import { render } from '@/test-utils/index';
3
3
 
4
4
  const productImage = `
5
5
  https://media.nuskin.com/m/471880e8f6e689f4/Lumi-IO-normal-combo-cleansing-device-and-cleanser.png
@@ -1,5 +1,5 @@
1
1
  import type { StoryObj, Meta } from '@storybook/react';
2
- import { withCenterDecorator } from '../../stories/decorators/withCenterDecorator';
2
+ import { withCenterDecorator } from '@/stories/decorators/withCenterDecorator';
3
3
  import { NsNavProductCard } from './';
4
4
 
5
5
  type ComponentType = typeof NsNavProductCard;
@@ -7,7 +7,7 @@ type Story = StoryObj<ComponentType>;
7
7
  type MetaStory = Meta<ComponentType>;
8
8
 
9
9
  export default {
10
- title: 'Components/NsNavProductCard',
10
+ title: 'Components/Navigation/NsNavProductCard',
11
11
  component: NsNavProductCard,
12
12
  decorators: [withCenterDecorator],
13
13
  args: {
@@ -2,7 +2,7 @@
2
2
  import React, { PropsWithChildren } from 'react';
3
3
  import { NsImage, NsTypography } from '../';
4
4
  import { ProductCardContainer } from './NsNavProductCard.styled';
5
- import { NsNavProductCardProps } from './types';
5
+ import { NsNavProductCardProps } from './types.d';
6
6
 
7
7
  /* TODO: can we update NsImage with NsNextImage, once storybook 7 is in place */
8
8
  export const NsNavProductCard = ({
@@ -1,2 +1,2 @@
1
1
  export { NsNavProductCard as NsNavProductCard } from './NsNavProductCard';
2
- export type { NsNavProductCardProps } from './types';
2
+ export type { NsNavProductCardProps } from './types.d';
@@ -1,10 +1,7 @@
1
1
  import { fireEvent } from '@testing-library/react';
2
- import nuskinTheme from '@nuskin/foundation-theme/src/themes/genome-foundation';
3
2
  import { NsNavTabComponent } from './NsNavTab';
4
- import { NavTabs } from './types';
5
- import { render } from '../../../test-utils';
6
-
7
- const { palette } = nuskinTheme;
3
+ import { NavTabs } from './types.d';
4
+ import { render } from '@/test-utils/index';
8
5
 
9
6
  const tabs: NavTabs[] = [
10
7
  {
@@ -54,7 +51,6 @@ describe('Nav Bar Component', () => {
54
51
  expect(li.length).toBe(4);
55
52
  li.forEach((list, i) => expect(list).toHaveTextContent(tabs[i].tabName));
56
53
  expect(container).toBeInTheDocument();
57
- expect(getByTestId('Skin & Beauty-list').firstChild).toHaveStyle(`color: ${palette.primary.main}`);
58
54
  fireEvent.mouseOver(getByTestId('Skin & Beauty'));
59
55
  expect(getByTestId('nav-drawer')).toBeInTheDocument();
60
56
  fireEvent.mouseLeave(getByTestId('Skin & Beauty'));
@@ -65,6 +61,5 @@ describe('Nav Bar Component', () => {
65
61
  const { getByTestId } = render(<NsNavTabComponent showDrawer={false} className="mb-2" tabs={tabs} />);
66
62
  fireEvent.mouseOver(getByTestId('Skin & Beauty'));
67
63
  expect(getByTestId('underline')).toBeInTheDocument();
68
- expect(getByTestId('underline')).toHaveStyle(`background-color: ${palette.success.main}`);
69
64
  });
70
65
  });
@@ -1,5 +1,5 @@
1
1
  import type { StoryObj, Meta } from '@storybook/react';
2
- import { withCenterDecorator } from '../../stories/decorators/withCenterDecorator';
2
+ import { withCenterDecorator } from '@/stories/decorators/withCenterDecorator';
3
3
  import { NsNavTab } from './';
4
4
 
5
5
  type ComponentType = typeof NsNavTab;
@@ -7,7 +7,7 @@ type Story = StoryObj<ComponentType>;
7
7
  type MetaStory = Meta<ComponentType>;
8
8
 
9
9
  export default {
10
- title: 'Components/NsNavTab',
10
+ title: 'Components/Navigation/NsNavTab',
11
11
  component: NsNavTab,
12
12
  decorators: [withCenterDecorator],
13
13
  argTypes: {
@@ -1,6 +1,9 @@
1
- import { FoundationTheme, styled } from '@nuskin/foundation-theme';
1
+ import { FoundationTheme, styled, ColorUtils } from '@nuskin/foundation-theme';
2
2
  import { motion } from 'framer-motion';
3
3
 
4
+ const { paletteColor } = ColorUtils;
5
+
6
+
4
7
  export const NavTabContainer = styled.div`
5
8
  .shadow {
6
9
  box-shadow: 0 2px 3px 0 rgba(0, 0, 0, 0.15);
@@ -23,7 +26,7 @@ export const NavTabUnderLine = styled(motion.div)<{ color?: FoundationTheme.Pale
23
26
  position: absolute;
24
27
  bottom: -2px;
25
28
  height: 2px;
26
- background-color: ${({ theme: { palette }, color = 'primary' }) => palette?.[color]?.main};
29
+ background-color: ${({ theme, color = 'primary' }) => paletteColor(color)({ theme })};
27
30
  `;
28
31
 
29
32
  export const NavDrawer = styled.div`
@@ -37,7 +40,7 @@ export const NavDrawer = styled.div`
37
40
  width: 100%;
38
41
  max-height: 590px;
39
42
 
40
- background-color: ${({ theme }) => theme?.palette?.primary.contrastText};
43
+ background-color: ${paletteColor('primary', 'contrastText')};
41
44
  box-shadow: 0 2px 3px 0 rgba(0, 0, 0, 0.15);
42
45
  transition: all 0.15s ease-in-out;
43
46
  overflow: hidden;
@@ -54,7 +57,7 @@ export const NavDrawerContainer = styled(motion.div)`
54
57
  z-index: 1;
55
58
  }
56
59
  box-shadow: 0 2px 3px 0 rgba(0, 0, 0, 0.15);
57
- background-color: ${({ theme }) => theme?.palette?.primary.contrastText};
60
+ background-color: ${paletteColor('primary', 'contrastText')};
58
61
  width: 100%;
59
62
  text-align: left;
60
63
  max-height: 590px;
@@ -2,7 +2,7 @@ import React, { PropsWithChildren, useState } from 'react';
2
2
  import { LayoutGroup } from 'framer-motion';
3
3
  import { NsTypography } from '../typography';
4
4
  import { NavDrawerContainer, NavTabContainer, NavTabLine, NavTabUnderLine, NavDrawer } from './NsNavTab.styled';
5
- import { NSNavTabComponentProps } from './types';
5
+ import { NSNavTabComponentProps } from './types.d';
6
6
 
7
7
  export const NsNavTabComponent = (props: PropsWithChildren<NSNavTabComponentProps>) => {
8
8
  const { tabs, className, tabTitleClassName, showDrawer = true } = props;
@@ -1,2 +1,2 @@
1
1
  export { NsNavTabComponent as NsNavTab } from './NsNavTab';
2
- export type { NSNavTabComponentProps, NavTabs } from './types';
2
+ export type { NSNavTabComponentProps, NavTabs } from './types.d';
@@ -1,7 +1,7 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { FoundationTheme } from '@nuskin/foundation-theme';
3
3
  import { Variants } from '../typography/types';
4
- import { AdditionalProps, ContentStackLiveTags } from '../common.types';
4
+ import { AdditionalProps, CslpTag } from '../common.types';
5
5
 
6
6
  export type NavTabs = {
7
7
  tabName: string;
@@ -9,7 +9,7 @@ export type NavTabs = {
9
9
  activeColor: FoundationTheme.PaletteColors;
10
10
  color?: FoundationTheme.PaletteColors;
11
11
  textVariant: Variants;
12
- liveTag?: ContentStackLiveTags;
12
+ liveTag?: CslpTag;
13
13
  };
14
14
 
15
15
  export type NSNavTabComponentProps = {
@@ -0,0 +1,63 @@
1
+ import React from 'react';
2
+ import { render, fireEvent, screen } from '@testing-library/react';
3
+ import { NsRadioGroup } from './';
4
+ import { FoundationTheme } from '@nuskin/foundation-theme';
5
+
6
+ describe('NsRadioGroup', () => {
7
+ const options = [
8
+ { id: 'Option1', label: 'Option 1', value: 'Option1' },
9
+ { id: 'Option2', label: 'Option 2', value: 'Option2' },
10
+ { id: 'Option3', label: 'Option 3', value: 'Option3' },
11
+ ];
12
+
13
+ const props = {
14
+ disable: false,
15
+ items: options,
16
+ name: 'test',
17
+ label: 'I choose to signup as',
18
+ color: '#272525' as FoundationTheme.PaletteColors,
19
+ additionalSlot: 'An additional slot allows for more text',
20
+ size: 24,
21
+ labelFontSize: 16,
22
+ additionalProps: {
23
+ testid: 'radio-group',
24
+ },
25
+ };
26
+ const onChange = jest.fn();
27
+
28
+ it('1. renders options correctly', () => {
29
+ render(<NsRadioGroup {...props} onChange={onChange} />);
30
+
31
+ options.forEach((option) => {
32
+ const radioOption = screen.getByLabelText(option.label) as HTMLInputElement;
33
+ expect(radioOption).toBeInTheDocument();
34
+ expect(radioOption.value).toBe(option.value);
35
+ });
36
+ });
37
+ it('2. renders options correctly without additional slot', () => {
38
+ render(<NsRadioGroup {...props} onChange={onChange} additionalSlot={''} />);
39
+
40
+ options.forEach((option) => {
41
+ const radioOption = screen.getByLabelText(option.label) as HTMLInputElement;
42
+ expect(radioOption).toBeInTheDocument();
43
+ expect(radioOption.value).toBe(option.value);
44
+ });
45
+ });
46
+
47
+ it('3. calls OnChange when selecting option', () => {
48
+ render(<NsRadioGroup {...props} onChange={onChange} />);
49
+
50
+ const radioOption = screen.getByLabelText('Option 2') as HTMLInputElement;
51
+ fireEvent.click(radioOption);
52
+ expect(onChange).toHaveBeenCalledTimes(1);
53
+ });
54
+
55
+ it('4. does not call Onchange when the same option is clicked', () => {
56
+ const onChange = jest.fn();
57
+ render(<NsRadioGroup {...props} onChange={onChange} />);
58
+
59
+ const radioOption = screen.getByLabelText('Option 1') as HTMLInputElement;
60
+ fireEvent.click(radioOption);
61
+ expect(onChange).not.toHaveBeenCalled();
62
+ });
63
+ });
@@ -0,0 +1,84 @@
1
+ import type { StoryObj, Meta } from '@storybook/react';
2
+ import { within, userEvent } from '@storybook/testing-library';
3
+ import { expect } from '@storybook/jest';
4
+ import { NsRadioGroup } from './';
5
+ import { FoundationTheme } from '@nuskin/foundation-theme';
6
+
7
+ type ComponentType = typeof NsRadioGroup;
8
+ type Story = StoryObj<ComponentType>;
9
+ type MetaStory = Meta<ComponentType>;
10
+
11
+ export default {
12
+ component: NsRadioGroup,
13
+ title: 'Components/Inputs/NsRadioGroup',
14
+ argTypes: {
15
+ disable: {
16
+ description: 'Indicates whether the radio button is enabled/disabled',
17
+ },
18
+ items: {
19
+ description: 'Value of the component to be emitted when selected.',
20
+ },
21
+ name: {
22
+ description: 'Name of the component',
23
+ },
24
+ label: {
25
+ description: 'Label of the radio group',
26
+ },
27
+ color: {
28
+ description: 'Color of the radio button',
29
+ },
30
+ size: {
31
+ description: 'Margin Left for Additional Slot text',
32
+ },
33
+ labelFontSize: {
34
+ description: 'Used to change font-size of the label',
35
+ },
36
+ additionalSlot: {
37
+ description: 'An additional slot allows for more text',
38
+ },
39
+ },
40
+ } as MetaStory;
41
+
42
+ export const RadioGroup: Story = {
43
+ args: {
44
+ disable: false,
45
+ items: [
46
+ {
47
+ id: 'individual',
48
+ label: `Vendeur à domicile indépendant mandataire (The VDI mandataire
49
+ enters into sales or service agreements
50
+ with customers in the name and on behalf of the company.
51
+ His remuneration will be based on commissions made
52
+ on the sales of products to customers.)`,
53
+ value: 'individual',
54
+ },
55
+ {
56
+ id: ' retailer',
57
+ label: `Vendeur à domicile indépendant acheteur-revendeur
58
+ (The VDI acheteur-revendeur sells the company's products in his own name and behalf.
59
+ His remuneration will be based on commissions and on the margins made on the sales of
60
+ products to customers.)`,
61
+ value: 'retailer',
62
+ },
63
+ ],
64
+ name: 'test',
65
+ label: 'I choose to signup as',
66
+ color: '#272525' as FoundationTheme.PaletteColors,
67
+ additionalSlot: 'An additional slot allows for more text',
68
+ size: 10,
69
+ labelFontSize: 16,
70
+ additionalProps: {
71
+ testid: 'radio-group',
72
+ },
73
+ },
74
+ play: async ({ canvasElement }) => {
75
+ const canvas = within(canvasElement);
76
+ await userEvent.hover(canvas.getByTestId('radio-group'));
77
+ await expect(
78
+ canvas.getByText(
79
+ // eslint-disable-next-line max-len
80
+ 'Vendeur à domicile indépendant mandataire (The VDI mandataire enters into sales or service agreements with customers in the name and on behalf of the company. His remuneration will be based on commissions made on the sales of products to customers.)'
81
+ )
82
+ ).toBeInTheDocument();
83
+ },
84
+ };
@@ -0,0 +1,52 @@
1
+ import { Radio, FormControlLabel, FormLabel, RadioGroup } from '@mui/material';
2
+ import { ColorUtils, FoundationTheme, styled } from '@nuskin/foundation-theme';
3
+ import { skipDarkModeEnabled } from '../util';
4
+
5
+ const { paletteColor, isDarkMode, color } = ColorUtils;
6
+
7
+ export const StyledHelperText = styled('div')`
8
+ margin-top :10px;
9
+ padding-left: 0.5em;
10
+ text-align: left;
11
+ justify-self: flex-start;
12
+ )`;
13
+
14
+ export const StyledSpan = styled('span')`
15
+ font-size: '16px';
16
+ font-weight: 300;
17
+ color: ${paletteColor('primary')};
18
+ `;
19
+
20
+ export const StyledLabel = styled(FormLabel)`
21
+ color: ${paletteColor('primary')},
22
+ marginBottom: '15px',
23
+ backgroundColor: 'transparent',
24
+ `;
25
+
26
+ export const StyledRadio = styled(Radio)`
27
+ color: ${(props) => color('primary', !isDarkMode(props) ? 'black' : 'white')(props)};
28
+ `;
29
+
30
+ export const StyledFormControlLabel = styled(FormControlLabel)<{ darkModeEnabled?: boolean }>((props) => {
31
+ return {
32
+ color: paletteColor('primary')(props),
33
+ marginBottom: '10px',
34
+ '.MuiFormControlLabel-label.Mui-disabled': {
35
+ color: `${color('neutral', !isDarkMode(props) ? 60 : 20)(props)}`,
36
+ },
37
+ };
38
+ });
39
+ const options = {
40
+ shouldForwardProp: skipDarkModeEnabled,
41
+ };
42
+ export const StyledRadioGroup = styled(
43
+ RadioGroup,
44
+ options
45
+ )<{ color: FoundationTheme.PaletteColors; darkModeEnabled?: boolean }>(({ theme, color, darkModeEnabled }) => {
46
+ return {
47
+ marginTop: '10px',
48
+ '.MuiRadio-root.custom-radio.Mui-checked': {
49
+ color: paletteColor(color)({ theme, darkModeEnabled }),
50
+ },
51
+ };
52
+ });
@@ -0,0 +1,62 @@
1
+ import { FormControl } from '@mui/material';
2
+
3
+ import {
4
+ StyledHelperText,
5
+ StyledFormControlLabel,
6
+ StyledRadio,
7
+ StyledSpan,
8
+ StyledRadioGroup,
9
+ } from './NsRadioGroup.styled';
10
+ import { NsLabel } from '../label';
11
+
12
+ import { NsRadioGroupProps } from './types';
13
+
14
+ const NsRadioGroup = (props: NsRadioGroupProps) => {
15
+ const {
16
+ items,
17
+ additionalSlot,
18
+ label,
19
+ onChange,
20
+ color,
21
+ disable,
22
+ size,
23
+ additionalProps,
24
+ labelFontSize,
25
+ darkModeEnabled = true,
26
+ } = props;
27
+
28
+ return (
29
+ <>
30
+ <FormControl data-testid={additionalProps?.testid}>
31
+ <NsLabel size={labelFontSize}>{label}</NsLabel>
32
+ <StyledRadioGroup
33
+ aria-labelledby="radio-buttons-group-label"
34
+ defaultValue={items?.[0]?.value}
35
+ name="radio-buttons-group"
36
+ onChange={onChange}
37
+ color={color}
38
+ darkModeEnabled={darkModeEnabled}
39
+ >
40
+ {items?.map((item, index) => (
41
+ <StyledFormControlLabel
42
+ id={`${index} `}
43
+ key={item?.id}
44
+ value={item?.value}
45
+ control={<StyledRadio className="custom-radio" />}
46
+ label={item?.label}
47
+ disabled={disable}
48
+ darkModeEnabled={darkModeEnabled}
49
+ />
50
+ ))}
51
+ </StyledRadioGroup>
52
+ </FormControl>
53
+ {additionalSlot ? (
54
+ <StyledHelperText className={`ml-${size}`}>
55
+ <StyledSpan className="text-sm">{additionalSlot}</StyledSpan>
56
+ </StyledHelperText>
57
+ ) : null}
58
+ </>
59
+ );
60
+ };
61
+
62
+ export default NsRadioGroup;
@@ -0,0 +1,2 @@
1
+ export { default as NsRadioGroup } from './NsRadioGroup';
2
+ export type { NsRadioGroupProps} from './types.d'
@@ -0,0 +1,20 @@
1
+ import { FoundationTheme } from '@nuskin/foundation-theme';
2
+ import { AdditionalProps } from '../common.types';
3
+
4
+ export type NsRadioGroupProps = {
5
+ disable : boolean ;
6
+ name : string;
7
+ additionalSlot : string;
8
+ label : string ;
9
+ items: RadioItems[] ;
10
+ color: FoundationTheme.PaletteColors;
11
+ size : number;
12
+ labelFontSize:number,
13
+ onChange : () => void;
14
+ } & AdditionalProps;
15
+
16
+ export type RadioItems = {
17
+ label : string ;
18
+ value :string | number ;
19
+ id: string | number;
20
+ }
@@ -1,4 +1,4 @@
1
- import { render } from '../../../test-utils';
1
+ import { render } from '@/test-utils/index';
2
2
  import NsSearchBar from './NsSearchBar';
3
3
 
4
4
  describe('Search Bar Component', () => {
@@ -2,8 +2,6 @@ import React from 'react';
2
2
  import InputBase from '@mui/material/InputBase';
3
3
  import { styled } from '@nuskin/foundation-theme';
4
4
 
5
- interface NsSearchBarProps {}
6
-
7
5
  const Search = styled('div')`
8
6
  position: relative;
9
7
  borderRadius: 0;
@@ -31,7 +29,7 @@ const StyledInputBase = styled(InputBase)(() => ({
31
29
  },
32
30
  }));
33
31
 
34
- const NsSearchBar: React.FC<NsSearchBarProps> = () => {
32
+ const NsSearchBar: React.FC = () => {
35
33
  return (
36
34
  <div>
37
35
  <Search>