@growth-angels/ds-core 1.17.1 → 1.19.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.
@@ -1,4 +1,3 @@
1
- import { JSX } from "react/jsx-runtime";
1
+ import type { JSX } from "react/jsx-runtime";
2
2
  import type { ButtonProps } from "./Button.types";
3
- import React from "react";
4
3
  export declare const Button: <T extends React.ElementType = "button">(props: ButtonProps<T>) => JSX.Element;
@@ -1,7 +1,8 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import React from "react";
2
+ import { useReactAdapter } from "../../hooks/useReactAdaptater";
3
3
  import { Icon } from "../Icon/Icon";
4
4
  export const Button = (props) => {
5
+ const React = useReactAdapter();
5
6
  const { as, children, variant, preventDefault, icon, extraClassNames, ...restProps } = props;
6
7
  let customVariant = variant;
7
8
  if (icon) {
@@ -1,5 +1,5 @@
1
1
  import { WordpressDefault } from "../../global.types.js";
2
- import React, { ElementType, ComponentPropsWithoutRef } from "react";
2
+ import type { ElementType, ComponentPropsWithoutRef, ReactNode, MouseEventHandler, ElementRef } from "react";
3
3
  export type ButtonVariant = "primary" | "secondary" | "tertiary" | "link" | "icon";
4
4
  export type ButtonProps<T extends ElementType = "button"> = {
5
5
  as?: T;
@@ -7,7 +7,7 @@ export type ButtonProps<T extends ElementType = "button"> = {
7
7
  hasIcon?: "left" | "right";
8
8
  icon?: string;
9
9
  preventDefault?: boolean;
10
- children?: React.ReactNode;
10
+ children?: ReactNode;
11
11
  } & WordpressDefault & Omit<ComponentPropsWithoutRef<T>, "as" | "className" | "onClick"> & {
12
- onClick?: React.MouseEventHandler<React.ElementRef<T>>;
12
+ onClick?: MouseEventHandler<ElementRef<T>>;
13
13
  };
@@ -1,6 +1,5 @@
1
- import React from "react";
2
1
  import { TextProps } from "./Text.types";
3
- export declare const Text: (props: TextProps) => React.DetailedReactHTMLElement<{
2
+ export declare const Text: (props: TextProps) => import("react").DetailedReactHTMLElement<{
4
3
  className: string;
5
- style: React.CSSProperties | undefined;
4
+ style: import("react").CSSProperties | undefined;
6
5
  }, HTMLElement>;
@@ -1,5 +1,6 @@
1
- import React from "react";
1
+ import { useReactAdapter } from "../../hooks/useReactAdaptater";
2
2
  export const Text = (props) => {
3
+ const React = useReactAdapter();
3
4
  const { as, children, classNames, type = "paragraph", size, style } = props;
4
5
  const className = typeof classNames === "string" ? classNames : classNames?.join(" ") || "";
5
6
  return React.createElement(as, {
@@ -1,4 +1,3 @@
1
- import React from 'react';
2
1
  type ReactType = typeof import('react');
3
2
  type ExtendedReactType = ReactType & {
4
3
  createRoot: (container: Element | DocumentFragment) => {
@@ -1,10 +1,9 @@
1
- import React from 'react';
2
1
  export const useReactAdapter = () => {
3
- // Check if WordPress element is available (WordPress context)
4
- if (typeof window !== 'undefined' && window.wp?.element) {
5
- return window.wp.element;
2
+ if (typeof window === 'undefined') {
3
+ throw new Error('useReactAdapter requires a browser environment with window.wp.element');
6
4
  }
7
- // Fallback for non-WordPress environments (Storybook, tests, SSR)
8
- // This will bundle React only in non-WordPress builds
9
- return React;
5
+ if (!window.wp?.element) {
6
+ throw new Error('window.wp.element is not available. Make sure wp-element is loaded.');
7
+ }
8
+ return window.wp.element;
10
9
  };
@@ -1,11 +1,12 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  export const Container = (props) => {
3
- const { size, children, style, padding, margin, stretch, id } = props;
3
+ const { size, children, style, padding, margin, stretch, id, paddingPosition, marginPosition } = props;
4
+ console.log("Container props", props);
4
5
  const classes = [
5
6
  "ga-ds-container",
6
7
  `ga-ds-container--${size}`,
7
- ...(padding ? [`ga-ds-util-padding--${padding}`] : []),
8
- ...(margin ? [`ga-ds-util-margin--${margin}`] : []),
8
+ ...(padding ? [`ga-ds-util-padding${paddingPosition ? `-${paddingPosition}` : ""}--${padding}`] : []),
9
+ ...(margin ? [`ga-ds-util-margin${marginPosition ? `-${marginPosition}` : ""}--${margin}`] : []),
9
10
  ...(stretch ? [`ga-ds-container-stretch--${stretch}`] : []),
10
11
  ...(props.extraClassNames || []),
11
12
  ];
@@ -6,4 +6,6 @@ export interface ContainerProps extends WordpressDefault, React.HTMLAttributes<H
6
6
  stretch?: ContainerStretch;
7
7
  children: React.ReactNode | React.ReactNode[];
8
8
  style?: React.CSSProperties;
9
+ paddingPosition?: "top" | "bottom";
10
+ marginPosition?: "top" | "bottom";
9
11
  }
@@ -1,10 +1,10 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  export const Grid = (props) => {
3
- const { children, alignItems, justifyContent, extraClassNames, padding, margin } = props;
3
+ const { children, alignItems, justifyContent, extraClassNames, padding, margin, paddingPosition, marginPosition } = props;
4
4
  const classNames = [
5
5
  "ga-ds-grid",
6
- ...(padding ? [`ga-ds-util-padding--${padding}`] : []),
7
- ...(margin ? [`ga-ds-util-margin--${margin}`] : []),
6
+ ...(padding ? [`ga-ds-util-padding${paddingPosition ? `-${paddingPosition}` : ""}--${padding}`] : []),
7
+ ...(margin ? [`ga-ds-util-margin${marginPosition ? `-${marginPosition}` : ""}--${margin}`] : []),
8
8
  ...(extraClassNames || []),
9
9
  ];
10
10
  return (_jsx("div", { className: classNames.join(" "), style: { ...(alignItems !== "none" && { alignItems }), ...(justifyContent !== "none" && { justifyContent }) }, children: children }));
@@ -2,6 +2,8 @@ import { WordpressDefault } from "../../global.types";
2
2
  export interface GridAttributes {
3
3
  alignItems: 'flex-start' | 'center' | 'flex-end' | 'none';
4
4
  justifyContent: 'flex-start' | 'center' | 'flex-end' | 'space-between' | 'space-around' | 'none';
5
+ paddingPosition?: 'top' | 'bottom';
6
+ marginPosition?: 'top' | 'bottom';
5
7
  }
6
8
  export interface GridProps extends WordpressDefault, GridAttributes {
7
9
  children: React.ReactNode | React.ReactNode[];
@@ -1,3 +1,3 @@
1
- import { JSX } from "react/jsx-runtime";
1
+ import type { JSX } from "react/jsx-runtime";
2
2
  import type { CardProps } from "./Card.types";
3
3
  export declare const Card: ({ children, variant, extraClassNames, type, style, backgroundImage, }: CardProps) => JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@growth-angels/ds-core",
3
- "version": "1.17.1",
3
+ "version": "1.19.0",
4
4
  "description": "Design system by Growth Angels",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -1,9 +1,10 @@
1
- import { JSX } from "react/jsx-runtime"
1
+ import type { JSX } from "react/jsx-runtime"
2
2
  import type { ButtonProps } from "./Button.types"
3
- import React from "react"
3
+ import { useReactAdapter } from "../../hooks/useReactAdaptater"
4
4
  import { Icon } from "../Icon/Icon"
5
5
 
6
6
  export const Button = <T extends React.ElementType = "button">(props: ButtonProps<T>): JSX.Element => {
7
+ const React = useReactAdapter()
7
8
  const { as, children, variant, preventDefault, icon, extraClassNames, ...restProps } = props
8
9
  let customVariant = variant
9
10
  if (icon) {
@@ -1,5 +1,5 @@
1
1
  import { WordpressDefault } from "../../global.types.js"
2
- import React, { ElementType, ComponentPropsWithoutRef } from "react"
2
+ import type { ElementType, ComponentPropsWithoutRef, ReactNode, MouseEventHandler, ElementRef } from "react"
3
3
 
4
4
  export type ButtonVariant = "primary" | "secondary" | "tertiary" | "link" | "icon"
5
5
 
@@ -9,8 +9,8 @@ export type ButtonProps<T extends ElementType = "button"> = {
9
9
  hasIcon?: "left" | "right"
10
10
  icon?: string
11
11
  preventDefault?: boolean
12
- children?: React.ReactNode
12
+ children?: ReactNode
13
13
  } & WordpressDefault &
14
14
  Omit<ComponentPropsWithoutRef<T>, "as" | "className" | "onClick"> & {
15
- onClick?: React.MouseEventHandler<React.ElementRef<T>>
15
+ onClick?: MouseEventHandler<ElementRef<T>>
16
16
  }
@@ -1,7 +1,8 @@
1
- import React from "react"
1
+ import { useReactAdapter } from "../../hooks/useReactAdaptater"
2
2
  import { TextProps } from "./Text.types"
3
3
 
4
4
  export const Text = (props: TextProps) => {
5
+ const React = useReactAdapter()
5
6
  const { as, children, classNames, type = "paragraph", size, style } = props
6
7
 
7
8
  const className = typeof classNames === "string" ? classNames : classNames?.join(" ") || ""
@@ -1,4 +1,3 @@
1
- import React from 'react'
2
1
  // @ts-ignore - React types from window.wp.element
3
2
  type ReactType = typeof import('react')
4
3
 
@@ -21,13 +20,14 @@ declare global {
21
20
  }
22
21
 
23
22
  export const useReactAdapter = (): ExtendedReactType => {
24
- // Check if WordPress element is available (WordPress context)
25
- if (typeof window !== 'undefined' && window.wp?.element) {
26
- return window.wp.element
23
+ if (typeof window === 'undefined') {
24
+ throw new Error('useReactAdapter requires a browser environment with window.wp.element')
27
25
  }
28
26
 
29
- // Fallback for non-WordPress environments (Storybook, tests, SSR)
30
- // This will bundle React only in non-WordPress builds
31
- return React as ExtendedReactType
27
+ if (!window.wp?.element) {
28
+ throw new Error('window.wp.element is not available. Make sure wp-element is loaded.')
29
+ }
30
+
31
+ return window.wp.element
32
32
  }
33
33
 
@@ -1,12 +1,13 @@
1
1
  import type { ContainerProps } from "./Container.types"
2
2
 
3
3
  export const Container = (props: ContainerProps) => {
4
- const { size, children, style, padding, margin, stretch, id } = props
4
+ const { size, children, style, padding, margin, stretch, id, paddingPosition, marginPosition } = props
5
+ console.log("Container props", props)
5
6
  const classes = [
6
7
  "ga-ds-container",
7
8
  `ga-ds-container--${size}`,
8
- ...(padding ? [`ga-ds-util-padding--${padding}`] : []),
9
- ...(margin ? [`ga-ds-util-margin--${margin}`] : []),
9
+ ...(padding ? [`ga-ds-util-padding${paddingPosition ? `-${paddingPosition}` : ""}--${padding}`] : []),
10
+ ...(margin ? [`ga-ds-util-margin${marginPosition ? `-${marginPosition}` : ""}--${margin}`] : []),
10
11
  ...(stretch ? [`ga-ds-container-stretch--${stretch}`] : []),
11
12
  ...(props.extraClassNames || []),
12
13
  ]
@@ -8,4 +8,6 @@ export interface ContainerProps extends WordpressDefault, React.HTMLAttributes<H
8
8
  stretch?:ContainerStretch
9
9
  children: React.ReactNode | React.ReactNode[];
10
10
  style?: React.CSSProperties;
11
+ paddingPosition?: "top" | "bottom";
12
+ marginPosition?: "top" | "bottom";
11
13
  }
@@ -1,10 +1,10 @@
1
1
  import { GridProps } from "./Grid.types"
2
2
  export const Grid = (props: GridProps): JSX.Element => {
3
- const { children, alignItems, justifyContent, extraClassNames, padding, margin } = props
3
+ const { children, alignItems, justifyContent, extraClassNames, padding, margin, paddingPosition, marginPosition } = props
4
4
  const classNames = [
5
5
  "ga-ds-grid",
6
- ...(padding ? [`ga-ds-util-padding--${padding}`] : []),
7
- ...(margin ? [`ga-ds-util-margin--${margin}`] : []),
6
+ ...(padding ? [`ga-ds-util-padding${paddingPosition ? `-${paddingPosition}` : ""}--${padding}`] : []),
7
+ ...(margin ? [`ga-ds-util-margin${marginPosition ? `-${marginPosition}` : ""}--${margin}`] : []),
8
8
  ...(extraClassNames || []),
9
9
  ]
10
10
 
@@ -3,6 +3,8 @@ import { WordpressDefault } from "../../global.types";
3
3
  export interface GridAttributes {
4
4
  alignItems: 'flex-start' | 'center' | 'flex-end' | 'none'
5
5
  justifyContent: 'flex-start' | 'center' | 'flex-end' | 'space-between' | 'space-around' | 'none'
6
+ paddingPosition?: 'top' | 'bottom'
7
+ marginPosition?: 'top' | 'bottom'
6
8
  }
7
9
 
8
10
  export interface GridProps extends WordpressDefault, GridAttributes {
@@ -1,4 +1,4 @@
1
- import { JSX } from "react/jsx-runtime"
1
+ import type { JSX } from "react/jsx-runtime"
2
2
  import type { CardProps } from "./Card.types"
3
3
 
4
4
  export const Card = ({
@@ -11,7 +11,7 @@
11
11
  &__track {
12
12
  --ga-ds-slides-per-view: 1;
13
13
  display: grid;
14
- grid-auto-flow: column; // place les slides horizontalement
14
+ grid-auto-flow: column;
15
15
  grid-auto-columns: calc(
16
16
  (100% - (var(--ga-ds-space-between, 1rem) * (var(--ga-ds-slides-per-view, 3) - 1))) / var(--ga-ds-slides-per-view, 3)
17
17
  );
@@ -72,13 +72,14 @@
72
72
  }
73
73
 
74
74
  &__dots {
75
+ --dot-size: 1rem;
75
76
  display: flex;
76
77
  gap: var(--ga-ds-gap, 1rem);
77
78
 
78
79
  .ga-ds-carousel__dot {
79
80
  display: block;
80
- width: 1rem;
81
- height: 1rem;
81
+ width: var(--dot-size);
82
+ height: var(--dot-size);
82
83
  border-radius: 50%;
83
84
  background-color: #e2e2e2;
84
85
 
@@ -5,6 +5,14 @@ $spacingsMap: ("xsmall", "small", "medium", "large", "xlarge");
5
5
  padding-top: var(--ga-spacings-padding-#{$value});
6
6
  padding-bottom: var(--ga-spacings-padding-#{$value});
7
7
  }
8
+
9
+ .ga-ds-util-padding-top--#{$value} {
10
+ padding-top: var(--ga-spacings-padding-#{$value});
11
+ }
12
+
13
+ .ga-ds-util-padding-bottom--#{$value} {
14
+ padding-bottom: var(--ga-spacings-padding-#{$value});
15
+ }
8
16
  }
9
17
 
10
18
  $marginsMap: ("small", "medium", "large");
@@ -14,4 +22,10 @@ $marginsMap: ("small", "medium", "large");
14
22
  margin-top: var(--ga-spacings-margin-#{$value});
15
23
  margin-bottom: var(--ga-spacings-margin-#{$value});
16
24
  }
25
+ .ga-ds-util-margin-top--#{$value} {
26
+ margin-top: var(--ga-spacings-margin-#{$value});
27
+ }
28
+ .ga-ds-util-margin-bottom--#{$value} {
29
+ margin-bottom: var(--ga-spacings-margin-#{$value});
30
+ }
17
31
  }