@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.
Files changed (132) hide show
  1. package/dist/atoms/Button/Button.d.ts +3 -3
  2. package/dist/atoms/Button/Button.js +8 -8
  3. package/dist/atoms/Button/Button.stories.d.ts +2 -2
  4. package/dist/atoms/Button/Button.stories.js +15 -15
  5. package/dist/atoms/Button/Button.types.d.ts +2 -2
  6. package/dist/atoms/Icon/Icon.d.ts +1 -1
  7. package/dist/atoms/Icon/Icon.js +3 -3
  8. package/dist/atoms/Icon/Icon.types.d.ts +2 -1
  9. package/dist/atoms/Text/Text.d.ts +1 -0
  10. package/dist/atoms/Text/Text.js +4 -3
  11. package/dist/atoms/Text/Text.types.d.ts +5 -1
  12. package/dist/atoms/atoms.d.ts +3 -0
  13. package/dist/atoms/atoms.js +3 -0
  14. package/dist/context/SpoilerContext.d.ts +9 -0
  15. package/dist/context/SpoilerContext.js +15 -0
  16. package/dist/global.types.d.ts +4 -0
  17. package/dist/hooks/useReactAdaptater.d.ts +10 -2
  18. package/dist/hooks/useReactAdaptater.js +6 -3
  19. package/dist/hooks/useSpoilerContext.d.ts +4 -0
  20. package/dist/hooks/useSpoilerContext.js +12 -0
  21. package/dist/index.d.ts +1 -0
  22. package/dist/index.js +1 -0
  23. package/dist/layout/Container/Container.d.ts +2 -3
  24. package/dist/layout/Container/Container.js +10 -3
  25. package/dist/layout/Container/Container.types.d.ts +4 -1
  26. package/dist/layout/FlexBlock/FlexBlock.d.ts +2 -0
  27. package/dist/layout/FlexBlock/FlexBlock.js +21 -0
  28. package/dist/layout/FlexBlock/FlexBlock.types.d.ts +10 -0
  29. package/dist/layout/FlexBlock/FlexBlock.types.js +1 -0
  30. package/dist/layout/FlexCol/FlexCol.d.ts +5 -0
  31. package/dist/layout/FlexCol/FlexCol.js +4 -0
  32. package/dist/layout/FlexCol/FlexCol.types.d.ts +3 -0
  33. package/dist/layout/FlexCol/FlexCol.types.js +1 -0
  34. package/dist/layout/Grid/Grid.d.ts +1 -2
  35. package/dist/layout/Grid/Grid.js +3 -3
  36. package/dist/layout/Grid/Grid.types.d.ts +4 -4
  37. package/dist/layout/Grid/GridItem/GridItem.d.ts +2 -2
  38. package/dist/layout/Grid/GridItem/GridItem.js +10 -3
  39. package/dist/layout/Grid/GridItem/GridItem.types.d.ts +3 -2
  40. package/dist/layout/layout.d.ts +7 -0
  41. package/dist/layout/layout.js +7 -0
  42. package/dist/molecules/ButtonGroup/ButtonGroup.d.ts +2 -0
  43. package/dist/molecules/ButtonGroup/ButtonGroup.js +16 -0
  44. package/dist/molecules/ButtonGroup/ButtonGroup.types.d.ts +5 -0
  45. package/dist/molecules/ButtonGroup/ButtonGroup.types.js +1 -0
  46. package/dist/molecules/Spoiler/Spoiler.d.ts +2 -0
  47. package/dist/molecules/Spoiler/Spoiler.js +13 -0
  48. package/dist/molecules/Spoiler/Spoiler.stories.d.ts +7 -0
  49. package/dist/molecules/Spoiler/Spoiler.stories.js +25 -0
  50. package/dist/molecules/Spoiler/Spoiler.types.d.ts +6 -0
  51. package/dist/molecules/Spoiler/Spoiler.types.js +1 -0
  52. package/dist/molecules/molecules.d.ts +2 -0
  53. package/dist/molecules/molecules.js +2 -0
  54. package/dist/organisms/Card/Card.d.ts +3 -3
  55. package/dist/organisms/Card/Card.js +4 -4
  56. package/dist/organisms/Card/Card.types.d.ts +12 -3
  57. package/dist/organisms/Card/CardDefault.stories.d.ts +2 -2
  58. package/dist/organisms/Card/CardDefault.stories.js +17 -17
  59. package/dist/organisms/Carousel/Carousel.js +5 -1
  60. package/dist/organisms/Carousel/Carousel.types.d.ts +2 -1
  61. package/dist/organisms/SpoilerList/SpoilerList.d.ts +2 -0
  62. package/dist/organisms/SpoilerList/SpoilerList.js +11 -0
  63. package/dist/organisms/SpoilerList/SpoilerList.types.d.ts +4 -0
  64. package/dist/organisms/SpoilerList/SpoilerList.types.js +1 -0
  65. package/dist/organisms/organisms.d.ts +2 -0
  66. package/dist/organisms/organisms.js +2 -0
  67. package/dist/styles.d.ts +1 -0
  68. package/dist/styles.js +1 -0
  69. package/package.json +10 -9
  70. package/src/atoms/Button/Button.scss +23 -19
  71. package/src/atoms/Button/Button.stories.tsx +17 -17
  72. package/src/atoms/Button/Button.tsx +20 -16
  73. package/src/atoms/Button/Button.types.ts +2 -2
  74. package/src/atoms/Icon/Icon.scss +9 -9
  75. package/src/atoms/Icon/Icon.tsx +10 -8
  76. package/src/atoms/Icon/Icon.types.ts +3 -1
  77. package/src/atoms/Text/Text.scss +33 -2
  78. package/src/atoms/Text/Text.tsx +13 -8
  79. package/src/atoms/Text/Text.types.ts +5 -1
  80. package/src/atoms/atoms.scss +3 -3
  81. package/src/atoms/atoms.ts +3 -0
  82. package/src/context/SpoilerContext.tsx +24 -0
  83. package/src/global.types.ts +4 -0
  84. package/src/hooks/useReactAdaptater.ts +20 -4
  85. package/src/hooks/useSpoilerContext.ts +17 -0
  86. package/src/index.scss +2 -0
  87. package/src/index.ts +1 -0
  88. package/src/layout/Container/Container.scss +58 -13
  89. package/src/layout/Container/Container.tsx +17 -9
  90. package/src/layout/Container/Container.types.ts +4 -2
  91. package/src/layout/FlexBlock/FlexBlock.scss +4 -0
  92. package/src/layout/FlexBlock/FlexBlock.tsx +31 -0
  93. package/src/layout/FlexBlock/FlexBlock.types.ts +12 -0
  94. package/src/layout/FlexCol/FlexCol.scss +5 -0
  95. package/src/layout/FlexCol/FlexCol.tsx +12 -0
  96. package/src/layout/FlexCol/FlexCol.types.ts +3 -0
  97. package/src/layout/Grid/Grid.scss +8 -4
  98. package/src/layout/Grid/Grid.tsx +12 -8
  99. package/src/layout/Grid/Grid.types.ts +4 -4
  100. package/src/layout/Grid/GridItem/GridItem.scss +17 -4
  101. package/src/layout/Grid/GridItem/GridItem.tsx +28 -13
  102. package/src/layout/Grid/GridItem/GridItem.types.ts +3 -2
  103. package/src/layout/layout.scss +5 -3
  104. package/src/layout/layout.ts +8 -1
  105. package/src/molecules/ButtonGroup/ButtonGroup.scss +5 -0
  106. package/src/molecules/ButtonGroup/ButtonGroup.tsx +23 -0
  107. package/src/molecules/ButtonGroup/ButtonGroup.types.ts +6 -0
  108. package/src/molecules/Spoiler/Spoiler.scss +47 -0
  109. package/src/molecules/Spoiler/Spoiler.stories.tsx +44 -0
  110. package/src/molecules/Spoiler/Spoiler.tsx +30 -0
  111. package/src/molecules/Spoiler/Spoiler.types.ts +6 -0
  112. package/src/molecules/molecules.scss +2 -0
  113. package/src/molecules/molecules.ts +2 -0
  114. package/src/organisms/Card/Card.scss +50 -10
  115. package/src/organisms/Card/Card.tsx +17 -6
  116. package/src/organisms/Card/Card.types.ts +12 -3
  117. package/src/organisms/Card/CardDefault.stories.tsx +40 -37
  118. package/src/organisms/Carousel/Carousel.scss +3 -0
  119. package/src/organisms/Carousel/Carousel.tsx +7 -1
  120. package/src/organisms/Carousel/Carousel.types.ts +3 -1
  121. package/src/organisms/SpoilerList/SpoilerList.scss +5 -0
  122. package/src/organisms/SpoilerList/SpoilerList.tsx +19 -0
  123. package/src/organisms/SpoilerList/SpoilerList.types.ts +5 -0
  124. package/src/organisms/organisms.scss +3 -2
  125. package/src/organisms/organisms.ts +3 -1
  126. package/src/scss.d.ts +4 -0
  127. package/src/styles.ts +1 -0
  128. package/src/utils/_spacings.scss +17 -0
  129. package/src/utils/utils.scss +1 -0
  130. package/dist/utils.d.ts +0 -0
  131. package/dist/utils.js +0 -1
  132. package/src/utils.ts +0 -0
