@nuskin/foundation-ui-components 1.29.1 → 1.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -7
- package/src/common/accordion/NsAccordion.tsx +2 -2
- package/src/common/accordion/NsAccordionHeader.tsx +2 -9
- package/src/common/accordion/NsAccordionItem.tsx +4 -3
- package/src/common/accordion/NsCollapse.tsx +1 -1
- package/src/common/accordion/NsToggleSection.tsx +10 -3
- package/src/common/accordion/stories/NsAccordionItem.stories.tsx +5 -3
- package/src/common/accordion/stories/NsCollapse.stories.tsx +5 -3
- package/src/common/alert/NsAlert.stories.tsx +6 -4
- package/src/common/alert/NsAlert.tsx +27 -13
- package/src/common/auth-dropdown/NsAuthDropdown.tsx +7 -7
- package/src/common/autocomplete/NsAutocomplete.spec.tsx +3 -3
- package/src/common/autocomplete/NsAutocomplete.tsx +2 -1
- package/src/common/autocomplete/helper/SeeMoreButton.tsx +2 -2
- package/src/common/autocomplete/helper/renderGroupName.tsx +4 -3
- package/src/common/autocomplete/stories/NsAutocomplete.stories.tsx +9 -9
- package/src/common/banner/NsBanner.spec.tsx +5 -5
- package/src/common/banner/NsBanner.stories.tsx +8 -5
- package/src/common/banner/NsBanner.tsx +10 -20
- package/src/common/banner/types.d.ts +2 -2
- package/src/common/brand-components/NsBrandComponent.tsx +6 -3
- package/src/common/brand-components/icons/NSLogoHorizontal.tsx +7 -2
- package/src/common/brand-components/icons/NSLogoMark.tsx +3 -1
- package/src/common/brand-components/icons/NSLogoPoweredBy.tsx +4 -2
- package/src/common/brand-components/icons/NSLogoStacked.tsx +4 -2
- package/src/common/brand-components/icons/NSWordMark.tsx +4 -2
- package/src/common/breadcrumb/NsBreadcrumb.tsx +20 -5
- package/src/common/button/NsButton.stories.tsx +14 -8
- package/src/common/button/NsButton.tsx +7 -4
- package/src/common/card/CardButton.tsx +4 -3
- package/src/common/card/NsAwardCard.tsx +9 -8
- package/src/common/card/NsBgCard.tsx +1 -0
- package/src/common/card/NsBrandCard.tsx +8 -5
- package/src/common/card/NsBrandWrapper.tsx +3 -2
- package/src/common/card/NsCheckoutCard.tsx +4 -2
- package/src/common/card/NsHeroCardLevel1.tsx +9 -9
- package/src/common/card/NsHeroCardLevel2.tsx +9 -9
- package/src/common/card/NsIconText.tsx +3 -2
- package/src/common/card/NsLargeCard.tsx +9 -9
- package/src/common/card/NsMediumCard.tsx +10 -9
- package/src/common/card/NsPost.tsx +7 -8
- package/src/common/card/NsSmallFullCard.tsx +9 -9
- package/src/common/card/NsXLargeCard.tsx +9 -9
- package/src/common/card/fixtures/ImageData1.ts +38 -0
- package/src/common/card/fixtures/ImageData2.ts +38 -0
- package/src/common/card/specs/NsAwardCard.spec.tsx +2 -2
- package/src/common/card/specs/NsHeroCardLevel1.spec.tsx +2 -3
- package/src/common/card/specs/NsHeroCardLevel2.spec.tsx +2 -2
- package/src/common/card/specs/NsLargeCard.spec.tsx +2 -3
- package/src/common/card/specs/NsMediumCard.spec.tsx +3 -3
- package/src/common/card/specs/NsPost.spec.tsx +3 -3
- package/src/common/card/specs/NsSmallFullCard.spec.tsx +3 -3
- package/src/common/card/specs/NsXLargeCard.spec.tsx +3 -3
- package/src/common/card/stories/NsAwardCard.stories.tsx +2 -4
- package/src/common/card/stories/NsHeroCardLevel1.stories.tsx +2 -4
- package/src/common/card/stories/NsHeroCardLevel2.stories.tsx +2 -4
- package/src/common/card/stories/NsLargeCard.stories.tsx +2 -4
- package/src/common/card/stories/NsMediumCard.stories.tsx +2 -4
- package/src/common/card/stories/NsPost.stories.tsx +2 -4
- package/src/common/card/stories/NsSmallFullCard.stories.tsx +2 -4
- package/src/common/card/stories/NsXLargeCard.stories.tsx +4 -5
- package/src/common/carousal/CarousalControl.tsx +5 -2
- package/src/common/carousal/IconWrapper.tsx +4 -3
- package/src/common/carousal/NsCarousal.tsx +8 -6
- package/src/common/carousal/NsScrollingCarousal.tsx +2 -2
- package/src/common/carousal/RenderBrand.tsx +3 -1
- package/src/common/carousal/specs/NsScrollingCarousal.spec.tsx +4 -2
- package/src/common/carousal/stories/{NSCarousal.stories.tsx → NsCarousal1.stories.tsx} +5 -2
- package/src/common/carousal/stories/NsScrollingCarousal.stories.tsx +4 -2
- package/src/common/cart-icon/NsCartIcon.tsx +9 -1
- package/src/common/checkbox/NsCheckbox.stories.tsx +5 -4
- package/src/common/checkbox/NsCheckbox.tsx +6 -6
- package/src/common/column-control/NsColumnControl.tsx +5 -3
- package/src/common/column-control/NsFlexColumns.tsx +10 -3
- package/src/common/column-control/NsGridColumns.tsx +10 -3
- package/src/common/column-control/stories/NsColumnControl.stories.tsx +8 -5
- package/src/common/column-control/stories/NsFlexColumns.stories.tsx +9 -6
- package/src/common/column-control/stories/NsGridColumns.stories.tsx +19 -7
- package/src/common/column-control/styled/common.ts +1 -1
- package/src/common/dropdown/NsDropdown.tsx +6 -6
- package/src/common/dropdown/NsDropdownOption.tsx +4 -3
- package/src/common/dropdown/stories/NsDropdown.stories.tsx +5 -3
- package/src/common/email-simple/NsEmailSimple.tsx +4 -3
- package/src/common/flag/NsFlag.tsx +3 -2
- package/src/common/hooks/useAccordionMap.tsx +1 -1
- package/src/common/icon/NsIcon.tsx +2 -5
- package/src/common/icon/icons/AlertErrorIcon.tsx +3 -1
- package/src/common/icon/icons/ArrowDown.tsx +7 -2
- package/src/common/icon/icons/ArrowLeft.tsx +7 -2
- package/src/common/icon/icons/ArrowRight.tsx +7 -2
- package/src/common/icon/icons/ArrowUp.tsx +4 -2
- package/src/common/icon/icons/Cart.tsx +7 -2
- package/src/common/icon/icons/CartBadge.tsx +7 -2
- package/src/common/icon/icons/Check.tsx +7 -2
- package/src/common/icon/icons/CheckShield.tsx +4 -2
- package/src/common/icon/icons/CheckVerified.tsx +7 -2
- package/src/common/icon/icons/ChevronRight.tsx +9 -4
- package/src/common/icon/icons/CloseIcon.tsx +7 -2
- package/src/common/icon/icons/ErrorIcon.tsx +3 -1
- package/src/common/icon/icons/HamburgerIcon.tsx +4 -1
- package/src/common/icon/icons/InfoFilled.tsx +7 -2
- package/src/common/icon/icons/InfoOutlined.tsx +7 -2
- package/src/common/icon/icons/RoundedClose.tsx +7 -2
- package/src/common/icon/icons/SearchIcon.tsx +3 -1
- package/src/common/icon/icons/SlashIcon.tsx +7 -2
- package/src/common/icon/icons/SuccessIcon.tsx +3 -1
- package/src/common/icon/icons/TrashIcon.tsx +3 -1
- package/src/common/icon/icons/UserIcon.tsx +4 -1
- package/src/common/icon/icons/UserOutline.tsx +3 -1
- package/src/common/icon/icons/WarningIcon.tsx +3 -1
- package/src/common/icon/icons/home.tsx +4 -2
- package/src/common/image/BynderMedia.spec.tsx +42 -0
- package/src/common/image/BynderMedia.tsx +48 -0
- package/src/common/image/NsImage.tsx +3 -3
- package/src/common/image/NsNextImage.tsx +5 -2
- package/src/common/image/bynder-util.spec.ts +187 -0
- package/src/common/image/bynder-util.ts +98 -0
- package/src/common/image/index.ts +1 -1
- package/src/common/image/types.ts +78 -0
- package/src/common/input/InputWrapper.tsx +2 -1
- package/src/common/input/NsInputField.tsx +11 -3
- package/src/common/label/NsLabel.tsx +9 -4
- package/src/common/link/NsLink.stories.tsx +9 -5
- package/src/common/link/NsLink.tsx +9 -3
- package/src/common/modal/NsModal.tsx +2 -2
- package/src/common/modal/helper-component/NsModalContentBox.tsx +8 -3
- package/src/common/modal/helper-component/NsModalDefault.tsx +9 -2
- package/src/common/modal/helper-component/NsModalStatus.tsx +3 -1
- package/src/common/modal/helper-component/NsModalStatusIcon.tsx +2 -2
- package/src/common/modal/helper-component/NsModalTitle.tsx +6 -3
- package/src/common/modal/stories/NsModal.stories.tsx +9 -7
- package/src/common/nav-product-card/NsNavProductCard.spec.tsx +3 -5
- package/src/common/nav-product-card/NsNavProductCard.stories.tsx +4 -4
- package/src/common/nav-product-card/NsNavProductCard.tsx +6 -6
- package/src/common/nav-product-card/types.d.ts +2 -1
- package/src/common/nav-tab/NavDrawer.tsx +10 -3
- package/src/common/nav-tab/NavTitles.tsx +2 -2
- package/src/common/nav-tab/NsNavTab.tsx +10 -4
- package/src/common/progress/NsProgress.stories.tsx +6 -3
- package/src/common/progress/NsProgress.tsx +3 -3
- package/src/common/radiogroup/NsRadioGroup.tsx +4 -2
- package/src/common/search-bar/NsSearchBar.tsx +3 -2
- package/src/common/select/DefaultRenderOption.tsx +3 -1
- package/src/common/select/NsSelect.tsx +19 -6
- package/src/common/select/NsSelectOption.tsx +2 -2
- package/src/common/select/stories/NsSelect.stories.tsx +5 -4
- package/src/common/spinner/NsSpinner.stories.tsx +5 -2
- package/src/common/spinner/NsSpinner.tsx +3 -2
- package/src/common/spinner/icons/Spinner.tsx +3 -1
- package/src/common/table/NsExpandableRow.tsx +35 -41
- package/src/common/table/NsTable.stories.tsx +17 -23
- package/src/common/table/NsTable.tsx +27 -10
- package/src/common/table/NsTableHeader.tsx +18 -5
- package/src/common/table/NsTablePagination.tsx +7 -11
- package/src/common/text-strip/NsTextStrip.tsx +6 -3
- package/src/common/toast/Fade.tsx +5 -8
- package/src/common/toast/ToastProvider.tsx +18 -17
- package/src/common/toast/specs/Toast.spec.tsx +56 -64
- package/src/common/toast/stories/Toast.stories.tsx +12 -11
- package/src/common/typography/GlobalFontInter.tsx +7 -2
- package/src/common/typography/NsTypography.tsx +11 -4
- package/src/common/videos/NsVideo.tsx +5 -2
- package/src/common/image/types.d.ts +0 -30
|
@@ -1,18 +1,35 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
|
|
1
|
+
import React, {
|
|
2
|
+
ReactElement,
|
|
3
|
+
useEffect,
|
|
4
|
+
useState,
|
|
5
|
+
} from 'react';
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
TableBody,
|
|
9
|
+
TableCell,
|
|
10
|
+
TableRow,
|
|
11
|
+
} from '@mui/material';
|
|
12
|
+
import Grid from '@mui/material/Grid';
|
|
13
|
+
|
|
14
|
+
import {
|
|
15
|
+
getComparator,
|
|
16
|
+
stableSort,
|
|
17
|
+
} from './helper';
|
|
18
|
+
import ExpandableRow from './NsExpandableRow';
|
|
3
19
|
import {
|
|
4
|
-
StyledTable,
|
|
5
|
-
StyledTableContainer,
|
|
6
20
|
StyledEmptyRow,
|
|
7
|
-
StyledProgressCell,
|
|
8
21
|
StyledLinearProgress,
|
|
22
|
+
StyledProgressCell,
|
|
23
|
+
StyledTable,
|
|
24
|
+
StyledTableContainer,
|
|
9
25
|
} from './NsTable.styled';
|
|
10
|
-
import type { NsTableProps, Item, OrderType } from './types';
|
|
11
|
-
import { stableSort, getComparator } from './helper';
|
|
12
26
|
import NsTableHeader from './NsTableHeader';
|
|
13
27
|
import NsTablePagination from './NsTablePagination';
|
|
14
|
-
import
|
|
15
|
-
|
|
28
|
+
import type {
|
|
29
|
+
Item,
|
|
30
|
+
NsTableProps,
|
|
31
|
+
OrderType,
|
|
32
|
+
} from './types';
|
|
16
33
|
|
|
17
34
|
export default function NsTable({
|
|
18
35
|
headers = [],
|
|
@@ -26,7 +43,7 @@ export default function NsTable({
|
|
|
26
43
|
showExpandedContent = true,
|
|
27
44
|
loading = false,
|
|
28
45
|
isExpandableAll = false,
|
|
29
|
-
}: NsTableProps) {
|
|
46
|
+
}: NsTableProps): ReactElement {
|
|
30
47
|
const [order, setOrder] = useState<OrderType>('asc');
|
|
31
48
|
const [orderBy, setOrderBy] = useState<keyof Item>(itemKey);
|
|
32
49
|
const [expandMap, setExpandMap] = useState<{ [key: number]: boolean }>({});
|
|
@@ -1,10 +1,23 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import React, { ReactElement } from 'react';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
Box,
|
|
5
|
+
TableCell,
|
|
6
|
+
TableHead,
|
|
7
|
+
TableRow,
|
|
8
|
+
} from '@mui/material';
|
|
5
9
|
import { visuallyHidden } from '@mui/utils';
|
|
6
10
|
|
|
7
|
-
|
|
11
|
+
import {
|
|
12
|
+
StyledTableLabel,
|
|
13
|
+
StyledTableSortLabel,
|
|
14
|
+
} from './NsTable.styled';
|
|
15
|
+
import type {
|
|
16
|
+
Item,
|
|
17
|
+
NsTableHeaderProps,
|
|
18
|
+
} from './types';
|
|
19
|
+
|
|
20
|
+
export default function NsTableHeader(props: NsTableHeaderProps): ReactElement {
|
|
8
21
|
const { order, orderBy, headCells, onRequestSort } = props;
|
|
9
22
|
const createSortHandler = (property: keyof Item) => (event: React.MouseEvent<unknown>) => {
|
|
10
23
|
onRequestSort(event, property);
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import React from 'react'
|
|
3
|
-
import { StyledPagination } from './NsTable.styled'
|
|
1
|
+
import React, { ReactElement } from 'react';
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
onPageChange,
|
|
11
|
-
} = props;
|
|
3
|
+
import { StyledPagination } from './NsTable.styled';
|
|
4
|
+
import type { NsTablePaginationProps } from './types';
|
|
5
|
+
|
|
6
|
+
export default function NsTablePagination(props: NsTablePaginationProps): ReactElement {
|
|
7
|
+
const { count, rowsPerPage, page, onPageChange } = props;
|
|
12
8
|
|
|
13
9
|
const totalPage = Math.ceil(count / rowsPerPage);
|
|
14
10
|
const handleChange = (event: React.ChangeEvent<unknown>, value: number) => {
|
|
@@ -18,7 +14,7 @@ export default function NsTablePagination(props: NsTablePaginationProps) {
|
|
|
18
14
|
return (
|
|
19
15
|
<StyledPagination
|
|
20
16
|
count={totalPage}
|
|
21
|
-
page={page}
|
|
17
|
+
page={page}
|
|
22
18
|
variant="outlined"
|
|
23
19
|
onChange={handleChange}
|
|
24
20
|
shape="rounded"
|
|
@@ -3,9 +3,12 @@
|
|
|
3
3
|
* @description NsTextStrip component for scrolling text CTA
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import React from 'react';
|
|
6
|
+
import React, { ReactElement } from 'react';
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
ColorUtils,
|
|
10
|
+
styled,
|
|
11
|
+
} from '@nuskin/foundation-theme';
|
|
9
12
|
|
|
10
13
|
import { NsLink } from '../link';
|
|
11
14
|
import { NsTypography } from '../typography';
|
|
@@ -33,7 +36,7 @@ const StyledHeader = styled(NsLink)`
|
|
|
33
36
|
}
|
|
34
37
|
`;
|
|
35
38
|
|
|
36
|
-
const NsTextStrip = (props: NsTextStripProps) => {
|
|
39
|
+
const NsTextStrip = (props: NsTextStripProps): ReactElement => {
|
|
37
40
|
const { alignment = 'center', description, link, className = '' } = props;
|
|
38
41
|
|
|
39
42
|
return (
|
|
@@ -2,13 +2,10 @@
|
|
|
2
2
|
* Credit to MUI team @ https://mui.com
|
|
3
3
|
*/
|
|
4
4
|
import * as React from 'react';
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
getTransitionProps,
|
|
10
|
-
createTransition,
|
|
11
|
-
} from './shared';
|
|
5
|
+
|
|
6
|
+
import { Transition, TransitionProps, TransitionStatus } from 'notistack';
|
|
7
|
+
|
|
8
|
+
import { createTransition, getTransitionProps, reflow, useForkRef } from './shared';
|
|
12
9
|
|
|
13
10
|
const styles: Partial<Record<TransitionStatus, React.CSSProperties>> = {
|
|
14
11
|
entering: {
|
|
@@ -19,7 +16,7 @@ const styles: Partial<Record<TransitionStatus, React.CSSProperties>> = {
|
|
|
19
16
|
},
|
|
20
17
|
};
|
|
21
18
|
|
|
22
|
-
const Fade = React.forwardRef<HTMLDivElement, TransitionProps>((props, ref) => {
|
|
19
|
+
const Fade = React.forwardRef<HTMLDivElement, TransitionProps>((props, ref): React.ReactElement => {
|
|
23
20
|
const {
|
|
24
21
|
children,
|
|
25
22
|
in: inProp,
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { PropsWithChildren } from 'react';
|
|
2
|
-
import { SnackbarProvider, SnackbarProviderProps, MaterialDesignContent } from 'notistack';
|
|
1
|
+
import type { PropsWithChildren, ReactElement } from 'react';
|
|
3
2
|
|
|
4
|
-
import {
|
|
3
|
+
import { MaterialDesignContent, SnackbarProvider, SnackbarProviderProps } from 'notistack';
|
|
4
|
+
|
|
5
|
+
import { ColorUtils, ScreenSize, styled } from '@nuskin/foundation-theme';
|
|
5
6
|
|
|
6
7
|
const { getGenomeColor } = ColorUtils;
|
|
7
8
|
|
|
@@ -10,7 +11,7 @@ const ToastNotification = styled(MaterialDesignContent)`
|
|
|
10
11
|
height: 46px;
|
|
11
12
|
box-shadow: none;
|
|
12
13
|
padding: 0 20px;
|
|
13
|
-
|
|
14
|
+
|
|
14
15
|
.toast-message-wrapper {
|
|
15
16
|
width: 440px;
|
|
16
17
|
text-overflow: ellipsis;
|
|
@@ -67,21 +68,21 @@ const ToastNotification = styled(MaterialDesignContent)`
|
|
|
67
68
|
}
|
|
68
69
|
`;
|
|
69
70
|
|
|
70
|
-
const NsToastProvider = (props: PropsWithChildren<SnackbarProviderProps>) => {
|
|
71
|
-
const {
|
|
72
|
-
children,
|
|
73
|
-
autoHideDuration = 5000
|
|
74
|
-
} = props;
|
|
71
|
+
const NsToastProvider = (props: PropsWithChildren<SnackbarProviderProps>): ReactElement => {
|
|
72
|
+
const { children, autoHideDuration = 5000 } = props;
|
|
75
73
|
return (
|
|
76
|
-
<SnackbarProvider
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
74
|
+
<SnackbarProvider
|
|
75
|
+
autoHideDuration={autoHideDuration}
|
|
76
|
+
Components={{
|
|
77
|
+
success: ToastNotification,
|
|
78
|
+
error: ToastNotification,
|
|
79
|
+
info: ToastNotification,
|
|
80
|
+
warning: ToastNotification,
|
|
81
|
+
}}
|
|
82
|
+
>
|
|
83
|
+
{children}
|
|
83
84
|
</SnackbarProvider>
|
|
84
85
|
);
|
|
85
86
|
};
|
|
86
87
|
|
|
87
|
-
export default NsToastProvider;
|
|
88
|
+
export default NsToastProvider;
|
|
@@ -5,126 +5,118 @@ import React, { PropsWithChildren, useEffect } from 'react';
|
|
|
5
5
|
import { NsToastProvider, ToastOptions, useToast } from '../';
|
|
6
6
|
|
|
7
7
|
const ToastWrapper = ({ children }: PropsWithChildren<{}>) => {
|
|
8
|
-
return
|
|
9
|
-
|
|
10
|
-
{ children }
|
|
11
|
-
</NsToastProvider>
|
|
12
|
-
);
|
|
13
|
-
}
|
|
8
|
+
return <NsToastProvider>{children}</NsToastProvider>;
|
|
9
|
+
};
|
|
14
10
|
|
|
15
|
-
const ToastComponent = (props: {
|
|
16
|
-
variant: VariantType;
|
|
17
|
-
message?: string;
|
|
18
|
-
options?: ToastOptions;
|
|
19
|
-
}) => {
|
|
11
|
+
const ToastComponent = (props: { variant: VariantType; message?: string; options?: ToastOptions }) => {
|
|
20
12
|
const { showToast } = useToast();
|
|
21
|
-
const {
|
|
22
|
-
variant,
|
|
23
|
-
message,
|
|
24
|
-
options,
|
|
25
|
-
} = props;
|
|
13
|
+
const { variant, message, options } = props;
|
|
26
14
|
useEffect(() => {
|
|
27
15
|
showToast(variant, message, options);
|
|
28
|
-
|
|
16
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
29
17
|
}, []);
|
|
30
|
-
return
|
|
31
|
-
<div></div>
|
|
32
|
-
);
|
|
18
|
+
return <div></div>;
|
|
33
19
|
};
|
|
34
20
|
|
|
35
21
|
describe('Toast', () => {
|
|
36
22
|
afterEach(() => {
|
|
37
23
|
closeSnackbar();
|
|
38
24
|
});
|
|
39
|
-
it('should render a toast and displays the message', () => {
|
|
25
|
+
it('1. should render a toast and displays the message', () => {
|
|
40
26
|
render(
|
|
41
27
|
<ToastWrapper>
|
|
42
|
-
<ToastComponent variant=
|
|
28
|
+
<ToastComponent variant="success" message="Hello" />
|
|
43
29
|
</ToastWrapper>
|
|
44
30
|
);
|
|
45
31
|
expect(screen.queryByText('Hello')).toBeInTheDocument();
|
|
46
|
-
});
|
|
47
|
-
it('should render a success toast', () => {
|
|
32
|
+
}, 100000);
|
|
33
|
+
it('2. should render a success toast', () => {
|
|
48
34
|
const { container } = render(
|
|
49
35
|
<ToastWrapper>
|
|
50
|
-
<ToastComponent variant=
|
|
36
|
+
<ToastComponent variant="success" message="Hello" />
|
|
51
37
|
</ToastWrapper>
|
|
52
38
|
);
|
|
53
39
|
expect(container.querySelector('.notistack-MuiContent-success')).toBeInTheDocument();
|
|
54
|
-
});
|
|
55
|
-
it('should render a error toast', () => {
|
|
40
|
+
}, 100000);
|
|
41
|
+
it('3. should render a error toast', () => {
|
|
56
42
|
const { container } = render(
|
|
57
43
|
<ToastWrapper>
|
|
58
|
-
<ToastComponent variant=
|
|
44
|
+
<ToastComponent variant="error" message="Hello" />
|
|
59
45
|
</ToastWrapper>
|
|
60
46
|
);
|
|
61
47
|
expect(container.querySelector('.notistack-MuiContent-error')).toBeInTheDocument();
|
|
62
|
-
});
|
|
63
|
-
it('should render a info toast', () => {
|
|
48
|
+
}, 100000);
|
|
49
|
+
it('4. should render a info toast', () => {
|
|
64
50
|
const { container } = render(
|
|
65
51
|
<ToastWrapper>
|
|
66
|
-
<ToastComponent variant=
|
|
52
|
+
<ToastComponent variant="info" message="Hello" />
|
|
67
53
|
</ToastWrapper>
|
|
68
54
|
);
|
|
69
55
|
expect(container.querySelector('.notistack-MuiContent-info')).toBeInTheDocument();
|
|
70
|
-
});
|
|
71
|
-
it('it should render a warning toast', () => {
|
|
56
|
+
}, 100000);
|
|
57
|
+
it('5. it should render a warning toast', () => {
|
|
72
58
|
const { container } = render(
|
|
73
59
|
<ToastWrapper>
|
|
74
|
-
<ToastComponent variant=
|
|
60
|
+
<ToastComponent variant="warning" message="Hello" />
|
|
75
61
|
</ToastWrapper>
|
|
76
62
|
);
|
|
77
63
|
expect(container.querySelector('.notistack-MuiContent-warning')).toBeInTheDocument();
|
|
78
|
-
});
|
|
79
|
-
it('should render a warning toast and disappear after 3 seconds', async () => {
|
|
64
|
+
}, 100000);
|
|
65
|
+
it('6. should render a warning toast and disappear after 3 seconds', async () => {
|
|
80
66
|
const { container } = render(
|
|
81
67
|
<ToastWrapper>
|
|
82
|
-
<ToastComponent variant=
|
|
68
|
+
<ToastComponent variant="warning" message="Hello" options={{ autoHideDuration: 3000 }} />
|
|
83
69
|
</ToastWrapper>
|
|
84
70
|
);
|
|
85
71
|
expect(container.querySelector('.notistack-MuiContent-warning')).toBeInTheDocument();
|
|
86
72
|
await new Promise((r) => setTimeout(r, 4000));
|
|
87
73
|
expect(container.querySelector('.notistack-MuiContent-warning')).not.toBeInTheDocument();
|
|
88
|
-
});
|
|
89
|
-
it('should render a action buttons', async () => {
|
|
90
|
-
|
|
74
|
+
}, 100000);
|
|
75
|
+
it('7. should render a action buttons', async () => {
|
|
91
76
|
const { getByTestId } = render(
|
|
92
77
|
<ToastWrapper>
|
|
93
|
-
<ToastComponent
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
78
|
+
<ToastComponent
|
|
79
|
+
variant="warning"
|
|
80
|
+
message="Hello"
|
|
81
|
+
options={{
|
|
82
|
+
actions: [
|
|
83
|
+
{
|
|
84
|
+
label: 'Undo',
|
|
85
|
+
onClick: () => alert('Undo clicked'),
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
}}
|
|
89
|
+
/>
|
|
99
90
|
</ToastWrapper>
|
|
100
91
|
);
|
|
101
92
|
expect(getByTestId('action-button')).toBeInTheDocument();
|
|
102
|
-
});
|
|
103
|
-
it('should render close button', async () => {
|
|
93
|
+
}, 100000);
|
|
94
|
+
it('8. should render close button', async () => {
|
|
104
95
|
const { getByTestId } = render(
|
|
105
96
|
<ToastWrapper>
|
|
106
|
-
<ToastComponent variant=
|
|
107
|
-
{showCloseIcon: true,}}
|
|
108
|
-
/>
|
|
97
|
+
<ToastComponent variant="warning" message="Hello" options={{ showCloseIcon: true }} />
|
|
109
98
|
</ToastWrapper>
|
|
110
99
|
);
|
|
111
100
|
expect(getByTestId('icon')).toBeInTheDocument();
|
|
112
|
-
});
|
|
113
|
-
it('should render a action buttons and close button', async () => {
|
|
114
|
-
|
|
101
|
+
}, 100000);
|
|
102
|
+
it('9. should render a action buttons and close button', async () => {
|
|
115
103
|
const { getAllByRole } = render(
|
|
116
104
|
<ToastWrapper>
|
|
117
|
-
<ToastComponent
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
105
|
+
<ToastComponent
|
|
106
|
+
variant="warning"
|
|
107
|
+
message="Hello"
|
|
108
|
+
options={{
|
|
109
|
+
actions: [
|
|
110
|
+
{
|
|
111
|
+
label: 'Undo',
|
|
112
|
+
onClick: () => alert('Undo clicked'),
|
|
113
|
+
},
|
|
114
|
+
],
|
|
115
|
+
showCloseIcon: true,
|
|
116
|
+
}}
|
|
117
|
+
/>
|
|
126
118
|
</ToastWrapper>
|
|
127
119
|
);
|
|
128
120
|
expect(getAllByRole('button')?.length).toBe(2);
|
|
129
|
-
});
|
|
121
|
+
}, 100000);
|
|
130
122
|
});
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { ReactElement } from 'react';
|
|
2
|
+
|
|
2
3
|
import { VariantType } from 'notistack';
|
|
3
|
-
|
|
4
|
-
import {
|
|
4
|
+
|
|
5
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
6
|
+
|
|
7
|
+
import { NsToastProvider, ToastOptions, useToast } from '../';
|
|
5
8
|
|
|
6
9
|
type ComponentType = typeof NsToastProvider;
|
|
7
10
|
type Story = StoryObj<ComponentType>;
|
|
@@ -13,15 +16,15 @@ type ToastProps = {
|
|
|
13
16
|
options?: ToastOptions;
|
|
14
17
|
};
|
|
15
18
|
|
|
16
|
-
const ToastDecorator = (Story: React.FC) => {
|
|
19
|
+
const ToastDecorator = (Story: React.FC): ReactElement => {
|
|
17
20
|
return (
|
|
18
21
|
<NsToastProvider>
|
|
19
22
|
<Story />
|
|
20
23
|
</NsToastProvider>
|
|
21
|
-
)
|
|
24
|
+
);
|
|
22
25
|
};
|
|
23
26
|
|
|
24
|
-
const ToastComponent = (props: ToastProps) => {
|
|
27
|
+
const ToastComponent = (props: ToastProps): ReactElement => {
|
|
25
28
|
const {
|
|
26
29
|
variant,
|
|
27
30
|
message = 'Toast Demo',
|
|
@@ -37,9 +40,7 @@ const ToastComponent = (props: ToastProps) => {
|
|
|
37
40
|
|
|
38
41
|
return (
|
|
39
42
|
<div>
|
|
40
|
-
<button onClick={toastHandler}>
|
|
41
|
-
Show Toast
|
|
42
|
-
</button>
|
|
43
|
+
<button onClick={toastHandler}>Show Toast</button>
|
|
43
44
|
</div>
|
|
44
45
|
);
|
|
45
46
|
};
|
|
@@ -59,7 +60,7 @@ export default {
|
|
|
59
60
|
actions: {
|
|
60
61
|
description: 'The buttons should be passed to the Toast element',
|
|
61
62
|
},
|
|
62
|
-
}
|
|
63
|
+
},
|
|
63
64
|
},
|
|
64
65
|
args: {
|
|
65
66
|
variant: 'error',
|
|
@@ -74,7 +75,7 @@ export default {
|
|
|
74
75
|
onClick: () => alert('Undo clicked'),
|
|
75
76
|
},
|
|
76
77
|
],
|
|
77
|
-
}
|
|
78
|
+
},
|
|
78
79
|
},
|
|
79
80
|
} as MetaStory;
|
|
80
81
|
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import {
|
|
4
|
+
css,
|
|
5
|
+
GlobalStyles,
|
|
6
|
+
} from '@nuskin/foundation-theme';
|
|
7
|
+
|
|
8
|
+
const GlobalFontInter = (): ReactElement => (
|
|
4
9
|
<GlobalStyles
|
|
5
10
|
styles={css`
|
|
6
11
|
@import url('https://fonts.googleapis.com/css2?family=Inter');
|
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import React, {
|
|
2
|
+
PropsWithChildren,
|
|
3
|
+
ReactElement,
|
|
4
|
+
} from 'react';
|
|
5
|
+
|
|
4
6
|
import HtmlTagVariantMapping from './HtmlTagVariantMap';
|
|
7
|
+
import {
|
|
8
|
+
HtmlTagVariant,
|
|
9
|
+
NsTypographyProps,
|
|
10
|
+
} from './types.d';
|
|
11
|
+
import { StyledTypography } from './Typography.styled';
|
|
5
12
|
|
|
6
13
|
const NsTypography = ({
|
|
7
14
|
children,
|
|
@@ -14,7 +21,7 @@ const NsTypography = ({
|
|
|
14
21
|
colorOverride = '',
|
|
15
22
|
noSpacing = false,
|
|
16
23
|
renderHTMLNode,
|
|
17
|
-
}: PropsWithChildren<NsTypographyProps>) => {
|
|
24
|
+
}: PropsWithChildren<NsTypographyProps>): ReactElement => {
|
|
18
25
|
const htmlTagVariant: HtmlTagVariant | undefined = renderHTMLNode ? HtmlTagVariantMapping[variant] : undefined;
|
|
19
26
|
|
|
20
27
|
return (
|
|
@@ -4,11 +4,14 @@
|
|
|
4
4
|
* @description NsVideo component with a Iframe video url props
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
PropsWithChildren,
|
|
9
|
+
ReactElement,
|
|
10
|
+
} from 'react';
|
|
8
11
|
|
|
9
12
|
import { NsVideoProps } from './types.d';
|
|
10
13
|
|
|
11
|
-
const NsVideo = (props: PropsWithChildren<NsVideoProps>) => {
|
|
14
|
+
const NsVideo = (props: PropsWithChildren<NsVideoProps>): ReactElement => {
|
|
12
15
|
const { src, title, width, height, allowFullScreen } = props;
|
|
13
16
|
return (
|
|
14
17
|
<iframe
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { ImageProps } from 'next/image';
|
|
2
|
-
|
|
3
|
-
export type NsNextImageProps = Pick<
|
|
4
|
-
ImageProps,
|
|
5
|
-
| 'src'
|
|
6
|
-
| 'height'
|
|
7
|
-
| 'width'
|
|
8
|
-
| 'alt'
|
|
9
|
-
| 'priority'
|
|
10
|
-
| 'sizes'
|
|
11
|
-
| 'quality'
|
|
12
|
-
| 'placeholder'
|
|
13
|
-
| 'style'
|
|
14
|
-
| 'loading'
|
|
15
|
-
| 'blurDataURL'
|
|
16
|
-
| 'fill'
|
|
17
|
-
| 'unoptimized'
|
|
18
|
-
| 'loader'
|
|
19
|
-
> & { id?: string; className?: string };
|
|
20
|
-
|
|
21
|
-
export type NsImageProps = {
|
|
22
|
-
alt: string;
|
|
23
|
-
className?: string;
|
|
24
|
-
fill?: boolean;
|
|
25
|
-
height?: number | string;
|
|
26
|
-
id?: string;
|
|
27
|
-
src: string;
|
|
28
|
-
variant?: 'product' | 'award' | 'icon' | 'fill';
|
|
29
|
-
width?: number | string;
|
|
30
|
-
};
|