@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
@@ -1,6 +1,4 @@
1
1
  /**
2
- * @author [vijayaprathap Kumar] (vpkumar@nuskin.com)
3
- * types.d.ts
4
2
  * @description Extend the FlagProps interface to include message, color and size prop.
5
3
  */
6
4
 
@@ -0,0 +1,2 @@
1
+ export {default as useWindowSize} from './useWindowSize';
2
+ export {default as useAccordionMap} from './useAccordionMap';
@@ -0,0 +1,19 @@
1
+ import { renderHook, act } from '@testing-library/react-hooks';
2
+ import useWindowSize from '../useWindowSize';
3
+
4
+ describe('useWindowSize', () => {
5
+ it('should return the window size', () => {
6
+ const { result } = renderHook(useWindowSize);
7
+ expect(result.current).toEqual({ width: window.innerWidth, height: window.innerHeight });
8
+ });
9
+
10
+ it('should update the window size when the window is resized', () => {
11
+ const { result } = renderHook(() => useWindowSize());
12
+ act(() => {
13
+ window.innerWidth = 500;
14
+ window.innerHeight = 500;
15
+ window.dispatchEvent(new Event('resize'));
16
+ });
17
+ expect(result.current).toEqual({ width: 500, height: 500 });
18
+ });
19
+ });
@@ -0,0 +1,39 @@
1
+ import { useState, useEffect, useCallback } from 'react';
2
+
3
+ type ItemMap = Record<string, boolean>;
4
+ type UseAccordionProp = {
5
+ allowMultipleExpanded?: boolean;
6
+ defaultOpenIds?: string[];
7
+ };
8
+ const reducer = (map: ItemMap, id: string) => {
9
+ map[id] = true;
10
+ return map;
11
+ };
12
+
13
+ const useAccordionMap = ({ allowMultipleExpanded, defaultOpenIds }: UseAccordionProp) => {
14
+ const mapSetter = useCallback(() => {
15
+ let ids = defaultOpenIds;
16
+ if (!allowMultipleExpanded) {
17
+ ids = ids?.slice(0, 1) ?? [];
18
+ }
19
+ return ids?.reduce(reducer, {}) ?? {};
20
+ }, [defaultOpenIds, allowMultipleExpanded]);
21
+
22
+ const [itemStateMap, setItemMap] = useState<ItemMap>(mapSetter);
23
+
24
+ const toggleOpen = (index: string | number) => {
25
+ const key = index + '';
26
+ if (allowMultipleExpanded) {
27
+ setItemMap((prevState) => ({ ...prevState, [key]: !prevState[key] }));
28
+ } else {
29
+ setItemMap({ [key]: !itemStateMap[index] });
30
+ }
31
+ };
32
+
33
+ useEffect(() => {
34
+ setItemMap(mapSetter);
35
+ }, [mapSetter]);
36
+ return { itemStateMap, toggleOpen };
37
+ };
38
+
39
+ export default useAccordionMap;
@@ -0,0 +1,30 @@
1
+ import { useState, useEffect } from 'react';
2
+
3
+ const useWindowSize = () => {
4
+ const [windowSize, setWindowSize] = useState({
5
+ width: window.innerWidth,
6
+ height: window.innerHeight,
7
+ });
8
+
9
+ useEffect(() => {
10
+ function handleResize() {
11
+ setWindowSize({
12
+ width: window?.innerWidth || 300,
13
+ height: window?.innerHeight || 300,
14
+ });
15
+ }
16
+ if (typeof window !== 'undefined') {
17
+ window.addEventListener('resize', handleResize);
18
+ }
19
+
20
+ return () => {
21
+ if (typeof window !== 'undefined') {
22
+ window.removeEventListener('resize', handleResize);
23
+ }
24
+ };
25
+ }, []);
26
+
27
+ return windowSize;
28
+ };
29
+
30
+ export default useWindowSize;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { render, screen } from '../../../test-utils';
2
+ import { render, screen } from '@/test-utils/index';
3
3
  import { NsIcon, NsIconNameType, NsIconVariants } from './';
4
4
 