@@ -1,4 +1,4 @@
1
- import { JSX } from 'react/jsx-runtime';
2
- import type { ButtonProps } from './Button.types';
3
- import React from 'react';
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 'react';
3
- import { Icon } from '../Icon/Icon';
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 = 'icon';
8
+ customVariant = "icon";
9
9
  }
10
- const classNames = ['ga-ds-btn', `ga-ds-btn--${customVariant}`, ...(extraClassNames || [])];
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 || 'button', {
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: 'sm' }), children && children] }));
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 '@storybook/react-vite';
2
- import { Button } from './Button';
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 './Button';
1
+ import { Button } from "./Button";
2
2
  const meta = {
3
- title: 'Atoms/Button',
3
+ title: "Atoms/Button",
4
4
  component: Button,
5
- tags: ['autodocs'],
5
+ tags: ["autodocs"],
6
6
  };
7
7
  export default meta;
8
8
  export const Primary = {
9
9
  args: {
10
- variant: 'primary',
11
- children: 'Button',
12
- as: 'a',
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: 'secondary',
19
- children: 'Button',
20
- as: 'a',
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: 'link',
27
- children: 'Button',
28
- as: 'a',
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 Variant = "primary" | "secondary" | "tertiary" | "link" | "icon";
3
+ export type ButtonVariant = "primary" | "secondary" | "tertiary" | "link" | "icon";
4
4
  export type ButtonProps<T extends ElementType = "button"> = {
5
5
  as?: T;
6
- variant?: 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;
@@ -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 classeNames = ['ga-ds-icon', ...(size ? [`ga-ds-icon--${size}`] : [])];
6
- return _jsx("svg", { className: classeNames.join(' '), xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: _jsx("use", { xlinkHref: `${iconsSprite}#${name}` }) });
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
  };
@@ -1,4 +1,5 @@
1
- export interface IconProps {
1
+ import { WordpressDefault } from "../../global.types";
2
+ export interface IconProps extends WordpressDefault {
2
3
  name: string;
3
4
  size?: 'sm' | 'md' | 'lg';
4
5
  spriteFile?: string;
@@ -2,4 +2,5 @@ import React from "react";
2
2
  import { TextProps } from "./Text.types";
3
3
  export declare const Text: (props: TextProps) => React.DetailedReactHTMLElement<{
4
4
  className: string;
5
+ style: React.CSSProperties | undefined;
5
6
  }, HTMLElement>;
@@ -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 === 'string' ? classNames : classNames?.join(' ') || '';
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 TextProps {
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
  }
@@ -1 +1,4 @@
1
1
  export * from './Button/Button';
2
+ export * from './Button/Button.types';
3
+ export * from './Icon/Icon';
4
+ export * from './Icon/Icon.types';
@@ -1 +1,4 @@
1
1
  export * from './Button/Button';
2
+ export * from './Button/Button.types';
3
+ export * from './Icon/Icon';
4
+ export * from './Icon/Icon.types';
@@ -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
+ };
@@ -1,3 +1,7 @@
1
+ export type Padding = "xsmall" | "small" | "medium" | "large" | "xlarge";
2
+ export type Margin = "small" | "medium" | "large";
1
3
  export interface WordpressDefault {
2
4
  extraClassNames?: string[];
5
+ padding?: Padding;
6
+ margin?: Margin;
3
7
  }
@@ -1,2 +1,10 @@
1
- import React from 'react';
2
- export declare const useReactAdapter: () => typeof React;
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
- if (typeof window === 'undefined' || !window.wp || !window.wp.element) {
4
- return React;
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
- return window.wp.element;
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,4 @@
1
+ export default function (): {
2
+ activeIndex: number | null;
3
+ toggleIndex: (index: number) => void;
4
+ };
@@ -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
@@ -1,4 +1,5 @@
1
1
  export * from './atoms/atoms';
2
2
  export * from './organisms/organisms';
3
+ export * from './molecules/molecules';
3
4
  export * from './layout/layout';
4
5
  export { setThemeAssets } from './hooks/useThemeAssets';
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from './atoms/atoms';
2
2
  export * from './organisms/organisms';
3
+ export * from './molecules/molecules';
3
4
  export * from './layout/layout';
4
5
  export { setThemeAssets } from './hooks/useThemeAssets';
@@ -1,3 +1,2 @@
1
- import type { JSX } from 'react/jsx-runtime';
2
- import type { ContainerProps } from './Container.types';
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 = ['ga-ds-container', `ga-ds-container--${size}`, ...(props.extraClassNames || [])];
5
- return _jsx("div", { className: classes.join(' '), children: children });
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,2 @@
1
+ import { FlexBlockProps } from "./FlexBlock.types";
2
+ export declare const FlexBlock: ({ children, gap, alignItems, justifyContent, flexDirection, extraClassNames }: FlexBlockProps) => import("react/jsx-runtime").JSX.Element;
@@ -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,5 @@
1
+ import { FlexColAttrs } from "./FlexCol.types";
2
+ export declare const FlexCol: ({ children, gap }: {
3
+ children: React.ReactNode;
4
+ gap?: FlexColAttrs["gap"];
5
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,4 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ export const FlexCol = ({ children, gap }) => {
3
+ return (_jsx("div", { className: "ga-ds-flex-col", style: { "--ga-flex-col-gap": `var(--ga-spacings-gap-${gap || "xs"})` }, children: children }));
4
+ };
@@ -0,0 +1,3 @@
1
+ export type FlexColAttrs = {
2
+ gap?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
3
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,3 +1,2 @@
1
- import type { JSX } from 'react/jsx-runtime';
2
- import { GridProps } from './Grid.types';
1
+ import { GridProps } from "./Grid.types";
3
2
  export declare const Grid: (props: GridProps) => JSX.Element;
@@ -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 = ['ga-ds-grid', ...(extraClassNames || [])];
5
- return _jsx("div", { className: classNames.join(' '), style: { alignItems, justifyContent }, children: children });
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 Attributes {
3
- alignItems: 'flex-start' | 'center' | 'flex-end' | 'stretch' | 'baseline';
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, Attributes {
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 'react/jsx-runtime';
2
- import { GridItemProps } from './GridItem.types';
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 = Object.fromEntries(Object.entries(sizes).map(([key, value]) => [`--ga-ds-grid-item-size-${key}`, `${value}`]));
10
- return _jsx("div", { className: "ga-ds-grid-item", style: style, children: children });
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 Attributes {
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, Attributes {
11
+ export interface GridItemProps extends WordpressDefault, GridItemAttributes {
12
12
  children: React.ReactNode | React.ReactNode[];
13
+ style?: React.CSSProperties;
13
14
  }
@@ -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';
@@ -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,2 @@
1
+ import { ButtonGroupProps } from "./ButtonGroup.types";
2
+ export declare const ButtonGroup: ({ alignment, children, extraClassNames }: ButtonGroupProps) => import("react/jsx-runtime").JSX.Element;
@@ -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,5 @@
1
+ import { WordpressDefault } from "../../global.types";
2
+ export interface ButtonGroupProps extends WordpressDefault {
3
+ alignment?: 'center' | 'right';
4
+ children?: React.ReactNode;
5
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import { SpoilerProps } from "./Spoiler.types";
2
+ export declare const Spoiler: (props: SpoilerProps) => import("react/jsx-runtime").JSX.Element;
@@ -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,6 @@
1
+ export interface SpoilerProps {
2
+ summary: string;
3
+ children: React.ReactNode | React.ReactNode[];
4
+ defaultOpen?: boolean;
5
+ index: number;
6
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from './ButtonGroup/ButtonGroup';
2
+ export * from './Spoiler/Spoiler';
@@ -0,0 +1,2 @@
1
+ export * from './ButtonGroup/ButtonGroup';
2
+ export * from './Spoiler/Spoiler';
@@ -1,3 +1,3 @@
1
- import { JSX } from 'react/jsx-runtime';
2
- import type { CardProps } from './Card.types';
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 = 'primary', extraClassNames, type = 'default' }) => {
3
- const classNames = ['ga-ds-card', `ga-ds-card--${variant}`, `ga-ds-card--${type}`, ...(extraClassNames || [])];
4
- return _jsx("div", { className: classNames.join(' '), children: children });
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
  };