@faststore/components 2.0.18-alpha.0 → 2.0.24-alpha.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/CHANGELOG.md +18 -0
- package/dist/assets/ArrowRight.d.ts +3 -0
- package/dist/assets/ArrowRight.js +8 -0
- package/dist/assets/ArrowRight.js.map +1 -0
- package/dist/assets/House.d.ts +3 -0
- package/dist/assets/House.js +7 -0
- package/dist/assets/House.js.map +1 -0
- package/dist/assets/index.d.ts +3 -1
- package/dist/assets/index.js +3 -1
- package/dist/assets/index.js.map +1 -1
- package/dist/atoms/Badge/Badge.js +1 -1
- package/dist/atoms/Badge/Badge.js.map +1 -1
- package/dist/atoms/Button/Button.js +1 -1
- package/dist/atoms/Button/Button.js.map +1 -1
- package/dist/atoms/Icon/Icon.d.ts +4 -4
- package/dist/atoms/Link/Link.d.ts +4 -4
- package/dist/atoms/Link/Link.js +1 -1
- package/dist/atoms/Link/Link.js.map +1 -1
- package/dist/atoms/List/List.js +1 -1
- package/dist/atoms/List/List.js.map +1 -1
- package/dist/atoms/Overlay/Overlay.js +1 -1
- package/dist/atoms/Overlay/Overlay.js.map +1 -1
- package/dist/atoms/Price/Price.d.ts +4 -4
- package/dist/atoms/Price/Price.js +1 -1
- package/dist/atoms/Price/Price.js.map +1 -1
- package/dist/atoms/Radio/Radio.js +1 -1
- package/dist/atoms/Radio/Radio.js.map +1 -1
- package/dist/atoms/SROnly/SROnly.d.ts +2 -2
- package/dist/atoms/SROnly/SROnly.js.map +1 -1
- package/dist/atoms/Select/Select.d.ts +4 -4
- package/dist/atoms/Select/Select.js +1 -1
- package/dist/atoms/Select/Select.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/molecules/BuyButton/BuyButton.d.ts +2 -2
- package/dist/molecules/BuyButton/BuyButton.js +2 -2
- package/dist/molecules/BuyButton/BuyButton.js.map +1 -1
- package/dist/molecules/DiscountBadge/DiscountBadge.d.ts +5 -5
- package/dist/molecules/DiscountBadge/DiscountBadge.js +2 -2
- package/dist/molecules/DiscountBadge/DiscountBadge.js.map +1 -1
- package/dist/molecules/IconButton/IconButton.js +1 -1
- package/dist/molecules/IconButton/IconButton.js.map +1 -1
- package/dist/molecules/InputField/InputField.d.ts +5 -1
- package/dist/molecules/InputField/InputField.js +2 -2
- package/dist/molecules/InputField/InputField.js.map +1 -1
- package/dist/molecules/LinkButton/LinkButton.js +1 -1
- package/dist/molecules/LinkButton/LinkButton.js.map +1 -1
- package/dist/molecules/SelectField/SelectField.js +2 -2
- package/dist/molecules/SelectField/SelectField.js.map +1 -1
- package/dist/molecules/Tag/Tag.js +1 -1
- package/dist/molecules/Tag/Tag.js.map +1 -1
- package/dist/molecules/Toggle/Toggle.js +1 -1
- package/dist/molecules/Toggle/Toggle.js.map +1 -1
- package/dist/organisms/Hero/Hero.d.ts +27 -0
- package/dist/organisms/Hero/Hero.js +16 -0
- package/dist/organisms/Hero/Hero.js.map +1 -0
- package/dist/organisms/Hero/HeroHeading.d.ts +30 -0
- package/dist/organisms/Hero/HeroHeading.js +16 -0
- package/dist/organisms/Hero/HeroHeading.js.map +1 -0
- package/dist/organisms/Hero/HeroImage.d.ts +10 -0
- package/dist/organisms/Hero/HeroImage.js +6 -0
- package/dist/organisms/Hero/HeroImage.js.map +1 -0
- package/dist/organisms/Hero/index.d.ts +6 -0
- package/dist/organisms/Hero/index.js +4 -0
- package/dist/organisms/Hero/index.js.map +1 -0
- package/package.json +2 -2
- package/src/assets/ArrowRight.tsx +21 -0
- package/src/assets/House.tsx +20 -0
- package/src/assets/index.ts +3 -1
- package/src/atoms/Badge/Badge.tsx +1 -1
- package/src/atoms/Button/Button.tsx +1 -1
- package/src/atoms/Icon/Icon.tsx +4 -4
- package/src/atoms/Link/Link.tsx +19 -14
- package/src/atoms/List/List.tsx +1 -1
- package/src/atoms/Overlay/Overlay.tsx +2 -2
- package/src/atoms/Price/Price.tsx +5 -5
- package/src/atoms/Radio/Radio.tsx +1 -1
- package/src/atoms/SROnly/SROnly.tsx +2 -2
- package/src/atoms/Select/Select.tsx +6 -6
- package/src/index.ts +12 -0
- package/src/molecules/BuyButton/BuyButton.tsx +8 -3
- package/src/molecules/DiscountBadge/DiscountBadge.tsx +6 -6
- package/src/molecules/IconButton/IconButton.tsx +1 -1
- package/src/molecules/InputField/InputField.tsx +6 -0
- package/src/molecules/LinkButton/LinkButton.tsx +2 -2
- package/src/molecules/SelectField/SelectField.tsx +2 -2
- package/src/molecules/Tag/Tag.tsx +1 -1
- package/src/molecules/Toggle/Toggle.tsx +1 -1
- package/src/organisms/Hero/Hero.tsx +68 -0
- package/src/organisms/Hero/HeroHeading.tsx +82 -0
- package/src/organisms/Hero/HeroImage.tsx +22 -0
- package/src/organisms/Hero/index.tsx +8 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import React, { forwardRef, useContext, createContext } from 'react'
|
|
2
|
+
import type { HTMLAttributes } from 'react'
|
|
3
|
+
|
|
4
|
+
type Variant = 'primary' | 'secondary'
|
|
5
|
+
type ColorVariant = 'main' | 'light' | 'accent'
|
|
6
|
+
|
|
7
|
+
interface HeroContext {
|
|
8
|
+
variant: Variant
|
|
9
|
+
colorVariant: ColorVariant
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const HeroContext = createContext<HeroContext | undefined>(undefined)
|
|
13
|
+
|
|
14
|
+
export interface HeroProps extends HTMLAttributes<HTMLDivElement> {
|
|
15
|
+
/**
|
|
16
|
+
* Specifies the component variant.
|
|
17
|
+
*/
|
|
18
|
+
variant?: Variant
|
|
19
|
+
/**
|
|
20
|
+
* Specifies the component's color variant combination.
|
|
21
|
+
*/
|
|
22
|
+
colorVariant?: ColorVariant
|
|
23
|
+
/**
|
|
24
|
+
* ID to find this component in testing tools (e.g.: cypress,
|
|
25
|
+
* testing-library, and jest).
|
|
26
|
+
*/
|
|
27
|
+
testId?: string
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const Hero = forwardRef<HTMLDivElement, HeroProps>(function Hero(
|
|
31
|
+
{
|
|
32
|
+
children,
|
|
33
|
+
testId = 'fs-hero',
|
|
34
|
+
variant = 'primary',
|
|
35
|
+
colorVariant = 'main',
|
|
36
|
+
...otherProps
|
|
37
|
+
},
|
|
38
|
+
ref
|
|
39
|
+
) {
|
|
40
|
+
const context = { variant, colorVariant }
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<HeroContext.Provider value={context}>
|
|
44
|
+
<article
|
|
45
|
+
ref={ref}
|
|
46
|
+
data-fs-hero
|
|
47
|
+
data-fs-hero-variant={variant}
|
|
48
|
+
data-fs-hero-color-variant={colorVariant}
|
|
49
|
+
data-testid={testId}
|
|
50
|
+
{...otherProps}
|
|
51
|
+
>
|
|
52
|
+
{children}
|
|
53
|
+
</article>
|
|
54
|
+
</HeroContext.Provider>
|
|
55
|
+
)
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
export function useHero() {
|
|
59
|
+
const context = useContext(HeroContext)
|
|
60
|
+
|
|
61
|
+
if (context === undefined) {
|
|
62
|
+
throw new Error('Do not use Hero components outside the Hero context.')
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return context
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export default Hero
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { ReactNode, HTMLAttributes } from 'react'
|
|
2
|
+
import React, { forwardRef } from 'react'
|
|
3
|
+
import { Icon, LinkButton } from '../..'
|
|
4
|
+
import { ArrowRight } from '../../assets'
|
|
5
|
+
|
|
6
|
+
import { useHero } from './Hero'
|
|
7
|
+
|
|
8
|
+
export interface HeroHeadingProps extends HTMLAttributes<HTMLDivElement> {
|
|
9
|
+
/**
|
|
10
|
+
* Content for the h1 tag.
|
|
11
|
+
*/
|
|
12
|
+
title: string
|
|
13
|
+
/**
|
|
14
|
+
* Content for the p tag.
|
|
15
|
+
*/
|
|
16
|
+
subtitle: string
|
|
17
|
+
/**
|
|
18
|
+
* Icon component for additional customization.
|
|
19
|
+
*/
|
|
20
|
+
icon?: ReactNode
|
|
21
|
+
/**
|
|
22
|
+
* Specifies the URL the action button goes to.
|
|
23
|
+
*/
|
|
24
|
+
link?: string
|
|
25
|
+
/**
|
|
26
|
+
* Specifies the action button's content.
|
|
27
|
+
*/
|
|
28
|
+
linkText?: string
|
|
29
|
+
/**
|
|
30
|
+
* ID to find this component in testing tools (e.g.: cypress, testing library, and jest).
|
|
31
|
+
*/
|
|
32
|
+
testId?: string
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const HeroHeading = forwardRef<HTMLDivElement, HeroHeadingProps>(
|
|
36
|
+
function HeroHeading(
|
|
37
|
+
{
|
|
38
|
+
icon,
|
|
39
|
+
link,
|
|
40
|
+
title,
|
|
41
|
+
linkText,
|
|
42
|
+
subtitle,
|
|
43
|
+
children,
|
|
44
|
+
testId = 'fs-hero-heading',
|
|
45
|
+
...otherProps
|
|
46
|
+
},
|
|
47
|
+
ref
|
|
48
|
+
) {
|
|
49
|
+
const { variant, colorVariant } = useHero()
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<header
|
|
53
|
+
ref={ref}
|
|
54
|
+
data-fs-hero-heading
|
|
55
|
+
data-testid={testId}
|
|
56
|
+
{...otherProps}
|
|
57
|
+
>
|
|
58
|
+
<div data-fs-hero-wrapper className="layout__content">
|
|
59
|
+
<div data-fs-hero-info>
|
|
60
|
+
<h1 data-fs-hero-title>{title}</h1>
|
|
61
|
+
<p data-fs-hero-subtitle>{subtitle}</p>
|
|
62
|
+
{!!link && (
|
|
63
|
+
<LinkButton
|
|
64
|
+
href={link}
|
|
65
|
+
inverse={colorVariant === 'main'}
|
|
66
|
+
icon={<ArrowRight />}
|
|
67
|
+
iconPosition="right"
|
|
68
|
+
>
|
|
69
|
+
{linkText}
|
|
70
|
+
</LinkButton>
|
|
71
|
+
)}
|
|
72
|
+
</div>
|
|
73
|
+
{icon && variant === 'secondary' && (
|
|
74
|
+
<Icon data-fs-hero-icon component={icon} />
|
|
75
|
+
)}
|
|
76
|
+
</div>
|
|
77
|
+
</header>
|
|
78
|
+
)
|
|
79
|
+
}
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
export default HeroHeading
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'react'
|
|
2
|
+
import React, { forwardRef } from 'react'
|
|
3
|
+
|
|
4
|
+
export interface HeroImageProps extends HTMLAttributes<HTMLDivElement> {
|
|
5
|
+
/**
|
|
6
|
+
* ID to find this component in testing tools (e.g.: cypress, testing library, and jest).
|
|
7
|
+
*/
|
|
8
|
+
testId?: string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const HeroImage = forwardRef<HTMLDivElement, HeroImageProps>(function HeroImage(
|
|
12
|
+
{ children, testId = 'fs-hero-image', ...otherProps },
|
|
13
|
+
ref
|
|
14
|
+
) {
|
|
15
|
+
return (
|
|
16
|
+
<div ref={ref} data-fs-hero-image data-testid={testId} {...otherProps}>
|
|
17
|
+
{children}
|
|
18
|
+
</div>
|
|
19
|
+
)
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
export default HeroImage
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { default } from './Hero'
|
|
2
|
+
export type { HeroProps } from './Hero'
|
|
3
|
+
|
|
4
|
+
export { default as HeroImage } from './HeroImage'
|
|
5
|
+
export type { HeroImageProps } from './HeroImage'
|
|
6
|
+
|
|
7
|
+
export { default as HeroHeading } from './HeroHeading'
|
|
8
|
+
export type { HeroHeadingProps } from './HeroHeading'
|