5
5
  describe('NsIcon Component', () => {
@@ -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 { NsIcon, NsIconVariants } from './';
4
4
 
5
5
  type ComponentType = typeof NsIcon;
@@ -7,7 +7,7 @@ type Story = StoryObj<ComponentType>;
7
7
  type MetaStory = Meta<ComponentType>;
8
8
 
9
9
  export default {
10
- title: 'Components/NsIcon',
10
+ title: 'Icons/NsIcon',
11
11
  component: NsIcon,
12
12
  decorators: [withCenterDecorator],
13
13
  argTypes: {
@@ -1,5 +1,5 @@
1
1
  import { styled } from '@nuskin/foundation-theme';
2
- import { NsIconSizeType } from './types';
2
+ import { NsIconSizeType } from './types.d';
3
3
 
4
4
  const iconSize = {
5
5
  small: '16px',
@@ -1,6 +1,6 @@
1
1
  import { IconContainer } from './NsIcon.styled';
2
2
  import IconVariants from './NsIconVariants';
3
- import { NsIconProps } from './types';
3
+ import { NsIconProps } from './types.d';
4
4
 
5
5
  const NsIcon = ({
6
6
  name,
@@ -17,27 +17,32 @@ import Home from './icons/home';
17
17
  import AlertErrorIcon from './icons/AlertErrorIcon';
18
18
  import WarningIcon from './icons/WarningIcon';
19
19
  import CloseIcon from './icons/CloseIcon';
20
+ import UserIcon from './icons/UserIcon';
21
+ import HamburgerIcon from './icons/HamburgerIcon';
20
22
 
21
23
  const IconVariants = {
22
24
  arrowDown: ArrowDown,
23
25
  arrowUp: ArrowUp,
24
26
  arrowLeft: ArrowLeft,
25
27
  arrowRight: ArrowRight,
28
+ alertError: AlertErrorIcon,
26
29
  cart: Cart,
27
30
  cartBadge: CartBadge,
31
+ close: CloseIcon,
28
32
  checkShield: CheckShield,
29
33
  checkVerified: CheckVerified,
30
34
  error: ErrorIcon,
35
+ hamburgerIcon: HamburgerIcon,
36
+ home: Home,
31
37
  infoFilled: InfoFilled,
32
38
  infoOutlined: InfoOutlined,
33
39
  search: SearchIcon,
34
40
  success: SuccessIcon,
35
- trash: TrashIcon,
36
41
  slash: SlashIcon,
37
- home: Home,
38
- alertError: AlertErrorIcon,
42
+ trash: TrashIcon,
43
+ userIcon: UserIcon,
39
44
  warning: WarningIcon,
40
- close: CloseIcon
41
45
  };
42
46
 
43
47
  export default IconVariants;
48
+ export const isValidIconName = (name: string) => Object.keys(IconVariants).includes(name);
@@ -16,17 +16,26 @@ const AlertErrorIcon = (props: SvgIconProps) => {
16
16
  xmlns="http://www.w3.org/2000/svg"
17
17
  {...props}
18
18
  >
19
- <g id="💎-icon/alert/WarningFill-red" transform="translate(1.000000, 1.000000)">
19
+ <g id="icon/alert/WarningFill-red" transform="translate(1.000000, 1.000000)">
20
20
  <g id="Error2" transform="translate(0.000000, 1.200000)">
21
- <path d="M17.9465423,14.8670135 L9.44311247,0.246687943 C9.35049358,0.100809118 9.18936767,0.012383152 9.01617259,0.012383152 C8.84297751,0.012383152 8.68185161,
21
+ <path
22
+ d="M17.9465423,14.8670135 L9.44311247,0.246687943 C9.35049358,0.100809118 9.18936767,0.012383152 9.01617259,0.012383152 C8.84297751,0.012383152 8.68185161,
22
23
  0.100809118 8.58923271,0.246687943 L0.0706452929,14.8670135 C-0.0142965839,15.0216954 -0.0118890438,15.2093943 0.0769925071,15.3618609 C0.165874058,
23
24
  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,
24
- 15.2093943 18.0314841,15.0216954 17.9465423,14.8670135 Z" id="Shape" fill={props.fill || '#B2140A'} fill-rule="nonzero">
25
- </path>
26
- <path d="M8.19,12.84 C8.16437588,12.6281014 8.2368299,12.4160897 8.38677958,12.2641927 C8.53672927,12.1122956 8.74778837,12.0371121 8.96,12.06 C9.16715704,
25
+ 15.2093943 18.0314841,15.0216954 17.9465423,14.8670135 Z"
26
+ id="Shape"
27
+ fill={props.fill || '#B2140A'}
28
+ fillRule="nonzero"
29
+ ></path>
30
+ <path
31
+ d="M8.19,12.84 C8.16437588,12.6281014 8.2368299,12.4160897 8.38677958,12.2641927 C8.53672927,12.1122956 8.74778837,12.0371121 8.96,12.06 C9.16715704,
27
32
  12.0467652 9.37034806,12.1211477 9.52,12.265 C9.65709398,12.4241339 9.72701115,12.6303 9.715,12.84 C9.72048715,13.0522748 9.64341383,13.2584012 9.5,
28
33
  13.415 C9.35312473,13.5641498 9.1489517,13.6425377 8.94,13.63 C8.72997224,13.6424095 8.52401376,13.5683367 8.37,13.425 C8.23531653,13.2613056 8.17063593,
29
- 13.0510936 8.19,12.84 Z M9.415,11.195 L8.5,11.195 L8.25,5.96 L9.675,5.96 L9.415,11.195 Z" id="Shape" fill={props.fill || '#FFFFFF'} fill-rule="nonzero"></path>
34
+ 13.0510936 8.19,12.84 Z M9.415,11.195 L8.5,11.195 L8.25,5.96 L9.675,5.96 L9.415,11.195 Z"
35
+ id="Shape"
36
+ fill={props.fill || '#FFFFFF'}
37
+ fillRule="nonzero"
38
+ ></path>
30
39
  </g>
31
40
  </g>
32
41
  </SvgIcon>
@@ -0,0 +1,29 @@
1
+ /* eslint-disable max-len */
2
+ import SvgIcon, { SvgIconProps } from '@mui/material/SvgIcon';
3
+ /**
4
+ *
5
+ * @param props {fill: color to be filled for icon, color: color of the tick icon}
6
+ */
7
+ const HamburgerIcon = (props: SvgIconProps) => {
8
+ return (
9
+ <SvgIcon viewBox="0 0 24 24" {...props} data-testid="hamburgerIcon" xmlns="http://www.w3.org/2000/svg">
10
+ <path
11
+ fillRule="evenodd"
12
+ clipRule="evenodd"
13
+ d="M0 1C0 0.447715 0.447715 0 1 0H19C19.5523 0 20 0.447715 20 1C20 1.55228 19.5523 2 19 2H1C0.447715 2 0 1.55228 0 1Z"
14
+ />
15
+ <path
16
+ fillRule="evenodd"
17
+ clipRule="evenodd"
18
+ d="M0 9C0 8.44772 0.447715 8 1 8H19C19.5523 8 20 8.44772 20 9C20 9.55228 19.5523 10 19 10H1C0.447715 10 0 9.55228 0 9Z"
19
+ />
20
+ <path
21
+ fillRule="evenodd"
22
+ clipRule="evenodd"
23
+ d="M0 17C0 16.4477 0.447715 16 1 16H19C19.5523 16 20 16.4477 20 17C20 17.5523 19.5523 18 19 18H1C0.447715 18 0 17.5523 0 17Z"
24
+ />
25
+ </SvgIcon>
26
+ );
27
+ };
28
+
29
+ export default HamburgerIcon;
@@ -0,0 +1,30 @@
1
+ /* eslint-disable max-len */
2
+ import { useTheme } from '@mui/material/styles';
3
+ import SvgIcon, { SvgIconProps } from '@mui/material/SvgIcon';
4
+ /**
5
+ *
6
+ * @param props {fill: color to be filled for icon, color: color of the tick icon}
7
+ */
8
+ const UserIcon = (props: SvgIconProps) => {
9
+ const { palette } = useTheme();
10
+ const strokeColor = palette.primary.main;
11
+ return (
12
+ <SvgIcon viewBox="0 0 24 24" {...props} data-testid="userIcon" xmlns="http://www.w3.org/2000/svg">
13
+ <path
14
+ fillRule="evenodd"
15
+ clipRule="evenodd"
16
+ d="M12 23C18.0751 23 23 18.0751 23 12C23 5.92487 18.0751 1 12 1C5.92487 1 1 5.92487 1 12C1 18.0751 5.92487 23 12 23Z"
17
+ stroke={strokeColor}
18
+ strokeWidth="2"
19
+ />
20
+ <path
21
+ 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"
22
+ stroke={strokeColor}
23
+ strokeWidth="2"
24
+ strokeLinecap="round"
25
+ />
26
+ </SvgIcon>
27
+ );
28
+ };
29
+
30
+ export default UserIcon;
@@ -18,15 +18,24 @@ const WarningIcon = (props: SvgIconProps) => {
18
18
  >
19
19
  <g id="💎-icon/alert/WarningFill-yellow" transform="translate(1.000000, 1.000000)">
20
20
  <g id="Warning2" transform="translate(0.000000, 1.200000)">
21
- <path d="M17.9465423,14.8670135 L9.44311247,0.246687943 C9.35049358,0.100809118 9.18936767,0.012383152 9.01617259,0.012383152 C8.84297751,0.012383152 8.68185161,
21
+ <path
22
+ d="M17.9465423,14.8670135 L9.44311247,0.246687943 C9.35049358,0.100809118 9.18936767,0.012383152 9.01617259,0.012383152 C8.84297751,0.012383152 8.68185161,
22
23
  0.100809118 8.58923271,0.246687943 L0.0706452929,14.8670135 C-0.0142965839,15.0216954 -0.0118890438,15.2093943 0.0769925071,15.3618609 C0.165874058,
23
24
  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,
24
- 15.2093943 18.0314841,15.0216954 17.9465423,14.8670135 Z" id="Shape" fill="#FEBD00" fill-rule="nonzero"></path>
25
- <path d="M8.19,12.84 C8.16437588,12.6281014 8.2368299,12.4160897 8.38677958,12.2641927 C8.53672927,12.1122956 8.74778837,12.0371121 8.96,12.06 C9.16715704,
25
+ 15.2093943 18.0314841,15.0216954 17.9465423,14.8670135 Z"
26
+ id="Shape"
27
+ fill="#FEBD00"
28
+ fillRule="nonzero"
29
+ ></path>
30
+ <path
31
+ d="M8.19,12.84 C8.16437588,12.6281014 8.2368299,12.4160897 8.38677958,12.2641927 C8.53672927,12.1122956 8.74778837,12.0371121 8.96,12.06 C9.16715704,
26
32
  12.0467652 9.37034806,12.1211477 9.52,12.265 C9.65709398,12.4241339 9.72701115,12.6303 9.715,12.84 C9.72048715,13.0522748 9.64341383,13.2584012 9.5,
27
33
  13.415 C9.35312473,13.5641498 9.1489517,13.6425377 8.94,13.63 C8.72997224,13.6424095 8.52401376,13.5683367 8.37,13.425 C8.23531653,13.2613056 8.17063593,
28
- 13.0510936 8.19,12.84 Z M9.415,11.195 L8.5,11.195 L8.25,5.96 L9.675,5.96 L9.415,11.195 Z" id="Shape" fill="#FFFFFF" fill-rule="nonzero">
29
- </path>
34
+ 13.0510936 8.19,12.84 Z M9.415,11.195 L8.5,11.195 L8.25,5.96 L9.675,5.96 L9.415,11.195 Z"
35
+ id="Shape"
36
+ fill="#FFFFFF"
37
+ fillRule="nonzero"
38
+ ></path>
30
39
  </g>
31
40
  </g>
32
41
  </SvgIcon>
@@ -1,3 +1,3 @@
1
1
  export { default as NsIcon } from './NsIcon';
2
2
  export { default as NsIconVariants } from './NsIconVariants';
3
- export type { NsIconProps, NsIconNameType, NsIconSizeType } from './types';
3
+ export type { NsIconProps, NsIconNameType, NsIconSizeType } from './types.d';
@@ -4,6 +4,7 @@ import { NsIconVariants } from '.';
4
4
  export type NsIconSizeType = 'small' | 'medium' | 'large' | 'xLarge';
5
5
 
6
6
  export type NsIconNameType = keyof typeof NsIconVariants;
7
+
7
8
  export type NsIconProps = {
8
9
  name: NsIconNameType;
9
10
  size?: NsIconSizeType;
@@ -1,10 +1,60 @@
1
- import { render, screen } from '../../../test-utils';
2
- import NsImage from './NsImage';
3
- describe('NsImage', () => {
4
- it('NsImage element renders', () => {
5
- const altText = 'dummy image';
6
- render(<NsImage src="https://www.google.com" width={300} height={300} alt={altText} />);
7
- const imgElement = screen.getByAltText(altText);
1
+ import { render, screen } from '@/test-utils/index';
2
+ import { NsImage } from '../';
3
+
4
+ describe('NsImage component', () => {
5
+ it('1. renders', () => {
6
+ const alt = 'test image';
7
+ render(<NsImage src="image.jpg" width={300} height={300} alt={alt} />);
8
+ const imgElement = screen.getByAltText(alt);
8
9
  expect(imgElement).toBeInTheDocument();
9
10
  });
11
+
12
+ it('2. renders with correct src and alt attributes', () => {
13
+ const src = 'image.jpg';
14
+ const alt = 'test image';
15
+ const { getByAltText } = render(<NsImage src={src} alt={alt} />);
16
+ const image = getByAltText(alt);
17
+ expect(image).toHaveAttribute('src', src);
18
+ });
19
+
20
+ it('3. renders with width and height if variant is not provided', () => {
21
+ const { getByAltText } = render(<NsImage src="image.jpg" alt="test image" width={300} height={300} />);
22
+ const image = getByAltText('test image');
23
+ expect(image).toHaveAttribute('width', '300');
24
+ expect(image).toHaveAttribute('height', '300');
25
+ });
26
+
27
+ it('4. renders with correct width and height based on variant', () => {
28
+ const { getByAltText } = render(<NsImage src="image.jpg" alt="test image" variant="icon" />);
29
+ const image = getByAltText('test image');
30
+ expect(image).toHaveAttribute('width', '60');
31
+ expect(image).toHaveAttribute('height', '60');
32
+ });
33
+
34
+ it('5. renders with correct width and height if variant is "fill"', () => {
35
+ const { getByAltText } = render(<NsImage src="image.jpg" alt="test image" variant="fill" />);
36
+ const image = getByAltText('test image');
37
+ expect(image).toHaveAttribute('width', '100%');
38
+ expect(image).toHaveAttribute('height', 'auto');
39
+ });
40
+
41
+ it('6. renders with correct width and height if variant is "award"', () => {
42
+ const { getByAltText } = render(<NsImage src="image.jpg" alt="test image" variant="award" />);
43
+ const image = getByAltText('test image');
44
+ expect(image).toHaveAttribute('width', '130');
45
+ expect(image).toHaveAttribute('height', '130');
46
+ });
47
+
48
+ it('7. renders with correct width and height if variant is "product"', () => {
49
+ const { getByAltText } = render(<NsImage src="image.jpg" alt="test image" variant="product" />);
50
+ const image = getByAltText('test image');
51
+ expect(image).toHaveAttribute('width', '300');
52
+ expect(image).toHaveAttribute('height', '300');
53
+ });
54
+
55
+ it('8. renders with additional props', () => {
56
+ const { getByAltText } = render(<NsImage src="image.jpg" alt="test image" className="custom-image" />);
57
+ const image = getByAltText('test image');
58
+ expect(image).toHaveClass('custom-image');
59
+ });
10
60
  });
@@ -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 { NsImage } from './';
4
4
 
5
5
  type ComponentType = typeof NsImage;
@@ -7,7 +7,7 @@ type Story = StoryObj<ComponentType>;
7
7
  type MetaStory = Meta<ComponentType>;
8
8
 
9
9
  export default {
10
- title: 'Components/NsImage',
10
+ title: 'Components/Data Display/NsImage',
11
11
  component: NsImage,
12
12
  decorators: [withCenterDecorator],
13
13
  args: {
@@ -1,19 +1,31 @@
1
- import { NsImageProps } from './types';
1
+ import { NsImageProps } from './types.d';
2
2
 
3
3
  // eslint-disable-next-line no-unused-vars
4
4
  const NsImage = ({ src, width, height, alt, variant, ...rest }: NsImageProps) => {
5
- let cHeight: string | number | undefined = height,
6
- cWidth: string | number | undefined = width;
7
- if (variant === 'product') {
8
- (cHeight = 300), (cWidth = 300);
9
- } else if (variant === 'icon') {
10
- (cHeight = 60), (cWidth = 60);
11
- } else if (variant === 'award') {
12
- (cHeight = 130), (cWidth = 130);
13
- } else if (variant === 'fill') {
14
- (cHeight = 'auto'), (cWidth = '100%');
5
+ let cHeight, cWidth;
6
+ switch (variant) {
7
+ case 'product':
8
+ cHeight = 300;
9
+ cWidth = 300;
10
+ break;
11
+ case 'icon':
12
+ cHeight = 60;
13
+ cWidth = 60;
14
+ break;
15
+ case 'award':
16
+ cHeight = 130;
17
+ cWidth = 130;
18
+ break;
19
+ case 'fill':
20
+ cHeight = 'auto';
21
+ cWidth = '100%';
22
+ break;
23
+ default:
24
+ cHeight = height;
25
+ cWidth = width;
26
+ break;
15
27
  }
16
28
  // eslint-disable-next-line @next/next/no-img-element
17
- return <img src={src} alt={alt} height={cHeight} width={cWidth} />;
29
+ return <img src={src} alt={alt} height={cHeight} width={cWidth} {...rest} />;
18
30
  };
19
31
  export default NsImage;
@@ -1,4 +1,4 @@
1
- import { render, screen } from '../../../test-utils';
1
+ import { render, screen } from '@/test-utils/index';
2
2
  import NsNextImage from './NsNextImage';
3
3
  describe('NsNextImage', () => {
4
4
  it('test image element renders', () => {
@@ -1,5 +1,5 @@
1
1
  import { NsNextImage } from '.';
2
- import { withCenterDecorator } from '../../stories/decorators/withCenterDecorator';
2
+ import { withCenterDecorator } from '@/stories/decorators/withCenterDecorator';
3
3
  import type { StoryObj, Meta } from '@storybook/react';
4
4
 
5
5
  type ComponentType = typeof NsNextImage;
@@ -7,7 +7,7 @@ type Story = StoryObj<ComponentType>;
7
7
  type MetaStory = Meta<ComponentType>;
8
8
 
9
9
  export default {
10
- title: 'Components/NsNextImage',
10
+ title: 'Components/Data Display/NsNextImage',
11
11
  component: NsNextImage,
12
12
  decorators: [withCenterDecorator],
13
13
  } as MetaStory;
@@ -1,4 +1,4 @@
1
- import { NsNextImageProps } from './types';
1
+ import { NsNextImageProps } from './types.d';
2
2
  import Image from 'next/image';
3
3
 
4
4
  const NsNextImage = ({ src, width, height, alt, fill, priority, ...props }: NsNextImageProps) => {
@@ -1,3 +1,3 @@
1
1
  export { default as NsNextImage } from './NsNextImage';
2
- export type { NsImageProps, NsNextImageProps } from './types';
2
+ export type { NsImageProps, NsNextImageProps } from './types.d';
3
3
  export { default as NsImage } from './NsImage';
@@ -15,6 +15,7 @@ export type NsNextImageProps = Pick<
15
15
  | 'blurDataURL'
16
16
  | 'fill'
17
17
  | 'unoptimized'
18
+ | 'loader'
18
19
  > & { id?: string; className?: string };
19
20
 
20
21
  export type NsImageProps = {
@@ -1,4 +1,7 @@
1
+ export * from './accordion';
2
+ export * from './alert';
1
3
  export * from './auth-dropdown';
4
+ export * from './autocomplete';
2
5
  export * from './banner';
3
6
  export * from './breadcrumb';
4
7
  export * from './brand-components';
@@ -8,21 +11,22 @@ export * from './carousal';
8
11
  export * from './cart-icon';
9
12
  export * from './column-control';
10
13
  export * from './checkbox';
14
+ export * from './common.types.d';
11
15
  export * from './dropdown';
16
+ export * from './email-simple';
12
17
  export * from './flag';
18
+ export * from './hooks';
13
19
  export * from './icon';
14
- export * from './input';
15
20
  export * from './image';
16
- export * from './link';
21
+ export * from './input';
17
22
  export * from './label';
18
- export * from './autocomplete';
19
-
20
- /* Dropdown Components */
21
- export * from './dropdown';
22
- export * from './auth-dropdown';
23
- export * from './alert';
23
+ export * from './link';
24
+ export * from './modal';
24
25
  export * from './nav-tab';
25
26
  export * from './nav-product-card';
27
+ export * from './radiogroup';
28
+ export * from './spinner';
29
+ export * from './text-strip';
30
+ export * from './table';
26
31
  export * from './typography';
27
-
28
- export * from './common.types';
32
+ export * from './utility';
@@ -1,6 +1,6 @@
1
1
  import { Stack } from '@mui/material';
2
2
  import { styled, ColorUtils } from '@nuskin/foundation-theme';
3
- const { getPaletteColor, getAppColor } = ColorUtils;
3
+ const { color, paletteColor } = ColorUtils;
4
4
 
5
5
  const InputFieldWrapper = styled(Stack)(({ theme }: any) => {
6
6
  return {
@@ -10,12 +10,12 @@ const InputFieldWrapper = styled(Stack)(({ theme }: any) => {
10
10
  '.MuiFormHelperText-root': {
11
11
  fontSize: '11px',
12
12
  marginTop: 0,
13
- color: getPaletteColor(theme, 'primary', 'main'),
13
+ color: paletteColor('primary', 'main')({ theme }),
14
14
  '&.success': {
15
- color: getAppColor(theme, 'success', '40') as string,
15
+ color: color('success', '40')({ theme }),
16
16
  },
17
17
  '&.error': {
18
- color: getPaletteColor(theme, 'error', 'main'),
18
+ color: paletteColor('error', 'main')({ theme }),
19
19
  },
20
20
  },
21
21
  };
@@ -1,20 +1,25 @@
1
1
  import { Box } from '@mui/material';
2
- import { styled, nuskinTheme } from '@nuskin/foundation-theme';
3
- import { fieldStateType } from './types';
2
+ import { styled, nuskinTheme, ColorUtils, FoundationTheme } from '@nuskin/foundation-theme';
3
+ import {fieldStateType} from './types.d';
4
4
 
5
+ const { isDarkMode } = ColorUtils;
5
6
  const { colors } = nuskinTheme;
6
7
 
7
8
  const options = {
8
9
  shouldForwardProp: (propKey: string) => propKey !== 'fieldState',
9
10
  };
10
11
 
11
- const getInputBorderColor = (palette: any, fieldState: fieldStateType, isLight = true): string => {
12
+ const getInputBorderColor = (
13
+ palette: FoundationTheme.Theme['palette'],
14
+ fieldState: fieldStateType,
15
+ isLight = true
16
+ ): string => {
12
17
  if (fieldState === 'success') {
13
- return isLight ? colors.success[40] : colors.success[40];
18
+ return colors.success[40];
14
19
  } else if (fieldState === 'error') {
15
20
  return isLight ? colors.red[40] : colors.red[20];
16
21
  } else {
17
- return palette.primary.main;
22
+ return palette?.primary.main ?? '';
18
23
  }
19
24
  };
20
25
 
@@ -28,7 +33,7 @@ const InputWrapper = styled(
28
33
  )<InputWrapperType>(({ theme, fieldState }) => {
29
34
  /* default value added so that unit tests do not fail */
30
35
  const { palette = { primary: { main: '', contrastText: '' } } } = theme;
31
- const isLight = palette.primary.main === colors.primary.black;
36
+ const isLight = isDarkMode({ theme });
32
37
  const inputFocusedBorder = isLight ? colors.accentColorB[20] : colors.accentColorB[30];
33
38
  const inputDisabledBg = isLight ? colors.neutral[30] : colors.neutral[70];
34
39
  const inputDisabledBorder = isLight ? colors.neutral[60] : colors.neutral[80];
@@ -56,7 +61,7 @@ const InputWrapper = styled(
56
61
  },
57
62
  },
58
63
  fieldset: {
59
- border: `1px solid ${getInputBorderColor(palette as any, fieldState, isLight)}`,
64
+ border: `1px solid ${getInputBorderColor(palette, fieldState, isLight)}`,
60
65
  },
61
66
  input: {
62
67
  color: palette.primary.main,