@nuskin/foundation-ui-components 1.0.0-cft-35.7 → 1.0.0-cft-35.8
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/CHANGELOG.md +27 -0
- package/package.json +1 -1
- package/src/common/banner/NsBanner.spec.tsx +19 -0
- package/src/common/banner/NsBanner.stories.tsx +42 -0
- package/src/common/banner/NsBanner.styled.tsx +23 -0
- package/src/common/banner/NsBanner.tsx +33 -0
- package/src/common/banner/index.ts +1 -0
- package/src/common/banner/types.d.ts +14 -0
- package/src/common/index.ts +3 -0
- package/src/common/nav-tab/NsNavTab.tsx +3 -3
- package/src/common/typography/NsTypography.tsx +2 -0
- package/src/common/typography/Typography.styled.tsx +3 -4
- package/src/common/typography/types.d.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,30 @@
|
|
|
1
|
+
# [1.0.0-cft-35.8](https://code.tls.nuskin.io/ns-am/content-foundation/foundation-ui-components/compare/v1.0.0-cft-35.7...v1.0.0-cft-35.8) (2023-04-10)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Fis
|
|
5
|
+
|
|
6
|
+
* format code ([8587727](https://code.tls.nuskin.io/ns-am/content-foundation/foundation-ui-components/commit/85877278980afed666a55eabd7ba8a86ba14f236))
|
|
7
|
+
|
|
8
|
+
### Fix
|
|
9
|
+
|
|
10
|
+
* button import name chnaged ([47522e3](https://code.tls.nuskin.io/ns-am/content-foundation/foundation-ui-components/commit/47522e3f8c2e940ac720d204d69448a0b46442ce))
|
|
11
|
+
* conflict ([971e4a5](https://code.tls.nuskin.io/ns-am/content-foundation/foundation-ui-components/commit/971e4a50c88a545f2890a62349f2ebd06759384a))
|
|
12
|
+
* merge issue ([67a72ce](https://code.tls.nuskin.io/ns-am/content-foundation/foundation-ui-components/commit/67a72ce440c27b88a339e68f4c74a39c1c23b9a1))
|
|
13
|
+
* Typography and banner ui updates ([99a8322](https://code.tls.nuskin.io/ns-am/content-foundation/foundation-ui-components/commit/99a8322c968c9b31dca4bc1d0d3652d47a65338b))
|
|
14
|
+
|
|
15
|
+
### FIX
|
|
16
|
+
|
|
17
|
+
* build issue ([935b132](https://code.tls.nuskin.io/ns-am/content-foundation/foundation-ui-components/commit/935b1322d47841eb554ad514cb9880b9e9f48e52))
|
|
18
|
+
* typo fix ([32d5fa7](https://code.tls.nuskin.io/ns-am/content-foundation/foundation-ui-components/commit/32d5fa7dc09ec60ce3698b6c638ea9351405ef28))
|
|
19
|
+
|
|
20
|
+
### New
|
|
21
|
+
|
|
22
|
+
* Nsbaner Ui #CFT-118 ([d1896fd](https://code.tls.nuskin.io/ns-am/content-foundation/foundation-ui-components/commit/d1896fd00fc1c7cc22a0db931507ec6096e7fdef)), closes [#CFT-118](https://code.tls.nuskin.io/ns-am/content-foundation/foundation-ui-components/issues/CFT-118)
|
|
23
|
+
|
|
24
|
+
### Update
|
|
25
|
+
|
|
26
|
+
* Code format ([7244ea1](https://code.tls.nuskin.io/ns-am/content-foundation/foundation-ui-components/commit/7244ea1fcef2bdb75dd45d7af04809e763cff8dd))
|
|
27
|
+
|
|
1
28
|
# [1.0.0-cft-35.7](https://code.tls.nuskin.io/ns-am/content-foundation/foundation-ui-components/compare/v1.0.0-cft-35.6...v1.0.0-cft-35.7) (2023-04-10)
|
|
2
29
|
|
|
3
30
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuskin/foundation-ui-components",
|
|
3
|
-
"version": "1.0.0-cft-35.
|
|
3
|
+
"version": "1.0.0-cft-35.8",
|
|
4
4
|
"description": "It is a foundation library written in react, that provides commom components to all UI pages",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "src/common/index.ts",
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react';
|
|
3
|
+
import NsBanner from './';
|
|
4
|
+
|
|
5
|
+
describe('Hero component', () => {
|
|
6
|
+
it('renders banner image and title', () => {
|
|
7
|
+
const childText = 'Welcome to My Website';
|
|
8
|
+
const image = 'https://example.com/banner.jpg';
|
|
9
|
+
const { getByAltText, getByText } = render(
|
|
10
|
+
<NsBanner imageUrl={image} altText="Banner image">
|
|
11
|
+
<h1>{childText}</h1>
|
|
12
|
+
</NsBanner>
|
|
13
|
+
);
|
|
14
|
+
const childElement = getByText(childText);
|
|
15
|
+
const imageElement = getByAltText('Banner image');
|
|
16
|
+
expect(childElement).toBeInTheDocument();
|
|
17
|
+
expect(imageElement).toBeInTheDocument();
|
|
18
|
+
});
|
|
19
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author [Vijayaprathap Kumar] (vpkumar@nuskin.com)
|
|
3
|
+
* NsBanner.stories.tsx
|
|
4
|
+
* @description NsBanner component.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import { ComponentStory, ComponentMeta } from '@storybook/react';
|
|
9
|
+
|
|
10
|
+
import Banner from './';
|
|
11
|
+
import Typography from '../typography';
|
|
12
|
+
import Button from '../button/NsButton';
|
|
13
|
+
|
|
14
|
+
export default {
|
|
15
|
+
title: 'Components',
|
|
16
|
+
component: Banner,
|
|
17
|
+
decorators: [(story) => <div style={{ textAlign: 'center', marginTop: '20px' }}>{story()}</div>],
|
|
18
|
+
argTypes: {
|
|
19
|
+
children: {
|
|
20
|
+
control: 'text', // use the text control to edit children prop
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
args: {
|
|
24
|
+
imageUrl: 'https://media.nuskin.com/m/e2f6d26058b2e7d/webimage-us-collagen-strawberry-hompage-banner.png',
|
|
25
|
+
altText: 'NsBanner',
|
|
26
|
+
alignment: 'center',
|
|
27
|
+
justify: 'start',
|
|
28
|
+
children: (
|
|
29
|
+
<div>
|
|
30
|
+
<Typography className="w-80" variant="h1" colorOverride="#000000">
|
|
31
|
+
Limited time offers on LumiSpa iO cleansers and bundles!
|
|
32
|
+
</Typography>
|
|
33
|
+
<Typography variant="p-m" className="my-5" colorOverride="#000000">
|
|
34
|
+
Learn more about what I do and how I can help you
|
|
35
|
+
</Typography>
|
|
36
|
+
<Button variant="contained">Contact me</Button>
|
|
37
|
+
</div>
|
|
38
|
+
),
|
|
39
|
+
},
|
|
40
|
+
} as ComponentMeta<typeof Banner>;
|
|
41
|
+
|
|
42
|
+
export const NsBanner: ComponentStory<typeof Banner> = (args) => <Banner {...args} />;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { styled } from '@nuskin/foundation-theme';
|
|
2
|
+
import { AlignmentType } from './types';
|
|
3
|
+
|
|
4
|
+
export const StyledBanner = styled.section`
|
|
5
|
+
position: relative;
|
|
6
|
+
display: flex;
|
|
7
|
+
justify-content: space-evenly;
|
|
8
|
+
img {
|
|
9
|
+
width: 100%;
|
|
10
|
+
object-fit: cover;
|
|
11
|
+
}
|
|
12
|
+
`;
|
|
13
|
+
|
|
14
|
+
export const StyledHeroText = styled.div<{ $justify: AlignmentType; $alignment: AlignmentType }>`
|
|
15
|
+
height: 100%;
|
|
16
|
+
display: flex;
|
|
17
|
+
width: 100%;
|
|
18
|
+
position: absolute;
|
|
19
|
+
top: 0;
|
|
20
|
+
justify-content: ${({ $justify }) => $justify};
|
|
21
|
+
align-items: ${({ $alignment }) => $alignment};
|
|
22
|
+
text-align: left;
|
|
23
|
+
`;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author [Vijayaprathap Kumar] (vpkumar@nuskin.com)
|
|
3
|
+
* NsBanner.tsx
|
|
4
|
+
* @description NsBanner component with a image background
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import React, { PropsWithChildren } from 'react';
|
|
8
|
+
|
|
9
|
+
import { NsBannerProps } from './types';
|
|
10
|
+
import { StyledBanner, StyledHeroText } from './NsBanner.styled';
|
|
11
|
+
|
|
12
|
+
const NsBanner = (props: PropsWithChildren<NsBannerProps>) => {
|
|
13
|
+
const {
|
|
14
|
+
children,
|
|
15
|
+
imageUrl = '',
|
|
16
|
+
altText = 'NsBanner',
|
|
17
|
+
alignment = 'center',
|
|
18
|
+
justify = 'start',
|
|
19
|
+
className = '',
|
|
20
|
+
additionalProps = {},
|
|
21
|
+
} = props;
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<StyledBanner className={className}>
|
|
25
|
+
<img src={imageUrl} alt={altText} id="bgImage" {...additionalProps} />
|
|
26
|
+
<StyledHeroText $alignment={alignment} $justify={justify}>
|
|
27
|
+
<div className="mx-14">{children}</div>
|
|
28
|
+
</StyledHeroText>
|
|
29
|
+
</StyledBanner>
|
|
30
|
+
);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export default NsBanner;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './NsBanner';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { AdditionalProps } from '../common.types';
|
|
4
|
+
|
|
5
|
+
export type AlignmentType = 'start' | 'center' | 'end';
|
|
6
|
+
|
|
7
|
+
export type NsBannerProps = {
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
imageUrl: string;
|
|
10
|
+
altText?: string;
|
|
11
|
+
alignment?: AlignmentType;
|
|
12
|
+
justify?: AlignmentType;
|
|
13
|
+
className?: string;
|
|
14
|
+
} & AdditionalProps;
|
package/src/common/index.ts
CHANGED
|
@@ -19,6 +19,9 @@ export * from './nav-tab';
|
|
|
19
19
|
export { default as NsNavProductCard } from './nav-product-card';
|
|
20
20
|
export * from './nav-product-card';
|
|
21
21
|
|
|
22
|
+
export { default as NsBanner} from './banner';
|
|
23
|
+
export * from './banner';
|
|
24
|
+
|
|
22
25
|
export { default as Typography } from './typography';
|
|
23
26
|
export * from './typography';
|
|
24
27
|
|
|
@@ -20,14 +20,14 @@ export const NsNavTabComponent = (props: PropsWithChildren<NSNavTabComponentProp
|
|
|
20
20
|
<div onMouseLeave={handleLeave} data-testid="nav-container-draw" className="p-0 m-0">
|
|
21
21
|
<div className="pb-0.5">
|
|
22
22
|
<div className="flex">
|
|
23
|
-
{tabs?.map((tab
|
|
23
|
+
{tabs?.map((tab) => {
|
|
24
24
|
const handleMouseEnter = () => {
|
|
25
25
|
setActive(tab.tabName);
|
|
26
26
|
};
|
|
27
27
|
return (
|
|
28
28
|
<div
|
|
29
|
-
key={
|
|
30
|
-
data-testid={tab
|
|
29
|
+
key={tab?.tabName}
|
|
30
|
+
data-testid={tab?.tabName}
|
|
31
31
|
className="relative cursor-pointer"
|
|
32
32
|
onMouseEnter={handleMouseEnter}
|
|
33
33
|
>
|
|
@@ -11,6 +11,7 @@ const NsTypography = ({
|
|
|
11
11
|
decoration = 'none',
|
|
12
12
|
color = 'primary',
|
|
13
13
|
additionalProps = {},
|
|
14
|
+
colorOverride = '',
|
|
14
15
|
}: PropsWithChildren<NsTypographyProps>) => {
|
|
15
16
|
return (
|
|
16
17
|
<StyledTypography
|
|
@@ -19,6 +20,7 @@ const NsTypography = ({
|
|
|
19
20
|
weight={weight}
|
|
20
21
|
variant={variant}
|
|
21
22
|
decoration={decoration}
|
|
23
|
+
colorOverride={colorOverride}
|
|
22
24
|
color={color}
|
|
23
25
|
{...additionalProps}
|
|
24
26
|
>
|
|
@@ -2,9 +2,7 @@ import { css } from '@emotion/react';
|
|
|
2
2
|
import { styled, GlobalStyles, ColorUtils } from '@nuskin/foundation-theme';
|
|
3
3
|
import { NsTypographyProps } from './types';
|
|
4
4
|
|
|
5
|
-
const {
|
|
6
|
-
getPaletteColor,
|
|
7
|
-
} = ColorUtils;
|
|
5
|
+
const { getPaletteColor } = ColorUtils;
|
|
8
6
|
|
|
9
7
|
const variantStyles = {
|
|
10
8
|
h1: 'font-size: 36px; line-height: 44px;',
|
|
@@ -32,7 +30,8 @@ const fontWeightMap = {
|
|
|
32
30
|
|
|
33
31
|
export const StyledTypography = styled.div<NsTypographyProps>`
|
|
34
32
|
font-family: Inter;
|
|
35
|
-
color: ${({ color, theme }) =>
|
|
33
|
+
color: ${({ color, theme, colorOverride }) =>
|
|
34
|
+
colorOverride?.startsWith('#') ? colorOverride : getPaletteColor(theme, color)};
|
|
36
35
|
font-weight: ${({ weight = 'normal' }) => fontWeightMap[weight]};
|
|
37
36
|
font-style: ${({ fontStyle }) => fontStyle};
|
|
38
37
|
${({ variant = 'h1' }) => variantStyles[variant]};
|