@nuskin/foundation-ui-components 1.6.0 → 1.7.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 -1
- package/src/common/autocomplete/NsAutocomplete.styled.tsx +5 -1
- package/src/common/autocomplete/NsAutocomplete.tsx +19 -71
- package/src/common/autocomplete/helper/ClearButton.tsx +22 -0
- package/src/common/autocomplete/helper/SeeMoreButton.tsx +47 -0
- package/src/common/autocomplete/helper/renderGroupName.tsx +17 -0
- package/src/common/autocomplete/stories/ACWithoutClose.tsx +49 -0
- package/src/common/autocomplete/stories/NsAutocomplete.stories.tsx +76 -0
- package/src/common/autocomplete/stories/RenderAutoComplete.tsx +60 -0
- package/src/common/autocomplete/types.d.ts +1 -1
- package/src/common/card/NsBrandCard.tsx +94 -0
- package/src/common/card/NsCheckoutCard.tsx +92 -0
- package/src/common/card/NsHeroCardLevel1.tsx +106 -0
- package/src/common/card/NsHeroCardLevel2.tsx +126 -0
- package/src/common/card/NsIconText.tsx +153 -0
- package/src/common/card/NsLargeCard.tsx +120 -0
- package/src/common/card/NsMediumCard.tsx +64 -0
- package/src/common/card/NsPost.tsx +60 -0
- package/src/common/card/NsSmallFullCard.tsx +90 -0
- package/src/common/card/NsXLargeCard.tsx +80 -0
- package/src/common/card/cardSizes.ts +12 -0
- package/src/common/card/index.ts +10 -2
- package/src/common/card/specs/BrandLogo.spec.tsx +1 -1
- package/src/common/card/specs/NsBgCard.spec.tsx +2 -2
- package/src/common/card/specs/NsBrandCard.spec.tsx +97 -0
- package/src/common/card/specs/NsCheckoutCard.spec.tsx +50 -0
- package/src/common/card/specs/NsHeroCardLevel1.spec.tsx +48 -0
- package/src/common/card/specs/NsHeroCardLevel2.spec.tsx +51 -0
- package/src/common/card/specs/NsIconText.spec.tsx +28 -0
- package/src/common/card/specs/NsLargeCard.spec.tsx +41 -0
- package/src/common/card/specs/NsMediumCard.spec.tsx +35 -0
- package/src/common/card/specs/NsPost.spec.tsx +31 -0
- package/src/common/card/specs/NsSmallFullCard.spec.tsx +36 -0
- package/src/common/card/specs/NsXLargeCard.spec.tsx +35 -0
- package/src/common/card/stories/{NsBrandProductCard.stories.tsx → NsBrandCard.stories.tsx} +9 -4
- package/src/common/card/stories/NsCheckoutCard.stories.tsx +24 -0
- package/src/common/card/stories/NsHeroCardLevel1.stories.tsx +45 -0
- package/src/common/card/stories/NsHeroCardLevel2.stories.tsx +50 -0
- package/src/common/card/stories/NsIconText.stories.tsx +36 -0
- package/src/common/card/stories/NsLargeCard.stories.tsx +32 -0
- package/src/common/card/stories/NsMediumCard.stories.tsx +29 -0
- package/src/common/card/stories/NsPost.stories.tsx +39 -0
- package/src/common/card/stories/NsSmallFullCard.stories.tsx +29 -0
- package/src/common/card/stories/NsXLargeCard.stories.tsx +29 -0
- package/src/common/carousal/RenderBrand.tsx +3 -2
- package/src/common/input/InputWrapper.tsx +1 -1
- package/src/common/autocomplete/NsAutocomplete.stories.tsx +0 -108
- package/src/common/card/NsBrandProductCard.tsx +0 -47
- package/src/common/card/NsFfgCard.tsx +0 -24
- package/src/common/card/specs/NsBrandProductCard.spec.tsx +0 -32
- package/src/common/card/specs/NsFfgCard.spec.tsx +0 -33
- package/src/common/card/stories/NsBgCard.stories.tsx +0 -20
- package/src/common/card/stories/NsFfgCard.stories.tsx +0 -73
- package/src/common/card/styled/NsFfgStyled.tsx +0 -46
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import NsXLargeCard from '../NsXLargeCard';
|
|
4
|
+
|
|
5
|
+
describe('NsXLargeCard component', () => {
|
|
6
|
+
const props = {
|
|
7
|
+
title: 'Sample Title',
|
|
8
|
+
subtitle: 'Sample Subtitle',
|
|
9
|
+
backgroundImageUrl: 'https://example.com/image.jpg',
|
|
10
|
+
backgroundImageAlt: 'Sample Alt Text',
|
|
11
|
+
cardLink: {
|
|
12
|
+
href: 'https://www.example.com',
|
|
13
|
+
title: 'Sample Link Text',
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
it('1. renders with correct content and styles', () => {
|
|
18
|
+
render(<NsXLargeCard {...props} />);
|
|
19
|
+
|
|
20
|
+
const xLargeCard = screen.getByTestId('x-large-card');
|
|
21
|
+
expect(xLargeCard).toBeInTheDocument();
|
|
22
|
+
|
|
23
|
+
const subtitleElement = screen.getByText('Sample Subtitle');
|
|
24
|
+
expect(subtitleElement).toBeInTheDocument();
|
|
25
|
+
|
|
26
|
+
const titleElement = screen.getByText('Sample Title');
|
|
27
|
+
expect(titleElement).toBeInTheDocument();
|
|
28
|
+
|
|
29
|
+
const imageElement = screen.getByAltText('Sample Alt Text');
|
|
30
|
+
expect(imageElement).toBeInTheDocument();
|
|
31
|
+
|
|
32
|
+
const linkElement = screen.getByText('Sample Link Text');
|
|
33
|
+
expect(linkElement).toBeInTheDocument();
|
|
34
|
+
});
|
|
35
|
+
});
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { StoryObj, Meta } from '@storybook/react';
|
|
2
2
|
import { withCenterDecorator } from '@/stories/decorators/withCenterDecorator';
|
|
3
|
-
import {
|
|
3
|
+
import { NsBrandCard } from '../';
|
|
4
4
|
|
|
5
|
-
type ComponentType = typeof
|
|
5
|
+
type ComponentType = typeof NsBrandCard;
|
|
6
6
|
type Story = StoryObj<ComponentType>;
|
|
7
7
|
type MetaStory = Meta<ComponentType>;
|
|
8
8
|
|
|
9
9
|
export default {
|
|
10
|
-
component:
|
|
11
|
-
title: 'Components/Containers/Card/
|
|
10
|
+
component: NsBrandCard,
|
|
11
|
+
title: 'Components/Containers/Card/NsBrandCard',
|
|
12
12
|
argTypes: {},
|
|
13
13
|
decorators: [withCenterDecorator],
|
|
14
14
|
} as MetaStory;
|
|
@@ -18,5 +18,10 @@ export const Default: Story = {
|
|
|
18
18
|
title: 'ageLOC LumiSpa',
|
|
19
19
|
backgroundImageUrl: 'https://media.nuskin.com/m/3604b5202b0b64c6/webimage-brand-lumispa-optweb.png',
|
|
20
20
|
brandImageUrl: 'https://media.nuskin.com/m/2571a0407433a6e8/webimage-brand-lumispa.png',
|
|
21
|
+
size: 'large',
|
|
22
|
+
button: true,
|
|
23
|
+
onClick: () => {
|
|
24
|
+
console.log('onClick called');
|
|
25
|
+
},
|
|
21
26
|
},
|
|
22
27
|
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { StoryObj, Meta } from '@storybook/react';
|
|
2
|
+
import { withCenterDecorator } from '@/stories/decorators/withCenterDecorator';
|
|
3
|
+
import { NsCheckoutCard } from '../';
|
|
4
|
+
|
|
5
|
+
type ComponentType = typeof NsCheckoutCard;
|
|
6
|
+
type Story = StoryObj<ComponentType>;
|
|
7
|
+
type MetaStory = Meta<ComponentType>;
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
component: NsCheckoutCard,
|
|
11
|
+
title: 'Components/Containers/Card/NsCheckoutCard',
|
|
12
|
+
argTypes: {
|
|
13
|
+
onClick: { action: 'clicked' },
|
|
14
|
+
},
|
|
15
|
+
decorators: [withCenterDecorator],
|
|
16
|
+
} as MetaStory;
|
|
17
|
+
|
|
18
|
+
export const Default: Story = {
|
|
19
|
+
args: {
|
|
20
|
+
title: 'Section Title',
|
|
21
|
+
address: 'Address',
|
|
22
|
+
icon: 'home',
|
|
23
|
+
},
|
|
24
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { StoryObj, Meta } from '@storybook/react';
|
|
2
|
+
import { within, userEvent } from '@storybook/testing-library';
|
|
3
|
+
import { expect } from '@storybook/jest';
|
|
4
|
+
import { withCenterDecorator } from '@/stories/decorators/withCenterDecorator';
|
|
5
|
+
import { NsHeroCardLevel1 } from '../';
|
|
6
|
+
|
|
7
|
+
type ComponentType = typeof NsHeroCardLevel1;
|
|
8
|
+
type Story = StoryObj<ComponentType>;
|
|
9
|
+
type MetaStory = Meta<ComponentType>;
|
|
10
|
+
|
|
11
|
+
export default {
|
|
12
|
+
component: NsHeroCardLevel1,
|
|
13
|
+
title: 'Components/Containers/Card/NsHeroCardLevel1',
|
|
14
|
+
argTypes: {
|
|
15
|
+
onClick: { action: 'clicked' },
|
|
16
|
+
},
|
|
17
|
+
decorators: [withCenterDecorator],
|
|
18
|
+
} as MetaStory;
|
|
19
|
+
|
|
20
|
+
const text = 'A skin ready for winter';
|
|
21
|
+
const body = 'We have brought these discoveries to life through our powerful skin care products and supplements.';
|
|
22
|
+
const host = 'https://media.nuskin.com/';
|
|
23
|
+
|
|
24
|
+
export const Default: Story = {
|
|
25
|
+
args: {
|
|
26
|
+
cardLink: {
|
|
27
|
+
href: 'https://www.forceforgood.org/',
|
|
28
|
+
title: 'SHOP NOW',
|
|
29
|
+
},
|
|
30
|
+
text,
|
|
31
|
+
body,
|
|
32
|
+
backgroundImageUrl: `${host}m/9734240cc191163/webimage-lash-brow-serum-carousel-image-launch.png`,
|
|
33
|
+
backgroundImageAlt: 'lash brow serum carousel',
|
|
34
|
+
additionalProps: {
|
|
35
|
+
testid: 'hero-card-level-1',
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
play: async ({ canvasElement }: any) => {
|
|
39
|
+
const canvas = within(canvasElement);
|
|
40
|
+
userEvent.hover(canvas.getByTestId('hero-card-level-1'));
|
|
41
|
+
userEvent.hover(canvas.getByRole('link'));
|
|
42
|
+
expect(canvas.getByText(text)).toBeInTheDocument();
|
|
43
|
+
expect(canvas.getByText(body)).toBeInTheDocument();
|
|
44
|
+
},
|
|
45
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { StoryObj, Meta } from '@storybook/react';
|
|
2
|
+
import { within, userEvent } from '@storybook/testing-library';
|
|
3
|
+
import { expect } from '@storybook/jest';
|
|
4
|
+
import { withCenterDecorator } from '@/stories/decorators/withCenterDecorator';
|
|
5
|
+
import { NsHeroCardLevel2 } from '../';
|
|
6
|
+
|
|
7
|
+
type ComponentType = typeof NsHeroCardLevel2;
|
|
8
|
+
type Story = StoryObj<ComponentType>;
|
|
9
|
+
type MetaStory = Meta<ComponentType>;
|
|
10
|
+
|
|
11
|
+
export default {
|
|
12
|
+
component: NsHeroCardLevel2,
|
|
13
|
+
title: 'Components/Containers/Card/NsHeroCardLevel2',
|
|
14
|
+
argTypes: {
|
|
15
|
+
onClick: { action: 'clicked' },
|
|
16
|
+
},
|
|
17
|
+
decorators: [withCenterDecorator],
|
|
18
|
+
} as MetaStory;
|
|
19
|
+
|
|
20
|
+
const text = 'Current shop deals';
|
|
21
|
+
const body = 'Lumispa, sunscreen and more';
|
|
22
|
+
const icon = 'home';
|
|
23
|
+
const brand = 'Beauty focus™';
|
|
24
|
+
const host = 'https://media.nuskin.com/';
|
|
25
|
+
|
|
26
|
+
export const Default: Story = {
|
|
27
|
+
args: {
|
|
28
|
+
cardLink: {
|
|
29
|
+
href: 'https://www.forceforgood.org/',
|
|
30
|
+
title: 'Discover more',
|
|
31
|
+
},
|
|
32
|
+
text,
|
|
33
|
+
body,
|
|
34
|
+
icon,
|
|
35
|
+
brand,
|
|
36
|
+
backgroundImageUrl: `${host}m/5f1c423bb57589f0/webimage-autumn-sale-carousel.png`,
|
|
37
|
+
backgroundImageAlt: 'lash brow serum carousel',
|
|
38
|
+
additionalProps: {
|
|
39
|
+
testid: 'hero-card-level-2',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
play: async ({ canvasElement }: any) => {
|
|
43
|
+
const canvas = within(canvasElement);
|
|
44
|
+
userEvent.hover(canvas.getByTestId('hero-card-level-2'));
|
|
45
|
+
userEvent.hover(canvas.getByRole('link'));
|
|
46
|
+
expect(canvas.getByText(text)).toBeInTheDocument();
|
|
47
|
+
expect(canvas.getByText(body)).toBeInTheDocument();
|
|
48
|
+
expect(canvas.getByText(brand)).toBeInTheDocument();
|
|
49
|
+
},
|
|
50
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { StoryObj, Meta } from '@storybook/react';
|
|
2
|
+
import { within, userEvent } from '@storybook/testing-library';
|
|
3
|
+
import { expect } from '@storybook/jest';
|
|
4
|
+
import { withCenterDecorator } from '@/stories/decorators/withCenterDecorator';
|
|
5
|
+
import { NsIconText } from '../';
|
|
6
|
+
|
|
7
|
+
type ComponentType = typeof NsIconText;
|
|
8
|
+
type Story = StoryObj<ComponentType>;
|
|
9
|
+
type MetaStory = Meta<ComponentType>;
|
|
10
|
+
|
|
11
|
+
export default {
|
|
12
|
+
component: NsIconText,
|
|
13
|
+
title: 'Components/Containers/Card/NsIconText',
|
|
14
|
+
argTypes: {},
|
|
15
|
+
decorators: [withCenterDecorator],
|
|
16
|
+
} as MetaStory;
|
|
17
|
+
|
|
18
|
+
const text = 'Lorem ipsum';
|
|
19
|
+
const body = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Natoque lacus, in amet nunc. ';
|
|
20
|
+
|
|
21
|
+
export const Default: Story = {
|
|
22
|
+
args: {
|
|
23
|
+
text,
|
|
24
|
+
body,
|
|
25
|
+
additionalProps: {
|
|
26
|
+
testid: 'icon-text-card',
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
play: async ({ canvasElement }: any) => {
|
|
30
|
+
const canvas = within(canvasElement);
|
|
31
|
+
userEvent.hover(canvas.getByTestId('icon-text-card'));
|
|
32
|
+
userEvent.hover(canvas.getByRole('link'));
|
|
33
|
+
expect(canvas.getByText(text)).toBeInTheDocument();
|
|
34
|
+
expect(canvas.getByText(body)).toBeInTheDocument();
|
|
35
|
+
},
|
|
36
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { StoryObj, Meta } from '@storybook/react';
|
|
2
|
+
import { withCenterDecorator } from '@/stories/decorators/withCenterDecorator';
|
|
3
|
+
import { NsLargeCard } from '../';
|
|
4
|
+
|
|
5
|
+
type ComponentType = typeof NsLargeCard;
|
|
6
|
+
type Story = StoryObj<ComponentType>;
|
|
7
|
+
type MetaStory = Meta<ComponentType>;
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
component: NsLargeCard,
|
|
11
|
+
title: 'Components/Containers/Card/NsLargeCard',
|
|
12
|
+
argTypes: {},
|
|
13
|
+
decorators: [withCenterDecorator],
|
|
14
|
+
} as MetaStory;
|
|
15
|
+
|
|
16
|
+
const host = 'https://media.nuskin.com';
|
|
17
|
+
|
|
18
|
+
export const Default: Story = {
|
|
19
|
+
args: {
|
|
20
|
+
isHorizontal: false,
|
|
21
|
+
title: 'Title',
|
|
22
|
+
subtitle: 'Subtitle',
|
|
23
|
+
intro: 'Introduction sentence',
|
|
24
|
+
icon: 'cart',
|
|
25
|
+
cardLink: {
|
|
26
|
+
href: 'https://www.forceforgood.org/',
|
|
27
|
+
title: 'Button Text',
|
|
28
|
+
},
|
|
29
|
+
backgroundImageUrl: `${host}/m/36f2a073f3de08a2/Small-category-facial_cleansers.jpg`,
|
|
30
|
+
backgroundImageAlt: 'Facial Moisturizers',
|
|
31
|
+
},
|
|
32
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { StoryObj, Meta } from '@storybook/react';
|
|
2
|
+
import { withCenterDecorator } from '@/stories/decorators/withCenterDecorator';
|
|
3
|
+
import { NsMediumCard } from '../';
|
|
4
|
+
|
|
5
|
+
type ComponentType = typeof NsMediumCard;
|
|
6
|
+
type Story = StoryObj<ComponentType>;
|
|
7
|
+
type MetaStory = Meta<ComponentType>;
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
component: NsMediumCard,
|
|
11
|
+
title: 'Components/Containers/Card/NsMediumCard',
|
|
12
|
+
argTypes: {},
|
|
13
|
+
decorators: [withCenterDecorator],
|
|
14
|
+
} as MetaStory;
|
|
15
|
+
|
|
16
|
+
const host = 'https://media.nuskin.com';
|
|
17
|
+
|
|
18
|
+
export const Default: Story = {
|
|
19
|
+
args: {
|
|
20
|
+
title: 'Introducing LumiSpa',
|
|
21
|
+
subtitle: 'Lorem ipsum dolor',
|
|
22
|
+
cardLink: {
|
|
23
|
+
href: 'https://www.forceforgood.org/',
|
|
24
|
+
title: 'Button Text',
|
|
25
|
+
},
|
|
26
|
+
backgroundImageUrl: `${host}/m/3353b9c05cb83860/Small-category-facial_moisturizers.jpg`,
|
|
27
|
+
backgroundImageAlt: 'Lumi Spa',
|
|
28
|
+
},
|
|
29
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { StoryObj, Meta } from '@storybook/react';
|
|
2
|
+
import { within, userEvent } from '@storybook/testing-library';
|
|
3
|
+
import { expect } from '@storybook/jest';
|
|
4
|
+
import { withCenterDecorator } from '@/stories/decorators/withCenterDecorator';
|
|
5
|
+
import { NsPost } from '../';
|
|
6
|
+
|
|
7
|
+
type ComponentType = typeof NsPost;
|
|
8
|
+
type Story = StoryObj<ComponentType>;
|
|
9
|
+
type MetaStory = Meta<ComponentType>;
|
|
10
|
+
|
|
11
|
+
export default {
|
|
12
|
+
component: NsPost,
|
|
13
|
+
title: 'Components/Containers/Card/NsPost',
|
|
14
|
+
argTypes: {},
|
|
15
|
+
decorators: [withCenterDecorator],
|
|
16
|
+
} as MetaStory;
|
|
17
|
+
|
|
18
|
+
const text = 'Heading';
|
|
19
|
+
const body = 'Date';
|
|
20
|
+
const host = 'https://media.nuskin.com/';
|
|
21
|
+
|
|
22
|
+
export const Default: Story = {
|
|
23
|
+
args: {
|
|
24
|
+
text,
|
|
25
|
+
body,
|
|
26
|
+
backgroundImageUrl: `${host}m/780f8d84bcb9d5ed/Small-Essence_News.jpg`,
|
|
27
|
+
backgroundImageAlt: 'small essence news',
|
|
28
|
+
additionalProps: {
|
|
29
|
+
testid: 'post-card',
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
play: async ({ canvasElement }: any) => {
|
|
33
|
+
const canvas = within(canvasElement);
|
|
34
|
+
userEvent.hover(canvas.getByTestId('post-card'));
|
|
35
|
+
userEvent.hover(canvas.getByRole('link'));
|
|
36
|
+
expect(canvas.getByText(text)).toBeInTheDocument();
|
|
37
|
+
expect(canvas.getByText(body)).toBeInTheDocument();
|
|
38
|
+
},
|
|
39
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { StoryObj, Meta } from '@storybook/react';
|
|
2
|
+
import { withCenterDecorator } from '@/stories/decorators/withCenterDecorator';
|
|
3
|
+
import { NsSmallFullCard } from '../';
|
|
4
|
+
|
|
5
|
+
type ComponentType = typeof NsSmallFullCard;
|
|
6
|
+
type Story = StoryObj<ComponentType>;
|
|
7
|
+
type MetaStory = Meta<ComponentType>;
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
component: NsSmallFullCard,
|
|
11
|
+
title: 'Components/Containers/Card/NsSmallFullCard',
|
|
12
|
+
argTypes: {},
|
|
13
|
+
decorators: [withCenterDecorator],
|
|
14
|
+
} as MetaStory;
|
|
15
|
+
|
|
16
|
+
const host = 'https://media.nuskin.com';
|
|
17
|
+
|
|
18
|
+
export const Default: Story = {
|
|
19
|
+
args: {
|
|
20
|
+
title: 'Title',
|
|
21
|
+
subtitle: 'Subtitle',
|
|
22
|
+
cardLink: {
|
|
23
|
+
href: 'https://www.forceforgood.org/',
|
|
24
|
+
title: 'Placeholder',
|
|
25
|
+
},
|
|
26
|
+
backgroundImageUrl: `${host}/m/4f5b0aee8fe3ff90/Small-category-makeup.jpg`,
|
|
27
|
+
backgroundImageAlt: 'Facial Moisturizers',
|
|
28
|
+
},
|
|
29
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { StoryObj, Meta } from '@storybook/react';
|
|
2
|
+
import { withCenterDecorator } from '@/stories/decorators/withCenterDecorator';
|
|
3
|
+
import { NsXLargeCard } from '../';
|
|
4
|
+
|
|
5
|
+
type ComponentType = typeof NsXLargeCard;
|
|
6
|
+
type Story = StoryObj<ComponentType>;
|
|
7
|
+
type MetaStory = Meta<ComponentType>;
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
component: NsXLargeCard,
|
|
11
|
+
title: 'Components/Containers/Card/NsXLargeCard',
|
|
12
|
+
argTypes: {},
|
|
13
|
+
decorators: [withCenterDecorator],
|
|
14
|
+
} as MetaStory;
|
|
15
|
+
|
|
16
|
+
const host = 'https://media.nuskin.com';
|
|
17
|
+
|
|
18
|
+
export const Default: Story = {
|
|
19
|
+
args: {
|
|
20
|
+
title: 'Title',
|
|
21
|
+
subtitle: 'Subtitle',
|
|
22
|
+
cardLink: {
|
|
23
|
+
href: 'https://www.forceforgood.org/',
|
|
24
|
+
title: 'Call to action',
|
|
25
|
+
},
|
|
26
|
+
backgroundImageUrl: `${host}/m/4f5b0aee8fe3ff90/Small-category-makeup.jpg`,
|
|
27
|
+
backgroundImageAlt: 'Facial Moisturizers',
|
|
28
|
+
},
|
|
29
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import NsBrandCard from '../card/NsBrandCard';
|
|
2
2
|
|
|
3
3
|
interface BrandType {
|
|
4
4
|
title: string;
|
|
@@ -8,11 +8,12 @@ interface BrandType {
|
|
|
8
8
|
export const RenderBrand = (entry: BrandType, index: number) => {
|
|
9
9
|
const { title, backgroundImage, brandImage } = entry;
|
|
10
10
|
return (
|
|
11
|
-
<
|
|
11
|
+
<NsBrandCard
|
|
12
12
|
key={title + index}
|
|
13
13
|
backgroundImageUrl={backgroundImage}
|
|
14
14
|
title={title}
|
|
15
15
|
brandImageUrl={brandImage}
|
|
16
|
+
button={false}
|
|
16
17
|
/>
|
|
17
18
|
);
|
|
18
19
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Box } from '@mui/material';
|
|
2
2
|
import { styled, nuskinTheme, ColorUtils, FoundationTheme } from '@nuskin/foundation-theme';
|
|
3
|
-
import {fieldStateType} from './types.d';
|
|
3
|
+
import { fieldStateType } from './types.d';
|
|
4
4
|
|
|
5
5
|
const { isDarkMode } = ColorUtils;
|
|
6
6
|
const { colors } = nuskinTheme;
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @author [Vijayaprathap Kumar] (vpkumar@nuskin.com)
|
|
3
|
-
* NsAutocomplete.stories.tsx
|
|
4
|
-
* @description NsAutocomplete component.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import React, { useState } from 'react';
|
|
8
|
-
import type { StoryObj, Meta } from '@storybook/react';
|
|
9
|
-
|
|
10
|
-
import { withCenterDecorator } from '@/stories/decorators/withCenterDecorator';
|
|
11
|
-
import { NsAutocomplete } from './';
|
|
12
|
-
import { AutocompleteMockList } from './mock/MockData';
|
|
13
|
-
import { OptionUiComponent } from './mock/MockUI';
|
|
14
|
-
import { NsAutocompleteProps, OptionsProps } from './types.d';
|
|
15
|
-
import { NsIcon } from '../icon';
|
|
16
|
-
import { IconButton } from '@mui/material';
|
|
17
|
-
|
|
18
|
-
type ComponentType = typeof NsAutocomplete;
|
|
19
|
-
type Story = StoryObj<ComponentType>;
|
|
20
|
-
type MetaStory = Meta<ComponentType>;
|
|
21
|
-
|
|
22
|
-
const PAGE_SIZE = 6;
|
|
23
|
-
|
|
24
|
-
export default {
|
|
25
|
-
title: 'Components/Inputs/NsAutocomplete',
|
|
26
|
-
component: NsAutocomplete,
|
|
27
|
-
decorators: [withCenterDecorator],
|
|
28
|
-
argTypes: {
|
|
29
|
-
children: {
|
|
30
|
-
control: 'text',
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
args: {
|
|
34
|
-
options: AutocompleteMockList,
|
|
35
|
-
seeMore: {
|
|
36
|
-
text: 'See More Results',
|
|
37
|
-
show: true,
|
|
38
|
-
onSeeMore: () => {
|
|
39
|
-
throw new Error('Function not implemented.');
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
clear: {
|
|
43
|
-
text: 'Clear Recent Searches',
|
|
44
|
-
show: true,
|
|
45
|
-
onClear: () => {
|
|
46
|
-
throw new Error('Function not implemented.');
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
iconStart: <NsIcon name="search" />,
|
|
50
|
-
iconEnd: <NsIcon name="roundedClose" size="small" colorOverride="#F5F5F5" />,
|
|
51
|
-
placeholder: 'search',
|
|
52
|
-
},
|
|
53
|
-
} as MetaStory;
|
|
54
|
-
|
|
55
|
-
const RenderAutocomplete = (args: NsAutocompleteProps) => {
|
|
56
|
-
const [selectedOption, setSelectedOption] = useState<string | OptionsProps | null>(null);
|
|
57
|
-
const [searchTerms, setSearchTerms] = useState<string>('');
|
|
58
|
-
const [pageNo, setPageNo] = useState(PAGE_SIZE);
|
|
59
|
-
|
|
60
|
-
const onSeeMoreHandler = () => {
|
|
61
|
-
setPageNo(PAGE_SIZE + PAGE_SIZE);
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
const AutoCompleteProps = {
|
|
65
|
-
...args,
|
|
66
|
-
seeMore: {
|
|
67
|
-
...args.seeMore,
|
|
68
|
-
onSeeMore: onSeeMoreHandler,
|
|
69
|
-
},
|
|
70
|
-
} as NsAutocompleteProps;
|
|
71
|
-
|
|
72
|
-
const onSelect = (value: string | OptionsProps | null) => {
|
|
73
|
-
setSelectedOption(value);
|
|
74
|
-
setSearchTerms((value = ''));
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
const handleInputChange = (newValue: string) => {
|
|
78
|
-
setSearchTerms(newValue);
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
const onInputClear = () => {
|
|
82
|
-
setSelectedOption(null);
|
|
83
|
-
setSearchTerms('');
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
return (
|
|
87
|
-
<div>
|
|
88
|
-
<NsAutocomplete
|
|
89
|
-
{...AutoCompleteProps}
|
|
90
|
-
options={args.options.slice(0, pageNo)}
|
|
91
|
-
onChange={handleInputChange}
|
|
92
|
-
onSelect={onSelect}
|
|
93
|
-
OptionsUI={OptionUiComponent}
|
|
94
|
-
iconEnd={
|
|
95
|
-
<IconButton onClick={onInputClear}>
|
|
96
|
-
<NsIcon name="roundedClose" size="xLarge" colorOverride="#F5F5F5" />
|
|
97
|
-
</IconButton>
|
|
98
|
-
}
|
|
99
|
-
value={selectedOption}
|
|
100
|
-
inputValue={searchTerms}
|
|
101
|
-
/>
|
|
102
|
-
</div>
|
|
103
|
-
);
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
export const Autocomplete: Story = {
|
|
107
|
-
render: RenderAutocomplete,
|
|
108
|
-
};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import Box from '@mui/material/Box';
|
|
2
|
-
import { styled } from '@nuskin/foundation-theme';
|
|
3
|
-
import { NsTypography } from '../';
|
|
4
|
-
import NsBrandWrapper from './NsBrandWrapper';
|
|
5
|
-
import NsBrandLogo from './NsBrandLogo';
|
|
6
|
-
import NsBgCard from './NsBgCard';
|
|
7
|
-
|
|
8
|
-
type NsBrandProductCardProps = {
|
|
9
|
-
title?: string;
|
|
10
|
-
brandImageUrl: string;
|
|
11
|
-
backgroundImageUrl: string;
|
|
12
|
-
};
|
|
13
|
-
const CardContainer = styled(Box)(() => {
|
|
14
|
-
return {
|
|
15
|
-
width: '256px',
|
|
16
|
-
display: 'flex',
|
|
17
|
-
alignItems: 'start',
|
|
18
|
-
justifyContent: 'center',
|
|
19
|
-
position: 'relative',
|
|
20
|
-
flexDirection: 'column',
|
|
21
|
-
'.brand-title': {
|
|
22
|
-
marginTop: '20px',
|
|
23
|
-
fontSize: '20px',
|
|
24
|
-
},
|
|
25
|
-
':hover': {
|
|
26
|
-
'.brand-title': {
|
|
27
|
-
opacity: '0.7',
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
};
|
|
31
|
-
});
|
|
32
|
-
export default function NsBrandProductCard({ title, brandImageUrl, backgroundImageUrl }: NsBrandProductCardProps) {
|
|
33
|
-
return (
|
|
34
|
-
<CardContainer role="brand-card" component="div" data-testid="brand-product-card">
|
|
35
|
-
<NsBgCard backgroundImageUrl={backgroundImageUrl}>
|
|
36
|
-
<NsBrandWrapper>
|
|
37
|
-
<NsBrandLogo component="img" image={brandImageUrl} />
|
|
38
|
-
</NsBrandWrapper>
|
|
39
|
-
</NsBgCard>
|
|
40
|
-
{title ? (
|
|
41
|
-
<NsTypography variant="h3" className="brand-title">
|
|
42
|
-
{title}
|
|
43
|
-
</NsTypography>
|
|
44
|
-
) : null}
|
|
45
|
-
</CardContainer>
|
|
46
|
-
);
|
|
47
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { NsLink, NsImage } from '../';
|
|
2
|
-
import { NsFfgStyled } from './styled/NsFfgStyled';
|
|
3
|
-
import { NsFfgCardProps } from './types.d';
|
|
4
|
-
|
|
5
|
-
const NsFfgCard = ({ cardLink, text, topImageUrl, topImageAlt, additionalProps, cslp, onClick }: NsFfgCardProps) => {
|
|
6
|
-
return (
|
|
7
|
-
<NsFfgStyled
|
|
8
|
-
data-testid={additionalProps?.testid}
|
|
9
|
-
onClick={onClick}
|
|
10
|
-
className={additionalProps?.className ?? ''}
|
|
11
|
-
>
|
|
12
|
-
<header className="top-image">
|
|
13
|
-
<NsImage height={192} width={288} alt={topImageAlt} src={topImageUrl} />
|
|
14
|
-
</header>
|
|
15
|
-
<article className="body-text" {...cslp?.card_text}>
|
|
16
|
-
{text}
|
|
17
|
-
</article>
|
|
18
|
-
<NsLink className="action-link" href={cardLink.href} additionalProps={cslp?.action_text}>
|
|
19
|
-
{cardLink.title || 'LEARN MORE'}
|
|
20
|
-
</NsLink>
|
|
21
|
-
</NsFfgStyled>
|
|
22
|
-
);
|
|
23
|
-
};
|
|
24
|
-
export default NsFfgCard;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { render } from '@testing-library/react';
|
|
2
|
-
import NsBrandProductCard from '../NsBrandProductCard';
|
|
3
|
-
|
|
4
|
-
describe('NSBgCard component', () => {
|
|
5
|
-
const props = {
|
|
6
|
-
title: 'Nutricentials',
|
|
7
|
-
brandImageUrl: 'https://media.nuskin.com/m/f3a91129cbbae32/webimage-brand-nutricentials.png',
|
|
8
|
-
backgroundImageUrl: 'https://media.nuskin.com/m/298104036e885b40/webimage-brand-nutricentials.png',
|
|
9
|
-
};
|
|
10
|
-
it('render brand image', () => {
|
|
11
|
-
const { container } = render(<NsBrandProductCard {...props} />);
|
|
12
|
-
const img = container.querySelector('img');
|
|
13
|
-
expect(img).toHaveAttribute('src', props.brandImageUrl);
|
|
14
|
-
});
|
|
15
|
-
it('render background image', () => {
|
|
16
|
-
const { container } = render(<NsBrandProductCard {...props} />);
|
|
17
|
-
const card = container.querySelector('div.MuiPaper-root');
|
|
18
|
-
expect(card).toHaveStyle(`
|
|
19
|
-
background-image: url(${props.backgroundImageUrl});
|
|
20
|
-
`);
|
|
21
|
-
});
|
|
22
|
-
it('renders title', () => {
|
|
23
|
-
const { getByText } = render(<NsBrandProductCard {...props} />);
|
|
24
|
-
const cardElement = getByText(props.title);
|
|
25
|
-
expect(cardElement).toBeInTheDocument();
|
|
26
|
-
});
|
|
27
|
-
it('does not render title, when title is not passed', () => {
|
|
28
|
-
const { container } = render(<NsBrandProductCard {...{ ...props, title: undefined }} />);
|
|
29
|
-
const cardElement = container.querySelector('.brand-title');
|
|
30
|
-
expect(cardElement).toBeNull();
|
|
31
|
-
});
|
|
32
|
-
});
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { render, screen, fireEvent } from '@testing-library/react';
|
|
2
|
-
import NsFfgCard from '../NsFfgCard';
|
|
3
|
-
|
|
4
|
-
describe('NsFfgCard component', () => {
|
|
5
|
-
const props = {
|
|
6
|
-
topImageUrl: 'https://media.nuskin.com/m/6245528b8f76ad32/webimage-brand-ageLOC.png',
|
|
7
|
-
topImageAlt: 'alt-text',
|
|
8
|
-
text: 'card text',
|
|
9
|
-
cardLink: { href: 'https://www.google.com', title: 'Test' },
|
|
10
|
-
onClick: jest.fn(),
|
|
11
|
-
};
|
|
12
|
-
it('1. renders with background image', () => {
|
|
13
|
-
render(<NsFfgCard {...props} additionalProps={{ testid: 'ffg-card' }} />);
|
|
14
|
-
const card = screen.getByTestId('ffg-card');
|
|
15
|
-
expect(card).toHaveStyle(`
|
|
16
|
-
background-color: #fff;
|
|
17
|
-
`);
|
|
18
|
-
});
|
|
19
|
-
it('2. renders with cover size', () => {
|
|
20
|
-
render(<NsFfgCard {...props} additionalProps={{ testid: 'ffg-card-1' }} />);
|
|
21
|
-
const card = screen.getByText(props.cardLink.title);
|
|
22
|
-
expect(card).toBeInTheDocument();
|
|
23
|
-
});
|
|
24
|
-
it('3. calls onclick', () => {
|
|
25
|
-
const handler = jest.fn();
|
|
26
|
-
const { getByTestId } = render(
|
|
27
|
-
<NsFfgCard {...props} onClick={handler} additionalProps={{ testid: 'ffg-card-1' }} />
|
|
28
|
-
);
|
|
29
|
-
const card = getByTestId('ffg-card-1');
|
|
30
|
-
fireEvent.click(card);
|
|
31
|
-
expect(handler).toHaveBeenCalled();
|
|
32
|
-
});
|
|
33
|
-
});
|