@growth-angels/ds-core 0.0.5 → 1.1.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/dist/atoms/Button/Button.d.ts +3 -3
- package/dist/atoms/Button/Button.js +8 -8
- package/dist/atoms/Button/Button.stories.d.ts +2 -2
- package/dist/atoms/Button/Button.stories.js +15 -15
- package/dist/atoms/Button/Button.types.d.ts +2 -2
- package/dist/atoms/Icon/Icon.d.ts +1 -1
- package/dist/atoms/Icon/Icon.js +3 -3
- package/dist/atoms/Icon/Icon.types.d.ts +2 -1
- package/dist/atoms/Text/Text.d.ts +1 -0
- package/dist/atoms/Text/Text.js +4 -3
- package/dist/atoms/Text/Text.types.d.ts +5 -1
- package/dist/atoms/atoms.d.ts +3 -0
- package/dist/atoms/atoms.js +3 -0
- package/dist/context/SpoilerContext.d.ts +9 -0
- package/dist/context/SpoilerContext.js +15 -0
- package/dist/global.types.d.ts +4 -0
- package/dist/hooks/useReactAdaptater.d.ts +10 -2
- package/dist/hooks/useReactAdaptater.js +6 -3
- package/dist/hooks/useSpoilerContext.d.ts +4 -0
- package/dist/hooks/useSpoilerContext.js +12 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/layout/Container/Container.d.ts +2 -3
- package/dist/layout/Container/Container.js +10 -3
- package/dist/layout/Container/Container.types.d.ts +4 -1
- package/dist/layout/FlexBlock/FlexBlock.d.ts +2 -0
- package/dist/layout/FlexBlock/FlexBlock.js +21 -0
- package/dist/layout/FlexBlock/FlexBlock.types.d.ts +10 -0
- package/dist/layout/FlexBlock/FlexBlock.types.js +1 -0
- package/dist/layout/FlexCol/FlexCol.d.ts +5 -0
- package/dist/layout/FlexCol/FlexCol.js +4 -0
- package/dist/layout/FlexCol/FlexCol.types.d.ts +3 -0
- package/dist/layout/FlexCol/FlexCol.types.js +1 -0
- package/dist/layout/Grid/Grid.d.ts +1 -2
- package/dist/layout/Grid/Grid.js +3 -3
- package/dist/layout/Grid/Grid.types.d.ts +4 -4
- package/dist/layout/Grid/GridItem/GridItem.d.ts +2 -2
- package/dist/layout/Grid/GridItem/GridItem.js +10 -3
- package/dist/layout/Grid/GridItem/GridItem.types.d.ts +3 -2
- package/dist/layout/layout.d.ts +7 -0
- package/dist/layout/layout.js +7 -0
- package/dist/molecules/ButtonGroup/ButtonGroup.d.ts +2 -0
- package/dist/molecules/ButtonGroup/ButtonGroup.js +16 -0
- package/dist/molecules/ButtonGroup/ButtonGroup.types.d.ts +5 -0
- package/dist/molecules/ButtonGroup/ButtonGroup.types.js +1 -0
- package/dist/molecules/Spoiler/Spoiler.d.ts +2 -0
- package/dist/molecules/Spoiler/Spoiler.js +13 -0
- package/dist/molecules/Spoiler/Spoiler.stories.d.ts +7 -0
- package/dist/molecules/Spoiler/Spoiler.stories.js +25 -0
- package/dist/molecules/Spoiler/Spoiler.types.d.ts +6 -0
- package/dist/molecules/Spoiler/Spoiler.types.js +1 -0
- package/dist/molecules/molecules.d.ts +2 -0
- package/dist/molecules/molecules.js +2 -0
- package/dist/organisms/Card/Card.d.ts +3 -3
- package/dist/organisms/Card/Card.js +4 -4
- package/dist/organisms/Card/Card.types.d.ts +12 -3
- package/dist/organisms/Card/CardDefault.stories.d.ts +2 -2
- package/dist/organisms/Card/CardDefault.stories.js +17 -17
- package/dist/organisms/Carousel/Carousel.js +5 -1
- package/dist/organisms/Carousel/Carousel.types.d.ts +2 -1
- package/dist/organisms/SpoilerList/SpoilerList.d.ts +2 -0
- package/dist/organisms/SpoilerList/SpoilerList.js +11 -0
- package/dist/organisms/SpoilerList/SpoilerList.types.d.ts +4 -0
- package/dist/organisms/SpoilerList/SpoilerList.types.js +1 -0
- package/dist/organisms/organisms.d.ts +2 -0
- package/dist/organisms/organisms.js +2 -0
- package/dist/styles.d.ts +1 -0
- package/dist/styles.js +1 -0
- package/package.json +10 -9
- package/src/atoms/Button/Button.scss +23 -19
- package/src/atoms/Button/Button.stories.tsx +17 -17
- package/src/atoms/Button/Button.tsx +20 -16
- package/src/atoms/Button/Button.types.ts +2 -2
- package/src/atoms/Icon/Icon.scss +9 -9
- package/src/atoms/Icon/Icon.tsx +10 -8
- package/src/atoms/Icon/Icon.types.ts +3 -1
- package/src/atoms/Text/Text.scss +33 -2
- package/src/atoms/Text/Text.tsx +13 -8
- package/src/atoms/Text/Text.types.ts +5 -1
- package/src/atoms/atoms.scss +3 -3
- package/src/atoms/atoms.ts +3 -0
- package/src/context/SpoilerContext.tsx +24 -0
- package/src/global.types.ts +4 -0
- package/src/hooks/useReactAdaptater.ts +20 -4
- package/src/hooks/useSpoilerContext.ts +17 -0
- package/src/index.scss +2 -0
- package/src/index.ts +1 -0
- package/src/layout/Container/Container.scss +58 -13
- package/src/layout/Container/Container.tsx +17 -9
- package/src/layout/Container/Container.types.ts +4 -2
- package/src/layout/FlexBlock/FlexBlock.scss +4 -0
- package/src/layout/FlexBlock/FlexBlock.tsx +31 -0
- package/src/layout/FlexBlock/FlexBlock.types.ts +12 -0
- package/src/layout/FlexCol/FlexCol.scss +5 -0
- package/src/layout/FlexCol/FlexCol.tsx +12 -0
- package/src/layout/FlexCol/FlexCol.types.ts +3 -0
- package/src/layout/Grid/Grid.scss +8 -4
- package/src/layout/Grid/Grid.tsx +12 -8
- package/src/layout/Grid/Grid.types.ts +4 -4
- package/src/layout/Grid/GridItem/GridItem.scss +17 -4
- package/src/layout/Grid/GridItem/GridItem.tsx +28 -13
- package/src/layout/Grid/GridItem/GridItem.types.ts +3 -2
- package/src/layout/layout.scss +5 -3
- package/src/layout/layout.ts +8 -1
- package/src/molecules/ButtonGroup/ButtonGroup.scss +5 -0
- package/src/molecules/ButtonGroup/ButtonGroup.tsx +23 -0
- package/src/molecules/ButtonGroup/ButtonGroup.types.ts +6 -0
- package/src/molecules/Spoiler/Spoiler.scss +47 -0
- package/src/molecules/Spoiler/Spoiler.stories.tsx +44 -0
- package/src/molecules/Spoiler/Spoiler.tsx +30 -0
- package/src/molecules/Spoiler/Spoiler.types.ts +6 -0
- package/src/molecules/molecules.scss +2 -0
- package/src/molecules/molecules.ts +2 -0
- package/src/organisms/Card/Card.scss +50 -10
- package/src/organisms/Card/Card.tsx +17 -6
- package/src/organisms/Card/Card.types.ts +12 -3
- package/src/organisms/Card/CardDefault.stories.tsx +40 -37
- package/src/organisms/Carousel/Carousel.scss +3 -0
- package/src/organisms/Carousel/Carousel.tsx +7 -1
- package/src/organisms/Carousel/Carousel.types.ts +3 -1
- package/src/organisms/SpoilerList/SpoilerList.scss +5 -0
- package/src/organisms/SpoilerList/SpoilerList.tsx +19 -0
- package/src/organisms/SpoilerList/SpoilerList.types.ts +5 -0
- package/src/organisms/organisms.scss +3 -2
- package/src/organisms/organisms.ts +3 -1
- package/src/scss.d.ts +4 -0
- package/src/styles.ts +1 -0
- package/src/utils/_spacings.scss +17 -0
- package/src/utils/utils.scss +1 -0
- package/dist/utils.d.ts +0 -0
- package/dist/utils.js +0 -1
- package/src/utils.ts +0 -0
|
@@ -1,8 +1,17 @@
|
|
|
1
|
-
export type
|
|
2
|
-
export type CardType = '
|
|
1
|
+
export type CardVariant = 'primary' | 'secondary';
|
|
2
|
+
export type CardType = 'editorial' | 'image' | 'icon' | 'background-image';
|
|
3
3
|
export interface CardProps {
|
|
4
4
|
children: React.ReactNode | React.ReactNode[] | JSX.Element;
|
|
5
|
-
variant:
|
|
5
|
+
variant: CardVariant;
|
|
6
6
|
type?: CardType;
|
|
7
|
+
backgroundImage?: {
|
|
8
|
+
alt?: string;
|
|
9
|
+
sizes: {
|
|
10
|
+
full: {
|
|
11
|
+
url: string;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
};
|
|
7
15
|
extraClassNames?: string[];
|
|
16
|
+
style?: React.CSSProperties;
|
|
8
17
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from
|
|
2
|
-
import { Card } from
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
2
|
+
import { Card } from "./Card";
|
|
3
3
|
declare const meta: Meta<typeof Card>;
|
|
4
4
|
export default meta;
|
|
5
5
|
type Story = StoryObj<typeof Card>;
|
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Card } from
|
|
3
|
-
import { Button } from
|
|
4
|
-
import CardDefaultHeader600x400 from
|
|
5
|
-
import CardDefaultHeader50x50 from
|
|
2
|
+
import { Card } from "./Card";
|
|
3
|
+
import { Button } from "../../atoms/atoms";
|
|
4
|
+
import CardDefaultHeader600x400 from "../../../assets/600x400.svg";
|
|
5
|
+
import CardDefaultHeader50x50 from "../../../assets/50x50.svg";
|
|
6
6
|
const meta = {
|
|
7
|
-
title:
|
|
7
|
+
title: "Organisms/Card/Default",
|
|
8
8
|
component: Card,
|
|
9
|
-
tags: [
|
|
9
|
+
tags: ["autodocs"],
|
|
10
10
|
};
|
|
11
11
|
export default meta;
|
|
12
12
|
const CardChildren = ({ image }) => {
|
|
13
13
|
const images = {
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
"400x600": CardDefaultHeader600x400,
|
|
15
|
+
"50x50": CardDefaultHeader50x50,
|
|
16
16
|
};
|
|
17
|
-
return _jsxs(_Fragment, { children: [_jsx("div", { className: "ga-ds-card__header", children: _jsx("img", { src: images[image], alt: "Card header" }) }), _jsx("div", { className: "ga-ds-card__title", children: _jsx("h2", { children: "Card title" }) }), _jsx("div", { className:
|
|
17
|
+
return (_jsxs(_Fragment, { children: [_jsx("div", { className: "ga-ds-card__header", children: _jsx("img", { src: images[image], alt: "Card header" }) }), _jsx("div", { className: "ga-ds-card__title", children: _jsx("h2", { children: "Card title" }) }), _jsx("div", { className: "ga-ds-card__content", children: _jsx("p", { children: "Lorem ipsum dolor sit amet consectetur, adipisicing elit. Porro temporibus quam ex consequatur est laboriosam nam quisquam doloremque perferendis quo ut, tempora error neque modi delectus assumenda! A, doloremque nulla." }) }), _jsx("div", { className: "ga-ds-card__footer", children: _jsx(Button, { as: "a", variant: "primary", children: "Read more" }) })] }));
|
|
18
18
|
};
|
|
19
19
|
export const Primary = {
|
|
20
20
|
args: {
|
|
21
|
-
variant:
|
|
22
|
-
type:
|
|
23
|
-
children: _jsx(CardChildren, { image:
|
|
24
|
-
}
|
|
21
|
+
variant: "primary",
|
|
22
|
+
type: "image",
|
|
23
|
+
children: _jsx(CardChildren, { image: "400x600" }),
|
|
24
|
+
},
|
|
25
25
|
};
|
|
26
26
|
export const Secondary = {
|
|
27
27
|
args: {
|
|
28
|
-
variant:
|
|
29
|
-
type:
|
|
30
|
-
children: _jsx(CardChildren, { image:
|
|
31
|
-
}
|
|
28
|
+
variant: "secondary",
|
|
29
|
+
type: "image",
|
|
30
|
+
children: _jsx(CardChildren, { image: "400x600" }),
|
|
31
|
+
},
|
|
32
32
|
};
|
|
@@ -65,7 +65,11 @@ export const Carousel = (props) => {
|
|
|
65
65
|
});
|
|
66
66
|
setActiveSlideIndex(nextIndex);
|
|
67
67
|
};
|
|
68
|
-
|
|
68
|
+
const classes = ["ga-ds-carousel"];
|
|
69
|
+
if (props.extraClassNames) {
|
|
70
|
+
classes.push(...props.extraClassNames);
|
|
71
|
+
}
|
|
72
|
+
return (_jsxs("div", { className: classes.join(" "), style: style, children: [navigation?.positionY === "top" && hasNavigation && (_jsx(CarouselNavigation, { goPrev: goPrev, goNext: goNext, isAtStart: isAtStart, isAtEnd: isAtEnd })), _jsx("div", { className: "ga-ds-carousel__track", ref: trackRef, style: {
|
|
69
73
|
"--ga-ds-space-between": `${spaceBetween / 10}rem`,
|
|
70
74
|
}, children: context === "wp-editor"
|
|
71
75
|
? children
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { WordpressDefault } from "../../global.types";
|
|
1
2
|
export type Attributes = {
|
|
2
3
|
context?: 'wp-editor';
|
|
3
4
|
slidesPerView?: {
|
|
@@ -15,6 +16,6 @@ export type Attributes = {
|
|
|
15
16
|
positionY: 'bottom' | 'top';
|
|
16
17
|
};
|
|
17
18
|
};
|
|
18
|
-
export interface CarouselProps extends Attributes {
|
|
19
|
+
export interface CarouselProps extends Attributes, WordpressDefault {
|
|
19
20
|
children: React.ReactNode | React.ReactNode[];
|
|
20
21
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { SpoilerProvider } from "../../context/SpoilerContext";
|
|
3
|
+
import { useReactAdapter } from "../../hooks/useReactAdaptater";
|
|
4
|
+
export const SpoilerList = ({ children, extraClassNames }) => {
|
|
5
|
+
const { Children, cloneElement } = useReactAdapter();
|
|
6
|
+
const classes = ["ga-ds-spoiler-list"];
|
|
7
|
+
if (extraClassNames) {
|
|
8
|
+
classes.push(...extraClassNames);
|
|
9
|
+
}
|
|
10
|
+
return (_jsx("div", { className: classes.join(" "), children: _jsx(SpoilerProvider, { children: Children.toArray(children).map((child, index) => cloneElement(child, { index })) }) }));
|
|
11
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/styles.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './index.scss';
|
package/dist/styles.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './index.scss';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@growth-angels/ds-core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Design system by Growth Angels",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"private": false,
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
"import": "./dist/index.js",
|
|
17
17
|
"types": "./dist/index.d.ts"
|
|
18
18
|
},
|
|
19
|
-
"./styles": "./src/
|
|
19
|
+
"./styles": "./src/styles.ts",
|
|
20
|
+
"./styles/scss": "./src/index.scss"
|
|
20
21
|
},
|
|
21
22
|
"files": [
|
|
22
23
|
"dist",
|
|
@@ -31,24 +32,24 @@
|
|
|
31
32
|
"build-storybook": "storybook build"
|
|
32
33
|
},
|
|
33
34
|
"dependencies": {
|
|
34
|
-
"@growth-angels/foundation": "0.0
|
|
35
|
+
"@growth-angels/foundation": "1.0.0"
|
|
35
36
|
},
|
|
36
37
|
"peerDependencies": {
|
|
37
38
|
"react": ">=18"
|
|
38
39
|
},
|
|
39
40
|
"devDependencies": {
|
|
40
|
-
"@chromatic-com/storybook": "^4.1.
|
|
41
|
-
"@storybook/addon-a11y": "^
|
|
42
|
-
"@storybook/addon-docs": "^
|
|
43
|
-
"@storybook/addon-vitest": "^
|
|
44
|
-
"@storybook/react-vite": "^
|
|
41
|
+
"@chromatic-com/storybook": "^4.1.2",
|
|
42
|
+
"@storybook/addon-a11y": "^10.0.4",
|
|
43
|
+
"@storybook/addon-docs": "^10.0.4",
|
|
44
|
+
"@storybook/addon-vitest": "^10.0.4",
|
|
45
|
+
"@storybook/react-vite": "^10.0.4",
|
|
45
46
|
"@types/react": "^18.0.0",
|
|
46
47
|
"@vitest/browser": "^3.2.4",
|
|
47
48
|
"@vitest/coverage-v8": "^3.2.4",
|
|
48
49
|
"concurrently": "^9.2.1",
|
|
49
50
|
"playwright": "^1.56.1",
|
|
50
51
|
"sass": "^1.93.2",
|
|
51
|
-
"storybook": "^
|
|
52
|
+
"storybook": "^10.0.4",
|
|
52
53
|
"typescript": "^5.4.0",
|
|
53
54
|
"vitest": "^3.2.4"
|
|
54
55
|
}
|
|
@@ -1,31 +1,35 @@
|
|
|
1
|
-
.ga-ds-
|
|
1
|
+
.ga-ds-button > *,
|
|
2
|
+
button.ga-ds-button {
|
|
2
3
|
padding: var(--ga-button-padding);
|
|
3
|
-
display: inline-flex;
|
|
4
4
|
border: none;
|
|
5
5
|
font-size: var(--ga-font-sizes-base);
|
|
6
6
|
font-weight: var(--ga-font-weight-base);
|
|
7
7
|
font-family: var(--ga-font-family-button);
|
|
8
8
|
border-radius: var(--ga-button-radius, 0);
|
|
9
9
|
cursor: pointer;
|
|
10
|
+
}
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
.ga-ds-button--primary > *,
|
|
13
|
+
button.ga-ds-button--primary {
|
|
14
|
+
background-color: var(--ga-button-background-primary, #eee);
|
|
15
|
+
color: var(--ga-button-color-primary, #000);
|
|
16
|
+
}
|
|
15
17
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
.ga-ds-button--secondary > *,
|
|
19
|
+
button.ga-ds-button--secondary {
|
|
20
|
+
background-color: var(--ga-button-background-secondary, #424242);
|
|
21
|
+
color: var(--ga-button-color-secondary, #fff);
|
|
22
|
+
}
|
|
20
23
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
.ga-ds-button--link > *,
|
|
25
|
+
button.ga-ds-button--link {
|
|
26
|
+
color: var(--ga-button-color-link, purple);
|
|
27
|
+
padding: 0;
|
|
28
|
+
}
|
|
25
29
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
.ga-ds-button--icon > *,
|
|
31
|
+
button.ga-ds-button--icon {
|
|
32
|
+
--ga-button-padding: 0.8rem 1.2rem;
|
|
33
|
+
justify-content: center;
|
|
34
|
+
align-items: center;
|
|
31
35
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from
|
|
2
|
-
import { Button } from
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react-vite"
|
|
2
|
+
import { Button } from "./Button"
|
|
3
3
|
|
|
4
4
|
const meta: Meta<typeof Button> = {
|
|
5
|
-
title:
|
|
5
|
+
title: "Atoms/Button",
|
|
6
6
|
component: Button,
|
|
7
|
-
tags: [
|
|
7
|
+
tags: ["autodocs"],
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export default meta
|
|
@@ -12,27 +12,27 @@ type Story = StoryObj<typeof Button>
|
|
|
12
12
|
|
|
13
13
|
export const Primary: Story = {
|
|
14
14
|
args: {
|
|
15
|
-
variant:
|
|
16
|
-
children:
|
|
17
|
-
as:
|
|
18
|
-
href:
|
|
15
|
+
variant: "primary",
|
|
16
|
+
children: "Button",
|
|
17
|
+
as: "a",
|
|
18
|
+
href: "#",
|
|
19
19
|
},
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
export const Secondary: Story = {
|
|
23
23
|
args: {
|
|
24
|
-
variant:
|
|
25
|
-
children:
|
|
26
|
-
as:
|
|
27
|
-
href:
|
|
24
|
+
variant: "secondary",
|
|
25
|
+
children: "Button",
|
|
26
|
+
as: "a",
|
|
27
|
+
href: "#",
|
|
28
28
|
},
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
export const Link: Story = {
|
|
32
32
|
args: {
|
|
33
|
-
variant:
|
|
34
|
-
children:
|
|
35
|
-
as:
|
|
36
|
-
href:
|
|
33
|
+
variant: "link",
|
|
34
|
+
children: "Button",
|
|
35
|
+
as: "a",
|
|
36
|
+
href: "#",
|
|
37
37
|
},
|
|
38
|
-
}
|
|
38
|
+
}
|
|
@@ -1,25 +1,29 @@
|
|
|
1
|
-
import { JSX } from
|
|
2
|
-
import type { ButtonProps } from
|
|
3
|
-
import React from
|
|
4
|
-
import { Icon } from
|
|
1
|
+
import { JSX } from "react/jsx-runtime"
|
|
2
|
+
import type { ButtonProps } from "./Button.types"
|
|
3
|
+
import React from "react"
|
|
4
|
+
import { Icon } from "../Icon/Icon"
|
|
5
5
|
|
|
6
6
|
export const Button = <T extends React.ElementType = "button">(props: ButtonProps<T>): JSX.Element => {
|
|
7
7
|
const { as, children, variant, preventDefault, icon, extraClassNames, ...restProps } = props
|
|
8
8
|
let customVariant = variant
|
|
9
|
-
if(icon) {
|
|
10
|
-
customVariant =
|
|
9
|
+
if (icon) {
|
|
10
|
+
customVariant = "icon"
|
|
11
11
|
}
|
|
12
|
-
const classNames = [
|
|
13
|
-
|
|
12
|
+
const classNames = ["ga-ds-button", `ga-ds-button--${customVariant}`, ...(extraClassNames || [])]
|
|
13
|
+
const handleClick: React.MouseEventHandler<React.ElementRef<T>> = (e) => {
|
|
14
14
|
if (preventDefault) e.preventDefault()
|
|
15
15
|
props?.onClick?.(e)
|
|
16
16
|
}
|
|
17
|
-
return React.createElement(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
return React.createElement(
|
|
18
|
+
as || "button",
|
|
19
|
+
{
|
|
20
|
+
...restProps,
|
|
21
|
+
className: classNames.join(" "),
|
|
22
|
+
onClick: handleClick,
|
|
23
|
+
},
|
|
24
|
+
<>
|
|
25
|
+
{icon && <Icon name={icon} size="sm" />}
|
|
26
|
+
{children && children}
|
|
27
|
+
</>
|
|
28
|
+
)
|
|
25
29
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { WordpressDefault } from "../../global.types.js"
|
|
2
2
|
import React, { ElementType, ComponentPropsWithoutRef } from "react"
|
|
3
3
|
|
|
4
|
-
export type
|
|
4
|
+
export type ButtonVariant = "primary" | "secondary" | "tertiary" | "link" | "icon"
|
|
5
5
|
|
|
6
6
|
export type ButtonProps<T extends ElementType = "button"> = {
|
|
7
7
|
as?: T
|
|
8
|
-
variant?:
|
|
8
|
+
variant?: ButtonVariant
|
|
9
9
|
hasIcon?: "left" | "right"
|
|
10
10
|
icon?: "chevron-left" | "chevron-right"
|
|
11
11
|
preventDefault?: boolean
|
package/src/atoms/Icon/Icon.scss
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
.ga-ds-icon {
|
|
2
|
-
width: 2.4rem;
|
|
3
|
-
height: 2.4rem;
|
|
2
|
+
width: var(--icon-size, 2.4rem);
|
|
3
|
+
height: var(--icon-size, 2.4rem);
|
|
4
4
|
|
|
5
5
|
&--sm {
|
|
6
|
-
width: 1.8rem;
|
|
7
|
-
height: 1.8rem;
|
|
6
|
+
width: var(--icon-size-sm, 1.8rem);
|
|
7
|
+
height: var(--icon-size-sm, 1.8rem);
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
&--md {
|
|
11
|
-
width: 3rem;
|
|
12
|
-
height: 3rem;
|
|
11
|
+
width: var(--icon-size-md, 3rem);
|
|
12
|
+
height: var(--icon-size-md, 3rem);
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
&--lg {
|
|
16
|
-
width: 4rem;
|
|
17
|
-
height: 4rem;
|
|
16
|
+
width: var(--icon-size-lg, 4rem);
|
|
17
|
+
height: var(--icon-size-lg, 4rem);
|
|
18
18
|
}
|
|
19
|
-
}
|
|
19
|
+
}
|
package/src/atoms/Icon/Icon.tsx
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { useThemeAssets } from "../../hooks/useThemeAssets"
|
|
2
|
-
import { IconProps } from "./Icon.types"
|
|
1
|
+
import { useThemeAssets } from "../../hooks/useThemeAssets"
|
|
2
|
+
import { IconProps } from "./Icon.types"
|
|
3
3
|
|
|
4
|
-
export const Icon = ({ name, size }: IconProps) => {
|
|
4
|
+
export const Icon = ({ name, size, extraClassNames }: IconProps) => {
|
|
5
5
|
const { iconsSprite } = useThemeAssets()
|
|
6
|
-
const
|
|
7
|
-
return
|
|
8
|
-
<
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
const classNames = ["ga-ds-icon", ...(size ? [`ga-ds-icon--${size}`] : []), ...(extraClassNames || [])]
|
|
7
|
+
return (
|
|
8
|
+
<svg className={classNames.join(" ")} xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
|
9
|
+
<use xlinkHref={`${iconsSprite}#${name}`} />
|
|
10
|
+
</svg>
|
|
11
|
+
)
|
|
12
|
+
}
|
package/src/atoms/Text/Text.scss
CHANGED
|
@@ -1,4 +1,35 @@
|
|
|
1
|
-
.ga-ds-
|
|
1
|
+
.ga-ds-text {
|
|
2
|
+
font-size: var(--font-size, 1.6rem);
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.ga-ds-text--heading {
|
|
2
6
|
font-weight: var(--ga-font-weight-heading);
|
|
3
7
|
font-family: var(--ga-font-family-heading);
|
|
4
|
-
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.ga-ds-text--paragraph {
|
|
11
|
+
font-weight: var(--ga-font-weight-body);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.ga-ds-text--center {
|
|
15
|
+
text-align: center;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.ga-ds-text--right {
|
|
19
|
+
text-align: right;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
$sizes: (88, 64, 56, 48, 40, 32, 24, 20, 18, 16);
|
|
23
|
+
|
|
24
|
+
@each $size in $sizes {
|
|
25
|
+
.ga-ds-text--size-#{$size} {
|
|
26
|
+
font-size: calc(#{$size} / 10 * 1rem);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
$weights: (400, 500, 600, 700);
|
|
31
|
+
@each $weight in $weights {
|
|
32
|
+
.ga-ds-text--weight-#{$weight} {
|
|
33
|
+
font-weight: #{$weight};
|
|
34
|
+
}
|
|
35
|
+
}
|
package/src/atoms/Text/Text.tsx
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
|
-
import React from "react"
|
|
2
|
-
import { TextProps } from "./Text.types"
|
|
1
|
+
import React from "react"
|
|
2
|
+
import { TextProps } from "./Text.types"
|
|
3
3
|
|
|
4
4
|
export const Text = (props: TextProps) => {
|
|
5
|
-
const { as, children, classNames, type = "paragraph" } = props
|
|
5
|
+
const { as, children, classNames, type = "paragraph", size, style } = props
|
|
6
6
|
|
|
7
|
-
const className = typeof classNames ===
|
|
7
|
+
const className = typeof classNames === "string" ? classNames : classNames?.join(" ") || ""
|
|
8
8
|
|
|
9
|
-
return React.createElement(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
9
|
+
return React.createElement(
|
|
10
|
+
as,
|
|
11
|
+
{
|
|
12
|
+
className: `ga-ds-${type} ga-ds-text--${size} ${className}`,
|
|
13
|
+
style: style || undefined,
|
|
14
|
+
},
|
|
15
|
+
children
|
|
16
|
+
)
|
|
17
|
+
}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
export interface
|
|
1
|
+
export interface Attributes {
|
|
2
|
+
size: '64' | '56' | '48' | '40' | '32' | '24' | '20' | '16' | '14' | '12'
|
|
2
3
|
as: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'p' | 'span'
|
|
4
|
+
}
|
|
5
|
+
export interface TextProps extends Attributes {
|
|
3
6
|
classNames?: string[] | string
|
|
4
7
|
type?: 'heading' | 'paragraph'
|
|
8
|
+
style?: React.CSSProperties
|
|
5
9
|
children: string
|
|
6
10
|
}
|
package/src/atoms/atoms.scss
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
@use
|
|
2
|
-
@use
|
|
3
|
-
@use
|
|
1
|
+
@use "./Button/Button.scss";
|
|
2
|
+
@use "./Text/Text.scss";
|
|
3
|
+
@use "./Icon/Icon.scss";
|
package/src/atoms/atoms.ts
CHANGED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { useReactAdapter } from "../hooks/useReactAdaptater"
|
|
2
|
+
|
|
3
|
+
const { createContext, useContext, useState } = useReactAdapter()
|
|
4
|
+
|
|
5
|
+
interface SpoilerContextProps {
|
|
6
|
+
activeIndex: number | null
|
|
7
|
+
setActiveIndex: (index: number | null) => void
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const SpoilerContext = createContext<SpoilerContextProps | undefined>(undefined)
|
|
11
|
+
|
|
12
|
+
export const SpoilerProvider = ({ children }: { children: React.ReactNode }) => {
|
|
13
|
+
const [activeIndex, setActiveIndex] = useState<number | null>(0)
|
|
14
|
+
|
|
15
|
+
return <SpoilerContext.Provider value={{ activeIndex, setActiveIndex }}>{children}</SpoilerContext.Provider>
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const useSpoilerContext = (): SpoilerContextProps => {
|
|
19
|
+
const context = useContext(SpoilerContext)
|
|
20
|
+
if (!context) {
|
|
21
|
+
throw new Error("useSpoilerContext must be used within a SpoilerProvider")
|
|
22
|
+
}
|
|
23
|
+
return context
|
|
24
|
+
}
|
package/src/global.types.ts
CHANGED
|
@@ -1,8 +1,24 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
// @ts-ignore - React types from window.wp.element
|
|
4
|
+
type ReactType = typeof import('react')
|
|
5
|
+
|
|
6
|
+
declare global {
|
|
7
|
+
interface Window {
|
|
8
|
+
wp?: {
|
|
9
|
+
element?: ReactType
|
|
10
|
+
}
|
|
6
11
|
}
|
|
7
|
-
return (window as typeof window & { wp: { element: typeof React } }).wp.element
|
|
8
12
|
}
|
|
13
|
+
|
|
14
|
+
export const useReactAdapter = (): ReactType => {
|
|
15
|
+
// Check if WordPress element is available (WordPress context)
|
|
16
|
+
if (typeof window !== 'undefined' && window.wp?.element) {
|
|
17
|
+
return window.wp.element
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Fallback for non-WordPress environments (Storybook, tests, SSR)
|
|
21
|
+
// This will bundle React only in non-WordPress builds
|
|
22
|
+
return React
|
|
23
|
+
}
|
|
24
|
+
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useReactAdapter } from "./useReactAdaptater";
|
|
2
|
+
|
|
3
|
+
export default function() {
|
|
4
|
+
const { useState} = useReactAdapter();
|
|
5
|
+
const [activeIndex, setActiveIndex] = useState<number | null>(null);
|
|
6
|
+
|
|
7
|
+
const toggleIndex = (index: number) => {
|
|
8
|
+
setActiveIndex((currentIndex) =>
|
|
9
|
+
currentIndex === index ? null : index
|
|
10
|
+
);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
return {
|
|
14
|
+
activeIndex,
|
|
15
|
+
toggleIndex,
|
|
16
|
+
};
|
|
17
|
+
}
|
package/src/index.scss
CHANGED