@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.
- package/package.json +21 -11
- package/src/common/accordion/NsAccordion.tsx +69 -0
- package/src/common/accordion/NsAccordionHeader.tsx +77 -0
- package/src/common/accordion/NsAccordionItem.tsx +59 -0
- package/src/common/accordion/NsCollapse.tsx +110 -0
- package/src/common/accordion/NsToggleSection.tsx +43 -0
- package/src/common/accordion/ToggleSection.styled.tsx +32 -0
- package/src/common/accordion/colorMap.ts +117 -0
- package/src/common/accordion/enums.ts +8 -0
- package/src/common/accordion/index.ts +7 -0
- package/src/common/accordion/specs/NsAccordion.spec.tsx +163 -0
- package/src/common/accordion/specs/NsAccordionHeader.spec.tsx +130 -0
- package/src/common/accordion/specs/NsAccordionItem.spec.tsx +79 -0
- package/src/common/accordion/specs/NsCollapse.spec.tsx +129 -0
- package/src/common/accordion/specs/NsToggleSection.spec.tsx +74 -0
- package/src/common/accordion/stories/NsAccordion.stories.tsx +65 -0
- package/src/common/accordion/stories/NsAccordionHeader.stories.tsx +44 -0
- package/src/common/accordion/stories/NsAccordionItem.stories.tsx +45 -0
- package/src/common/accordion/stories/NsCollapse.stories.tsx +50 -0
- package/src/common/accordion/stories/NsToggleSection.stories.tsx +26 -0
- package/src/common/accordion/stories/data.tsx +143 -0
- package/src/common/accordion/types.d.ts +81 -0
- package/src/common/alert/Header.tsx +29 -0
- package/src/common/alert/NsAlert.spec.tsx +62 -29
- package/src/common/alert/NsAlert.stories.tsx +18 -17
- package/src/common/alert/NsAlert.styled.tsx +124 -0
- package/src/common/alert/NsAlert.tsx +27 -110
- package/src/common/alert/index.ts +2 -2
- package/src/common/alert/types.d.ts +23 -23
- package/src/common/auth-dropdown/NsAuthDropdown.spec.tsx +24 -6
- package/src/common/auth-dropdown/NsAuthDropdown.stories.tsx +2 -2
- package/src/common/auth-dropdown/NsAuthDropdown.styled.ts +21 -16
- package/src/common/auth-dropdown/NsAuthDropdown.tsx +7 -6
- package/src/common/auth-dropdown/index.ts +1 -1
- package/src/common/auth-dropdown/types.d.ts +3 -1
- package/src/common/autocomplete/NsAutocomplete.spec.tsx +69 -24
- package/src/common/autocomplete/NsAutocomplete.stories.tsx +64 -7
- package/src/common/autocomplete/NsAutocomplete.styled.tsx +12 -0
- package/src/common/autocomplete/NsAutocomplete.tsx +100 -46
- package/src/common/autocomplete/index.ts +2 -1
- package/src/common/autocomplete/mock/MockData.ts +50 -7
- package/src/common/autocomplete/mock/MockUI.tsx +2 -1
- package/src/common/autocomplete/{types.ts → types.d.ts} +18 -8
- package/src/common/banner/NsBanner.spec.tsx +13 -4
- package/src/common/banner/NsBanner.stories.tsx +2 -2
- package/src/common/banner/NsBanner.styled.tsx +1 -1
- package/src/common/banner/NsBanner.tsx +1 -1
- package/src/common/banner/index.ts +1 -1
- package/src/common/brand-components/NsBrand.stories.tsx +2 -2
- package/src/common/brand-components/NsBrandComponent.tsx +6 -3
- package/src/common/brand-components/index.ts +1 -1
- package/src/common/breadcrumb/NsBreadcrumb.spec.tsx +8 -9
- package/src/common/breadcrumb/NsBreadcrumb.stories.tsx +3 -5
- package/src/common/breadcrumb/NsBreadcrumb.tsx +5 -3
- package/src/common/breadcrumb/data.ts +10 -0
- package/src/common/breadcrumb/index.ts +1 -1
- package/src/common/button/NsButton.spec.tsx +66 -51
- package/src/common/button/NsButton.stories.tsx +61 -4
- package/src/common/button/NsButton.styled.tsx +54 -72
- package/src/common/button/NsButton.tsx +9 -3
- package/src/common/button/helper.ts +82 -0
- package/src/common/button/index.ts +1 -1
- package/src/common/button/types.d.ts +3 -0
- package/src/common/card/NsFfgCard.tsx +14 -8
- package/src/common/card/specs/NsFfgCard.spec.tsx +33 -0
- package/src/common/card/stories/NsBgCard.stories.tsx +2 -4
- package/src/common/card/stories/NsBrandProductCard.stories.tsx +2 -2
- package/src/common/card/stories/NsFfgCard.stories.tsx +49 -16
- package/src/common/card/stories/{data.js → data.ts} +1 -25
- package/src/common/card/styled/NsFfgStyled.tsx +9 -7
- package/src/common/card/types.d.ts +7 -4
- package/src/common/carousal/NsScrollingCarousal.tsx +61 -0
- package/src/common/carousal/index.ts +3 -0
- package/src/common/carousal/{tests → specs}/NsCarousal.spec.tsx +2 -2
- package/src/common/carousal/specs/NsScrollingCarousal.spec.tsx +61 -0
- package/src/common/carousal/stories/NSCarousal.stories.tsx +2 -2
- package/src/common/carousal/stories/NsScrollingCarousal.stories.tsx +52 -0
- package/src/common/carousal/types.d.ts +23 -0
- package/src/common/cart-icon/NsCartIcon.spec.tsx +1 -1
- package/src/common/cart-icon/NsCartIcon.stories.tsx +2 -2
- package/src/common/cart-icon/NsCartIcon.tsx +1 -1
- package/src/common/cart-icon/index.ts +1 -1
- package/src/common/checkbox/NsCheckbox.spec.tsx +2 -2
- package/src/common/checkbox/NsCheckbox.stories.tsx +2 -2
- package/src/common/checkbox/NsCheckbox.styled.tsx +15 -16
- package/src/common/checkbox/NsCheckbox.tsx +2 -2
- package/src/common/checkbox/index.ts +1 -1
- package/src/common/checkbox/types.d.ts +1 -7
- package/src/common/column-control/NsColumnControl.tsx +1 -1
- package/src/common/column-control/NsFlexColumns.tsx +22 -0
- package/src/common/column-control/NsGridColumns.tsx +22 -0
- package/src/common/column-control/index.ts +3 -1
- package/src/common/column-control/{NsColumnControl.spec.tsx → specs/NsColumnControl.spec.tsx} +3 -3
- package/src/common/column-control/specs/NsFlexColumns.spec.tsx +24 -0
- package/src/common/column-control/specs/NsGridColumns.spec.tsx +24 -0
- package/src/common/column-control/stories/DivArray.stories.tsx +18 -0
- package/src/common/column-control/stories/DivArray.tsx +63 -0
- package/src/common/column-control/{NsColumnControl.stories.tsx → stories/NsColumnControl.stories.tsx} +9 -16
- package/src/common/column-control/stories/NsFlexColumns.stories.tsx +63 -0
- package/src/common/column-control/stories/NsGridColumns.stories.tsx +63 -0
- package/src/common/column-control/stories/common.tsx +14 -0
- package/src/common/column-control/styled/StyledFlex.tsx +45 -0
- package/src/common/column-control/styled/StyledGrid.tsx +40 -0
- package/src/common/column-control/styled/common.ts +27 -0
- package/src/common/column-control/types.d.ts +15 -16
- package/src/common/column-control/utils.ts +5 -5
- package/src/common/common.types.d.ts +21 -0
- package/src/common/dropdown/NsDropdown.spec.tsx +1 -1
- package/src/common/dropdown/NsDropdown.styled.tsx +23 -18
- package/src/common/dropdown/NsDropdown.tsx +1 -1
- package/src/common/dropdown/NsDropdownOption.tsx +1 -1
- package/src/common/dropdown/index.ts +1 -1
- package/src/common/dropdown/stories/NsDropdown.stories.tsx +2 -2
- package/src/common/dropdown/stories/NsDropdownCountry.stories.tsx +2 -2
- package/src/common/dropdown/types.d.ts +3 -1
- package/src/common/email-simple/NsEmailSimple.spec.tsx +145 -0
- package/src/common/email-simple/NsEmailSimple.stories.tsx +61 -0
- package/src/common/email-simple/NsEmailSimple.tsx +71 -0
- package/src/common/email-simple/index.ts +2 -0
- package/src/common/email-simple/types.d.ts +14 -0
- package/src/common/flag/NsFlag.spec.tsx +5 -25
- package/src/common/flag/NsFlag.stories.tsx +2 -2
- package/src/common/flag/NsFlag.styled.tsx +7 -9
- package/src/common/flag/NsFlag.tsx +1 -3
- package/src/common/flag/index.ts +1 -1
- package/src/common/flag/types.d.ts +0 -2
- package/src/common/hooks/index.ts +2 -0
- package/src/common/hooks/specs/useWindowSize.spec.tsx +19 -0
- package/src/common/hooks/useAccordionMap.tsx +39 -0
- package/src/common/hooks/useWindowSize.tsx +30 -0
- package/src/common/icon/NsIcon.spec.tsx +1 -1
- package/src/common/icon/NsIcon.stories.tsx +2 -2
- package/src/common/icon/NsIcon.styled.tsx +1 -1
- package/src/common/icon/NsIcon.tsx +1 -1
- package/src/common/icon/NsIconVariants.ts +9 -4
- package/src/common/icon/icons/AlertErrorIcon.tsx +15 -6
- package/src/common/icon/icons/HamburgerIcon.tsx +29 -0
- package/src/common/icon/icons/UserIcon.tsx +30 -0
- package/src/common/icon/icons/WarningIcon.tsx +14 -5
- package/src/common/icon/index.ts +1 -1
- package/src/common/icon/types.d.ts +1 -0
- package/src/common/image/NsImage.spec.tsx +57 -7
- package/src/common/image/NsImage.stories.tsx +2 -2
- package/src/common/image/NsImage.tsx +24 -12
- package/src/common/image/NsNextImage.spec.tsx +1 -1
- package/src/common/image/NsNextImage.stories.tsx +2 -2
- package/src/common/image/NsNextImage.tsx +1 -1
- package/src/common/image/index.ts +1 -1
- package/src/common/image/types.d.ts +1 -0
- package/src/common/index.ts +14 -10
- package/src/common/input/InputFieldWrapper.tsx +4 -4
- package/src/common/input/InputWrapper.tsx +12 -7
- package/src/common/input/NsInputField.stories.tsx +13 -10
- package/src/common/input/NsInputField.tsx +13 -6
- package/src/common/input/getAdornmentProps.tsx +5 -1
- package/src/common/input/index.ts +1 -1
- package/src/common/input/types.d.ts +18 -1
- package/src/common/label/NsLabel.stories.tsx +6 -1
- package/src/common/label/NsLabel.tsx +21 -20
- package/src/common/label/index.ts +1 -1
- package/src/common/label/types.d.ts +2 -1
- package/src/common/link/NsLink.spec.tsx +1 -1
- package/src/common/link/NsLink.stories.tsx +2 -2
- package/src/common/link/NsLink.tsx +1 -1
- package/src/common/link/index.ts +1 -1
- package/src/common/modal/NsModal.spec.tsx +46 -0
- package/src/common/modal/NsModal.styled.tsx +28 -0
- package/src/common/modal/NsModal.tsx +37 -0
- package/src/common/modal/helper-component/NsModalContentBox.tsx +32 -0
- package/src/common/modal/helper-component/NsModalDefault.tsx +25 -0
- package/src/common/modal/helper-component/NsModalStatus.tsx +15 -0
- package/src/common/modal/helper-component/NsModalStatusIcon.tsx +14 -0
- package/src/common/modal/helper-component/NsModalTitle.tsx +26 -0
- package/src/common/modal/index.ts +2 -0
- package/src/common/modal/model/NsModalVariantMap.tsx +24 -0
- package/src/common/modal/stories/NsModal.stories.tsx +86 -0
- package/src/common/modal/stories/mock.tsx +46 -0
- package/src/common/modal/types.ts +56 -0
- package/src/common/nav-product-card/NsNavProductCard.spec.tsx +1 -1
- package/src/common/nav-product-card/NsNavProductCard.stories.tsx +2 -2
- package/src/common/nav-product-card/NsNavProductCard.tsx +1 -1
- package/src/common/nav-product-card/index.ts +1 -1
- package/src/common/nav-tab/NsNavTab.spec.tsx +2 -7
- package/src/common/nav-tab/NsNavTab.stories.tsx +2 -2
- package/src/common/nav-tab/NsNavTab.styled.tsx +7 -4
- package/src/common/nav-tab/NsNavTab.tsx +1 -1
- package/src/common/nav-tab/index.ts +1 -1
- package/src/common/nav-tab/types.d.ts +2 -2
- package/src/common/radiogroup/NsRadioGroup.spec.tsx +63 -0
- package/src/common/radiogroup/NsRadioGroup.stories.tsx +84 -0
- package/src/common/radiogroup/NsRadioGroup.styled.tsx +52 -0
- package/src/common/radiogroup/NsRadioGroup.tsx +62 -0
- package/src/common/radiogroup/index.ts +2 -0
- package/src/common/radiogroup/types.d.ts +20 -0
- package/src/common/search-bar/NsSeachBar.spec.tsx +1 -1
- package/src/common/search-bar/NsSearchBar.tsx +1 -3
- package/src/common/select/NsSelect.spec.tsx +193 -0
- package/src/common/select/NsSelect.styled.tsx +104 -0
- package/src/common/select/NsSelect.tsx +117 -0
- package/src/common/select/NsSelectOption.tsx +30 -0
- package/src/common/select/index.ts +3 -0
- package/src/common/select/stories/NsSelect.stories.tsx +134 -0
- package/src/common/select/types.d.ts +34 -0
- package/src/common/spinner/NsSpinner.spec.tsx +21 -0
- package/src/common/spinner/NsSpinner.stories.tsx +26 -0
- package/src/common/spinner/NsSpinner.styled.tsx +344 -0
- package/src/common/spinner/NsSpinner.tsx +14 -0
- package/src/common/spinner/icons/Spinner.tsx +161 -0
- package/src/common/spinner/index.ts +2 -0
- package/src/common/spinner/types.ts +5 -0
- package/src/common/table/NsExpandableRow.tsx +68 -0
- package/src/common/table/NsTable.spec.tsx +174 -0
- package/src/common/table/NsTable.stories.tsx +161 -0
- package/src/common/table/NsTable.styled.ts +127 -0
- package/src/common/table/NsTable.tsx +133 -0
- package/src/common/table/NsTableHeader.tsx +41 -0
- package/src/common/table/NsTablePagination.tsx +28 -0
- package/src/common/table/helper.ts +33 -0
- package/src/common/table/index.ts +2 -0
- package/src/common/table/types.d.ts +57 -0
- package/src/common/text-strip/NsTextStrip.spec.tsx +30 -0
- package/src/common/text-strip/NsTextStrip.stories.tsx +33 -0
- package/src/common/text-strip/NsTextStrip.tsx +47 -0
- package/src/common/text-strip/index.ts +2 -0
- package/src/common/text-strip/types.d.ts +17 -0
- package/src/common/typography/NsTypography.stories.tsx +2 -2
- package/src/common/typography/NsTypography.tsx +1 -1
- package/src/common/typography/Typography.styled.tsx +4 -4
- package/src/common/typography/index.ts +1 -1
- package/src/common/util.ts +1 -0
- package/src/common/utility/Show.tsx +13 -0
- package/src/common/utility/index.ts +1 -0
- package/src/common/validations/regex.ts +3 -0
- package/src/common/videos/NsVideo.stories.tsx +2 -2
- package/src/common/videos/NsVideo.tsx +1 -1
- package/src/common/videos/index.ts +1 -1
- package/src/common/videos/types.d.ts +1 -1
- package/src/common/alert/NsAlert.styled.ts +0 -124
- package/src/common/card/tests/NsFfgCard.spec.tsx +0 -23
- package/src/common/column-control/NDivs.story.tsx +0 -35
- package/src/common/common.types.ts +0 -10
- /package/src/common/brand-components/{NsBrandContanier.styled.tsx → NsBrandContainer.styled.tsx} +0 -0
- /package/src/common/card/{tests → specs}/BrandLogo.spec.tsx +0 -0
- /package/src/common/card/{tests → specs}/NsBgCard.spec.tsx +0 -0
- /package/src/common/card/{tests → specs}/NsBrandProductCard.spec.tsx +0 -0
- /package/src/common/carousal/{tests → specs}/Chevron.spec.tsx +0 -0
- /package/src/common/carousal/{tests → specs}/RenderBrand.spec.tsx +0 -0
|
@@ -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 type { StoryObj, Meta } from '@storybook/react';
|
|
2
|
-
import { withCenterDecorator } from '
|
|
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: '
|
|
10
|
+
title: 'Icons/NsIcon',
|
|
11
11
|
component: NsIcon,
|
|
12
12
|
decorators: [withCenterDecorator],
|
|
13
13
|
argTypes: {
|
|
@@ -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
|
-
|
|
38
|
-
|
|
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="
|
|
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
|
|
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"
|
|
25
|
-
|
|
26
|
-
|
|
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"
|
|
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
|
|
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"
|
|
25
|
-
|
|
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"
|
|
29
|
-
|
|
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>
|
package/src/common/icon/index.ts
CHANGED
|
@@ -1,10 +1,60 @@
|
|
|
1
|
-
import { render, screen } from '
|
|
2
|
-
import NsImage from '
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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 '
|
|
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
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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,5 +1,5 @@
|
|
|
1
1
|
import { NsNextImage } from '.';
|
|
2
|
-
import { withCenterDecorator } from '
|
|
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;
|
package/src/common/index.ts
CHANGED
|
@@ -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 './
|
|
21
|
+
export * from './input';
|
|
17
22
|
export * from './label';
|
|
18
|
-
export * from './
|
|
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 {
|
|
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:
|
|
13
|
+
color: paletteColor('primary', 'main')({ theme }),
|
|
14
14
|
'&.success': {
|
|
15
|
-
color:
|
|
15
|
+
color: color('success', '40')({ theme }),
|
|
16
16
|
},
|
|
17
17
|
'&.error': {
|
|
18
|
-
color:
|
|
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 {
|
|
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 = (
|
|
12
|
+
const getInputBorderColor = (
|
|
13
|
+
palette: FoundationTheme.Theme['palette'],
|
|
14
|
+
fieldState: fieldStateType,
|
|
15
|
+
isLight = true
|
|
16
|
+
): string => {
|
|
12
17
|
if (fieldState === 'success') {
|
|
13
|
-
return
|
|
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
|
|
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 =
|
|
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
|
|
64
|
+
border: `1px solid ${getInputBorderColor(palette, fieldState, isLight)}`,
|
|
60
65
|
},
|
|
61
66
|
input: {
|
|
62
67
|
color: palette.primary.main,
|