@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,4 +1,4 @@
|
|
|
1
|
-
import { JSX } from
|
|
2
|
-
import type { ButtonProps } from
|
|
3
|
-
import React from
|
|
1
|
+
import { JSX } from "react/jsx-runtime";
|
|
2
|
+
import type { ButtonProps } from "./Button.types";
|
|
3
|
+
import React from "react";
|
|
4
4
|
export declare const Button: <T extends React.ElementType = "button">(props: ButtonProps<T>) => JSX.Element;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import React from
|
|
3
|
-
import { Icon } from
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { Icon } from "../Icon/Icon";
|
|
4
4
|
export const Button = (props) => {
|
|
5
5
|
const { as, children, variant, preventDefault, icon, extraClassNames, ...restProps } = props;
|
|
6
6
|
let customVariant = variant;
|
|
7
7
|
if (icon) {
|
|
8
|
-
customVariant =
|
|
8
|
+
customVariant = "icon";
|
|
9
9
|
}
|
|
10
|
-
const classNames = [
|
|
10
|
+
const classNames = ["ga-ds-button", `ga-ds-button--${customVariant}`, ...(extraClassNames || [])];
|
|
11
11
|
const handleClick = (e) => {
|
|
12
12
|
if (preventDefault)
|
|
13
13
|
e.preventDefault();
|
|
14
14
|
props?.onClick?.(e);
|
|
15
15
|
};
|
|
16
|
-
return React.createElement(as ||
|
|
16
|
+
return React.createElement(as || "button", {
|
|
17
17
|
...restProps,
|
|
18
|
-
className: classNames.join(
|
|
19
|
-
onClick: handleClick
|
|
20
|
-
}, _jsxs(_Fragment, { children: [icon && _jsx(Icon, { name: icon, size:
|
|
18
|
+
className: classNames.join(" "),
|
|
19
|
+
onClick: handleClick,
|
|
20
|
+
}, _jsxs(_Fragment, { children: [icon && _jsx(Icon, { name: icon, size: "sm" }), children && children] }));
|
|
21
21
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
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
|
declare const meta: Meta<typeof Button>;
|
|
4
4
|
export default meta;
|
|
5
5
|
type Story = StoryObj<typeof Button>;
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import { Button } from
|
|
1
|
+
import { Button } from "./Button";
|
|
2
2
|
const meta = {
|
|
3
|
-
title:
|
|
3
|
+
title: "Atoms/Button",
|
|
4
4
|
component: Button,
|
|
5
|
-
tags: [
|
|
5
|
+
tags: ["autodocs"],
|
|
6
6
|
};
|
|
7
7
|
export default meta;
|
|
8
8
|
export const Primary = {
|
|
9
9
|
args: {
|
|
10
|
-
variant:
|
|
11
|
-
children:
|
|
12
|
-
as:
|
|
13
|
-
href:
|
|
10
|
+
variant: "primary",
|
|
11
|
+
children: "Button",
|
|
12
|
+
as: "a",
|
|
13
|
+
href: "#",
|
|
14
14
|
},
|
|
15
15
|
};
|
|
16
16
|
export const Secondary = {
|
|
17
17
|
args: {
|
|
18
|
-
variant:
|
|
19
|
-
children:
|
|
20
|
-
as:
|
|
21
|
-
href:
|
|
18
|
+
variant: "secondary",
|
|
19
|
+
children: "Button",
|
|
20
|
+
as: "a",
|
|
21
|
+
href: "#",
|
|
22
22
|
},
|
|
23
23
|
};
|
|
24
24
|
export const Link = {
|
|
25
25
|
args: {
|
|
26
|
-
variant:
|
|
27
|
-
children:
|
|
28
|
-
as:
|
|
29
|
-
href:
|
|
26
|
+
variant: "link",
|
|
27
|
+
children: "Button",
|
|
28
|
+
as: "a",
|
|
29
|
+
href: "#",
|
|
30
30
|
},
|
|
31
31
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { WordpressDefault } from "../../global.types.js";
|
|
2
2
|
import React, { ElementType, ComponentPropsWithoutRef } from "react";
|
|
3
|
-
export type
|
|
3
|
+
export type ButtonVariant = "primary" | "secondary" | "tertiary" | "link" | "icon";
|
|
4
4
|
export type ButtonProps<T extends ElementType = "button"> = {
|
|
5
5
|
as?: T;
|
|
6
|
-
variant?:
|
|
6
|
+
variant?: ButtonVariant;
|
|
7
7
|
hasIcon?: "left" | "right";
|
|
8
8
|
icon?: "chevron-left" | "chevron-right";
|
|
9
9
|
preventDefault?: boolean;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { IconProps } from "./Icon.types";
|
|
2
|
-
export declare const Icon: ({ name, size }: IconProps) => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare const Icon: ({ name, size, extraClassNames }: IconProps) => import("react/jsx-runtime").JSX.Element;
|
package/dist/atoms/Icon/Icon.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useThemeAssets } from "../../hooks/useThemeAssets";
|
|
3
|
-
export const Icon = ({ name, size }) => {
|
|
3
|
+
export const Icon = ({ name, size, extraClassNames }) => {
|
|
4
4
|
const { iconsSprite } = useThemeAssets();
|
|
5
|
-
const
|
|
6
|
-
return _jsx("svg", { className:
|
|
5
|
+
const classNames = ["ga-ds-icon", ...(size ? [`ga-ds-icon--${size}`] : []), ...(extraClassNames || [])];
|
|
6
|
+
return (_jsx("svg", { className: classNames.join(" "), xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: _jsx("use", { xlinkHref: `${iconsSprite}#${name}` }) }));
|
|
7
7
|
};
|
package/dist/atoms/Text/Text.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
export const Text = (props) => {
|
|
3
|
-
const { as, children, classNames, type = "paragraph" } = props;
|
|
4
|
-
const className = typeof classNames ===
|
|
3
|
+
const { as, children, classNames, type = "paragraph", size, style } = props;
|
|
4
|
+
const className = typeof classNames === "string" ? classNames : classNames?.join(" ") || "";
|
|
5
5
|
return React.createElement(as, {
|
|
6
|
-
className: `ga-ds-${type} ${className}`,
|
|
6
|
+
className: `ga-ds-${type} ga-ds-text--${size} ${className}`,
|
|
7
|
+
style: style || undefined,
|
|
7
8
|
}, children);
|
|
8
9
|
};
|
|
@@ -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/dist/atoms/atoms.d.ts
CHANGED
package/dist/atoms/atoms.js
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
interface SpoilerContextProps {
|
|
2
|
+
activeIndex: number | null;
|
|
3
|
+
setActiveIndex: (index: number | null) => void;
|
|
4
|
+
}
|
|
5
|
+
export declare const SpoilerProvider: ({ children }: {
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export declare const useSpoilerContext: () => SpoilerContextProps;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useReactAdapter } from "../hooks/useReactAdaptater";
|
|
3
|
+
const { createContext, useContext, useState } = useReactAdapter();
|
|
4
|
+
const SpoilerContext = createContext(undefined);
|
|
5
|
+
export const SpoilerProvider = ({ children }) => {
|
|
6
|
+
const [activeIndex, setActiveIndex] = useState(0);
|
|
7
|
+
return _jsx(SpoilerContext.Provider, { value: { activeIndex, setActiveIndex }, children: children });
|
|
8
|
+
};
|
|
9
|
+
export const useSpoilerContext = () => {
|
|
10
|
+
const context = useContext(SpoilerContext);
|
|
11
|
+
if (!context) {
|
|
12
|
+
throw new Error("useSpoilerContext must be used within a SpoilerProvider");
|
|
13
|
+
}
|
|
14
|
+
return context;
|
|
15
|
+
};
|
package/dist/global.types.d.ts
CHANGED
|
@@ -1,2 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
type ReactType = typeof import('react');
|
|
2
|
+
declare global {
|
|
3
|
+
interface Window {
|
|
4
|
+
wp?: {
|
|
5
|
+
element?: ReactType;
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export declare const useReactAdapter: () => ReactType;
|
|
10
|
+
export {};
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
export const useReactAdapter = () => {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
// Check if WordPress element is available (WordPress context)
|
|
4
|
+
if (typeof window !== 'undefined' && window.wp?.element) {
|
|
5
|
+
return window.wp.element;
|
|
5
6
|
}
|
|
6
|
-
|
|
7
|
+
// Fallback for non-WordPress environments (Storybook, tests, SSR)
|
|
8
|
+
// This will bundle React only in non-WordPress builds
|
|
9
|
+
return React;
|
|
7
10
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useReactAdapter } from "./useReactAdaptater";
|
|
2
|
+
export default function () {
|
|
3
|
+
const { useState } = useReactAdapter();
|
|
4
|
+
const [activeIndex, setActiveIndex] = useState(null);
|
|
5
|
+
const toggleIndex = (index) => {
|
|
6
|
+
setActiveIndex((currentIndex) => currentIndex === index ? null : index);
|
|
7
|
+
};
|
|
8
|
+
return {
|
|
9
|
+
activeIndex,
|
|
10
|
+
toggleIndex,
|
|
11
|
+
};
|
|
12
|
+
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
export declare const Container: (props: ContainerProps) => JSX.Element;
|
|
1
|
+
import type { ContainerProps } from "./Container.types";
|
|
2
|
+
export declare const Container: (props: ContainerProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
export const Container = (props) => {
|
|
3
|
-
const { size, children } = props;
|
|
4
|
-
const classes = [
|
|
5
|
-
|
|
3
|
+
const { size, children, style, padding, margin, stretch } = props;
|
|
4
|
+
const classes = [
|
|
5
|
+
"ga-ds-container",
|
|
6
|
+
`ga-ds-container--${size}`,
|
|
7
|
+
...(padding ? [`ga-ds-util-padding--${padding}`] : []),
|
|
8
|
+
...(margin ? [`ga-ds-util-margin--${margin}`] : []),
|
|
9
|
+
...(stretch ? [`ga-ds-container-stretch--${stretch}`] : []),
|
|
10
|
+
...(props.extraClassNames || []),
|
|
11
|
+
];
|
|
12
|
+
return (_jsx("div", { className: classes.join(" "), style: style, children: children }));
|
|
6
13
|
};
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { WordpressDefault } from "../../global.types";
|
|
2
|
-
export type ContainerSize = 'large' | 'medium' | 'small';
|
|
2
|
+
export type ContainerSize = 'large' | 'medium' | 'small' | 'full';
|
|
3
|
+
export type ContainerStretch = 'right' | 'left';
|
|
3
4
|
export interface ContainerProps extends WordpressDefault {
|
|
4
5
|
size: ContainerSize;
|
|
6
|
+
stretch?: ContainerStretch;
|
|
5
7
|
children: React.ReactNode | React.ReactNode[];
|
|
8
|
+
style?: React.CSSProperties;
|
|
6
9
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
export const FlexBlock = ({ children, gap, alignItems, justifyContent, flexDirection, extraClassNames }) => {
|
|
3
|
+
const styles = [];
|
|
4
|
+
if (gap) {
|
|
5
|
+
styles.push(["gap", `var(--ga-spacings-gap-${gap})`]);
|
|
6
|
+
}
|
|
7
|
+
if (alignItems) {
|
|
8
|
+
styles.push(["alignItems", alignItems]);
|
|
9
|
+
}
|
|
10
|
+
if (justifyContent) {
|
|
11
|
+
styles.push(["justifyContent", justifyContent]);
|
|
12
|
+
}
|
|
13
|
+
if (flexDirection) {
|
|
14
|
+
styles.push(["flexDirection", flexDirection]);
|
|
15
|
+
}
|
|
16
|
+
const classNames = ["ga-ds-flex-block"];
|
|
17
|
+
if (extraClassNames) {
|
|
18
|
+
classNames.push(...extraClassNames);
|
|
19
|
+
}
|
|
20
|
+
return (_jsx("div", { className: classNames.join(" "), style: Object.fromEntries(styles), children: children }));
|
|
21
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { WordpressDefault } from "../../global.types";
|
|
2
|
+
export type FlexBlockAttrs = {
|
|
3
|
+
gap?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
4
|
+
alignItems?: string;
|
|
5
|
+
justifyContent?: string;
|
|
6
|
+
flexDirection?: 'column';
|
|
7
|
+
};
|
|
8
|
+
export interface FlexBlockProps extends FlexBlockAttrs, WordpressDefault {
|
|
9
|
+
children: React.ReactNode;
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/layout/Grid/Grid.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
export const Grid = (props) => {
|
|
3
|
-
const { children, alignItems, justifyContent, extraClassNames } = props;
|
|
4
|
-
const classNames = [
|
|
5
|
-
return _jsx("div", { className: classNames.join(
|
|
3
|
+
const { children, alignItems, justifyContent, extraClassNames, padding } = props;
|
|
4
|
+
const classNames = ["ga-ds-grid", ...(padding ? [`ga-ds-util-padding--${padding}`] : []), ...(extraClassNames || [])];
|
|
5
|
+
return (_jsx("div", { className: classNames.join(" "), style: { ...(alignItems !== "none" && { alignItems }), ...(justifyContent !== "none" && { justifyContent }) }, children: children }));
|
|
6
6
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { WordpressDefault } from "../../global.types";
|
|
2
|
-
export interface
|
|
3
|
-
alignItems: 'flex-start' | 'center' | 'flex-end' | '
|
|
4
|
-
justifyContent: 'flex-start' | 'center' | 'flex-end' | 'space-between' | 'space-around';
|
|
2
|
+
export interface GridAttributes {
|
|
3
|
+
alignItems: 'flex-start' | 'center' | 'flex-end' | 'none';
|
|
4
|
+
justifyContent: 'flex-start' | 'center' | 'flex-end' | 'space-between' | 'space-around' | 'none';
|
|
5
5
|
}
|
|
6
|
-
export interface GridProps extends WordpressDefault,
|
|
6
|
+
export interface GridProps extends WordpressDefault, GridAttributes {
|
|
7
7
|
children: React.ReactNode | React.ReactNode[];
|
|
8
8
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { JSX } from
|
|
2
|
-
import { GridItemProps } from
|
|
1
|
+
import type { JSX } from "react/jsx-runtime";
|
|
2
|
+
import { GridItemProps } from "./GridItem.types";
|
|
3
3
|
export declare const GridItem: (props: GridItemProps) => JSX.Element;
|
|
@@ -5,7 +5,14 @@ export const GridItem = (props) => {
|
|
|
5
5
|
sm: 12,
|
|
6
6
|
md: 12,
|
|
7
7
|
lg: 12,
|
|
8
|
-
} } = props;
|
|
9
|
-
const style =
|
|
10
|
-
|
|
8
|
+
}, style: givenStyle, extraClassNames, } = props;
|
|
9
|
+
const style = {
|
|
10
|
+
...Object.fromEntries(Object.entries(sizes).map(([key, value]) => [`--ga-ds-grid-item-size-${key}`, `${value}`])),
|
|
11
|
+
...givenStyle,
|
|
12
|
+
};
|
|
13
|
+
const classNames = ["ga-ds-grid-item"];
|
|
14
|
+
if (extraClassNames) {
|
|
15
|
+
classNames.push(...extraClassNames);
|
|
16
|
+
}
|
|
17
|
+
return (_jsx("div", { className: classNames.join(" "), style: style, children: children }));
|
|
11
18
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { WordpressDefault } from "../../../global.types";
|
|
2
2
|
export type ColumnSize = '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | '10' | '11' | '12';
|
|
3
|
-
export interface
|
|
3
|
+
export interface GridItemAttributes {
|
|
4
4
|
sizes: {
|
|
5
5
|
xs: ColumnSize;
|
|
6
6
|
sm: ColumnSize;
|
|
@@ -8,6 +8,7 @@ export interface Attributes {
|
|
|
8
8
|
lg: ColumnSize;
|
|
9
9
|
};
|
|
10
10
|
}
|
|
11
|
-
export interface GridItemProps extends WordpressDefault,
|
|
11
|
+
export interface GridItemProps extends WordpressDefault, GridItemAttributes {
|
|
12
12
|
children: React.ReactNode | React.ReactNode[];
|
|
13
|
+
style?: React.CSSProperties;
|
|
13
14
|
}
|
package/dist/layout/layout.d.ts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
1
|
export * from './Container/Container';
|
|
2
|
+
export * from './Container/Container.types';
|
|
2
3
|
export * from './Grid/Grid';
|
|
4
|
+
export * from './Grid/Grid.types';
|
|
3
5
|
export * from './Grid/GridItem/GridItem';
|
|
6
|
+
export * from './Grid/GridItem/GridItem.types';
|
|
7
|
+
export * from './FlexCol/FlexCol';
|
|
8
|
+
export * from './FlexCol/FlexCol.types';
|
|
9
|
+
export * from './FlexBlock/FlexBlock';
|
|
10
|
+
export * from './FlexBlock/FlexBlock.types';
|
package/dist/layout/layout.js
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
1
|
export * from './Container/Container';
|
|
2
|
+
export * from './Container/Container.types';
|
|
2
3
|
export * from './Grid/Grid';
|
|
4
|
+
export * from './Grid/Grid.types';
|
|
3
5
|
export * from './Grid/GridItem/GridItem';
|
|
6
|
+
export * from './Grid/GridItem/GridItem.types';
|
|
7
|
+
export * from './FlexCol/FlexCol';
|
|
8
|
+
export * from './FlexCol/FlexCol.types';
|
|
9
|
+
export * from './FlexBlock/FlexBlock';
|
|
10
|
+
export * from './FlexBlock/FlexBlock.types';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
export const ButtonGroup = ({ alignment, children, extraClassNames }) => {
|
|
3
|
+
const style = {};
|
|
4
|
+
const cssAlignmentsMap = {
|
|
5
|
+
center: "center",
|
|
6
|
+
right: "flex-end",
|
|
7
|
+
};
|
|
8
|
+
if (alignment && cssAlignmentsMap[alignment]) {
|
|
9
|
+
style["--alignment"] = cssAlignmentsMap[alignment];
|
|
10
|
+
}
|
|
11
|
+
const classes = ["ga-ds-btn-group"];
|
|
12
|
+
if (extraClassNames) {
|
|
13
|
+
classes.push(...extraClassNames);
|
|
14
|
+
}
|
|
15
|
+
return (_jsx("div", { className: classes.join(" "), ...(Object.entries(style).length ? { style } : {}), children: children }));
|
|
16
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Icon } from "../../atoms/Icon/Icon";
|
|
3
|
+
import { useSpoilerContext } from "../../context/SpoilerContext";
|
|
4
|
+
export const Spoiler = (props) => {
|
|
5
|
+
const { summary, children, defaultOpen = false, index } = props;
|
|
6
|
+
const { activeIndex, setActiveIndex } = useSpoilerContext();
|
|
7
|
+
const isOpen = activeIndex === index ? true : defaultOpen;
|
|
8
|
+
const handleToggle = (e) => {
|
|
9
|
+
e.preventDefault();
|
|
10
|
+
setActiveIndex(index);
|
|
11
|
+
};
|
|
12
|
+
return (_jsxs("div", { className: `ga-ds-spoiler ${isOpen ? "is-open" : ""}`, children: [_jsx("div", { className: "ga-ds-spoiler__separator" }), _jsxs("div", { className: "ga-ds-spoiler__summary", onClick: handleToggle, role: "button", tabIndex: 0, children: [summary, _jsx("span", { className: "ga-ds-spoiler__indicator", children: _jsx(Icon, { name: "chevron-right", size: "sm" }) })] }), _jsx("div", { className: "ga-ds-spoiler__content", children: _jsx("div", { className: "ga-ds-spoiler__body", children: children }) })] }));
|
|
13
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
2
|
+
import { Spoiler } from "./Spoiler";
|
|
3
|
+
declare const meta: Meta<typeof Spoiler>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof Spoiler>;
|
|
6
|
+
export declare const Default: Story;
|
|
7
|
+
export declare const OpenByDefault: Story;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Spoiler } from "./Spoiler";
|
|
3
|
+
import { SpoilerProvider } from "../../context/SpoilerContext";
|
|
4
|
+
const meta = {
|
|
5
|
+
title: "Molecules/Spoiler",
|
|
6
|
+
component: Spoiler,
|
|
7
|
+
tags: ["autodocs"],
|
|
8
|
+
decorators: [
|
|
9
|
+
(Story) => (_jsx(SpoilerProvider, { children: _jsx(Story, {}) })),
|
|
10
|
+
],
|
|
11
|
+
};
|
|
12
|
+
export default meta;
|
|
13
|
+
export const Default = {
|
|
14
|
+
args: {
|
|
15
|
+
summary: "Click to reveal the spoiler content",
|
|
16
|
+
children: (_jsxs(_Fragment, { children: [_jsx("p", { children: "This is the hidden spoiler content." }), _jsx("p", { children: "It can include any React nodes." })] })),
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
export const OpenByDefault = {
|
|
20
|
+
args: {
|
|
21
|
+
summary: "This spoiler is open by default",
|
|
22
|
+
children: (_jsxs(_Fragment, { children: [_jsx("p", { children: "The spoiler content is visible on load." }), _jsx("p", { children: "You can still toggle it closed." })] })),
|
|
23
|
+
defaultOpen: true,
|
|
24
|
+
},
|
|
25
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { JSX } from
|
|
2
|
-
import type { CardProps } from
|
|
3
|
-
export declare const Card: ({ children, variant, extraClassNames, type }: CardProps) => JSX.Element;
|
|
1
|
+
import { JSX } from "react/jsx-runtime";
|
|
2
|
+
import type { CardProps } from "./Card.types";
|
|
3
|
+
export declare const Card: ({ children, variant, extraClassNames, type, style, backgroundImage, }: CardProps) => JSX.Element;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
export const Card = ({ children, variant =
|
|
3
|
-
const classNames = [
|
|
4
|
-
return
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
export const Card = ({ children, variant = "primary", extraClassNames, type = "image", style, backgroundImage, }) => {
|
|
3
|
+
const classNames = ["ga-ds-card", `ga-ds-card--${variant}`, `ga-ds-card--${type}`, ...(extraClassNames || [])];
|
|
4
|
+
return (_jsxs("div", { ...(style && { style }), className: classNames.join(" "), children: [backgroundImage && _jsx("img", { src: backgroundImage.sizes?.full?.url, alt: backgroundImage?.alt }), children] }));
|
|
5
5
|
};
|