@wordpress/ui 0.3.1-next.6deb34194.0 → 1.0.1-next.738bb1424.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/build/badge/badge.cjs +95 -0
- package/build/badge/badge.cjs.map +7 -0
- package/build/{lock-unlock.js → badge/index.cjs} +8 -14
- package/build/badge/index.cjs.map +7 -0
- package/build/badge/types.cjs +19 -0
- package/build/badge/types.cjs.map +7 -0
- package/build/box/{box.js → box.cjs} +3 -3
- package/build/box/box.cjs.map +7 -0
- package/build/box/{index.js → index.cjs} +2 -2
- package/build/box/{types.js → types.cjs} +1 -1
- package/build/box/types.cjs.map +7 -0
- package/build/{index.js → index.cjs} +7 -3
- package/build/index.cjs.map +7 -0
- package/build/stack/{index.js → index.cjs} +2 -2
- package/build/stack/index.cjs.map +7 -0
- package/build/stack/{stack.js → stack.cjs} +7 -26
- package/build/stack/stack.cjs.map +7 -0
- package/build/stack/{types.js → types.cjs} +1 -1
- package/build/stack/types.cjs.map +7 -0
- package/build/types/css-modules.d.cjs +2 -0
- package/build/types/css-modules.d.cjs.map +7 -0
- package/build/types/{react.d.js → react.d.cjs} +1 -1
- package/build/utils/{element.js → element.cjs} +1 -1
- package/build/utils/{types.js → types.cjs} +1 -1
- package/build-module/badge/badge.js +70 -0
- package/build-module/badge/badge.js.map +7 -0
- package/build-module/badge/index.js +6 -0
- package/build-module/badge/index.js.map +7 -0
- package/build-module/badge/types.js +1 -0
- package/build-module/box/box.js +2 -2
- package/build-module/box/box.js.map +2 -2
- package/build-module/box/index.js +1 -1
- package/build-module/index.js +3 -1
- package/build-module/index.js.map +2 -2
- package/build-module/stack/index.js +1 -1
- package/build-module/stack/index.js.map +2 -2
- package/build-module/stack/stack.js +4 -22
- package/build-module/stack/stack.js.map +2 -2
- package/build-types/badge/badge.d.ts +7 -0
- package/build-types/badge/badge.d.ts.map +1 -0
- package/build-types/badge/index.d.ts +2 -0
- package/build-types/badge/index.d.ts.map +1 -0
- package/build-types/badge/stories/index.story.d.ts +22 -0
- package/build-types/badge/stories/index.story.d.ts.map +1 -0
- package/build-types/badge/types.d.ts +17 -0
- package/build-types/badge/types.d.ts.map +1 -0
- package/build-types/box/box.d.ts.map +1 -1
- package/build-types/box/stories/index.story.d.ts +0 -9
- package/build-types/box/stories/index.story.d.ts.map +1 -1
- package/build-types/box/types.d.ts +8 -15
- package/build-types/box/types.d.ts.map +1 -1
- package/build-types/index.d.ts +2 -0
- package/build-types/index.d.ts.map +1 -1
- package/build-types/stack/index.d.ts +0 -3
- package/build-types/stack/index.d.ts.map +1 -1
- package/build-types/stack/stack.d.ts +1 -10
- package/build-types/stack/stack.d.ts.map +1 -1
- package/build-types/stack/stories/index.story.d.ts.map +1 -1
- package/build-types/stack/types.d.ts +4 -8
- package/build-types/stack/types.d.ts.map +1 -1
- package/build-types/test/index.test.d.ts +2 -0
- package/build-types/test/index.test.d.ts.map +1 -0
- package/package.json +14 -7
- package/src/badge/badge.tsx +98 -0
- package/src/badge/index.ts +1 -0
- package/src/badge/stories/choosing-intent.mdx +112 -0
- package/src/badge/stories/index.story.tsx +134 -0
- package/src/badge/types.ts +25 -0
- package/src/box/box.tsx +5 -7
- package/src/box/stories/index.story.tsx +2 -12
- package/src/box/types.ts +16 -59
- package/src/index.ts +2 -0
- package/src/stack/index.ts +0 -3
- package/src/stack/stack.tsx +3 -37
- package/src/stack/stories/index.story.tsx +1 -13
- package/src/stack/test/stack.test.tsx +1 -21
- package/src/stack/types.ts +4 -9
- package/src/test/index.test.ts +22 -0
- package/build/box/box.js.map +0 -7
- package/build/box/types.js.map +0 -7
- package/build/index.js.map +0 -7
- package/build/lock-unlock.js.map +0 -7
- package/build/stack/index.js.map +0 -7
- package/build/stack/stack.js.map +0 -7
- package/build/stack/types.js.map +0 -7
- package/build/types/css-modules.d.js +0 -2
- package/build-module/lock-unlock.js +0 -11
- package/build-module/lock-unlock.js.map +0 -7
- package/build-types/lock-unlock.d.ts +0 -2
- package/build-types/lock-unlock.d.ts.map +0 -1
- package/src/lock-unlock.ts +0 -10
- package/tsconfig.json +0 -13
- package/tsconfig.tsbuildinfo +0 -1
- /package/build/box/{index.js.map → index.cjs.map} +0 -0
- /package/build/types/{react.d.js.map → react.d.cjs.map} +0 -0
- /package/build/utils/{element.js.map → element.cjs.map} +0 -0
- /package/build/utils/{types.js.map → types.cjs.map} +0 -0
- /package/{build/types/css-modules.d.js.map → build-module/badge/types.js.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/stack/index.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["export { Stack } from './stack';\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,aAAa;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// packages/ui/src/stack/stack.tsx
|
|
2
2
|
import clsx from "clsx";
|
|
3
3
|
import { forwardRef } from "@wordpress/element";
|
|
4
|
-
import { renderElement } from "../utils/element";
|
|
4
|
+
import { renderElement } from "../utils/element.js";
|
|
5
5
|
|
|
6
6
|
// packages/ui/src/stack/style.module.css
|
|
7
7
|
var css = `@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;
|
|
@@ -18,27 +18,10 @@ var style_default = {
|
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
// packages/ui/src/stack/stack.tsx
|
|
21
|
-
var
|
|
22
|
-
"2xs",
|
|
23
|
-
"xs",
|
|
24
|
-
"sm",
|
|
25
|
-
"md",
|
|
26
|
-
"lg",
|
|
27
|
-
"xl"
|
|
28
|
-
]);
|
|
29
|
-
function getNormalizedGap(gap) {
|
|
30
|
-
if (typeof gap === "number") {
|
|
31
|
-
return `calc( ${gap} * var( --wpds-dimension-base ) )`;
|
|
32
|
-
}
|
|
33
|
-
if (TOKEN_NAMES.has(gap)) {
|
|
34
|
-
return `var(--wpds-dimension-gap-${gap})`;
|
|
35
|
-
}
|
|
36
|
-
return String(gap);
|
|
37
|
-
}
|
|
38
|
-
var Stack = forwardRef(function Stack2({ direction, gap = 0, align, justify, wrap, render, ...props }, ref) {
|
|
21
|
+
var Stack = forwardRef(function Stack2({ direction, gap, align, justify, wrap, render, ...props }, ref) {
|
|
39
22
|
const className = clsx(props.className, style_default.stack);
|
|
40
23
|
const style = {
|
|
41
|
-
gap:
|
|
24
|
+
gap: gap && `var(--wpds-dimension-gap-${gap})`,
|
|
42
25
|
alignItems: align,
|
|
43
26
|
justifyContent: justify,
|
|
44
27
|
flexDirection: direction,
|
|
@@ -52,7 +35,6 @@ var Stack = forwardRef(function Stack2({ direction, gap = 0, align, justify, wra
|
|
|
52
35
|
});
|
|
53
36
|
});
|
|
54
37
|
export {
|
|
55
|
-
Stack
|
|
56
|
-
getNormalizedGap
|
|
38
|
+
Stack
|
|
57
39
|
};
|
|
58
40
|
//# sourceMappingURL=stack.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/stack/stack.tsx", "../../src/stack/style.module.css"],
|
|
4
|
-
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { renderElement } from '../utils/element';\nimport { type StackProps
|
|
5
|
-
"mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,kBAAkB;AAK3B,SAAS,qBAAqB;;;ACb9B,IAAM,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQZ,SAAS,KACJ,YAAY,SAAS,cAAc,OAAO,CAAC,EAC3C,YAAY,SAAS,eAAe,GAAG,CAAC;AAE7C,IAAO,gBAAQ;AAAA,EACb,SAAS;AACX;;;
|
|
4
|
+
"sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { renderElement } from '../utils/element';\nimport { type StackProps } from './types';\nimport styles from './style.module.css';\n\n/**\n * A flexible layout component using CSS Flexbox for consistent spacing and alignment.\n * Built on design tokens for predictable spacing values.\n */\nexport const Stack = forwardRef< HTMLDivElement, StackProps >( function Stack(\n\t{ direction, gap, align, justify, wrap, render, ...props },\n\tref\n) {\n\tconst className = clsx( props.className, styles.stack );\n\n\tconst style: React.CSSProperties = {\n\t\tgap: gap && `var(--wpds-dimension-gap-${ gap })`,\n\t\talignItems: align,\n\t\tjustifyContent: justify,\n\t\tflexDirection: direction,\n\t\tflexWrap: wrap,\n\t\t...props.style,\n\t};\n\n\treturn renderElement< 'div' >( {\n\t\trender,\n\t\tref,\n\t\tprops: { ...props, style, className },\n\t} );\n} );\n", "const css = `@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;\n\n@layer wp-ui-components {\n\t.style-module__stack__Gc4EG {\n\t\tdisplay: flex;\n\t}\n}\n`;\ndocument.head\n .appendChild(document.createElement(\"style\"))\n .appendChild(document.createTextNode(css));\nexport {css};\nexport default {\n \"stack\": \"style-module__stack__Gc4EG\"\n};"],
|
|
5
|
+
"mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,kBAAkB;AAK3B,SAAS,qBAAqB;;;ACb9B,IAAM,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQZ,SAAS,KACJ,YAAY,SAAS,cAAc,OAAO,CAAC,EAC3C,YAAY,SAAS,eAAe,GAAG,CAAC;AAE7C,IAAO,gBAAQ;AAAA,EACb,SAAS;AACX;;;ADOO,IAAM,QAAQ,WAA0C,SAASA,OACvE,EAAE,WAAW,KAAK,OAAO,SAAS,MAAM,QAAQ,GAAG,MAAM,GACzD,KACC;AACD,QAAM,YAAY,KAAM,MAAM,WAAW,cAAO,KAAM;AAEtD,QAAM,QAA6B;AAAA,IAClC,KAAK,OAAO,4BAA6B,GAAI;AAAA,IAC7C,YAAY;AAAA,IACZ,gBAAgB;AAAA,IAChB,eAAe;AAAA,IACf,UAAU;AAAA,IACV,GAAG,MAAM;AAAA,EACV;AAEA,SAAO,cAAwB;AAAA,IAC9B;AAAA,IACA;AAAA,IACA,OAAO,EAAE,GAAG,OAAO,OAAO,UAAU;AAAA,EACrC,CAAE;AACH,CAAE;",
|
|
6
6
|
"names": ["Stack"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type BadgeProps } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* A badge component for displaying labels with semantic intent.
|
|
4
|
+
* Built on the Box primitive for consistent theming and accessibility.
|
|
5
|
+
*/
|
|
6
|
+
export declare const Badge: import("react").ForwardRefExoticComponent<BadgeProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
7
|
+
//# sourceMappingURL=badge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"badge.d.ts","sourceRoot":"","sources":["../../src/badge/badge.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,SAAS,CAAC;AA2D1C;;;GAGG;AACH,eAAO,MAAM,KAAK,uGAwBf,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/badge/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
5
|
+
import '@wordpress/theme/design-tokens.css';
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { Badge } from '../index';
|
|
10
|
+
declare const meta: Meta<typeof Badge>;
|
|
11
|
+
export default meta;
|
|
12
|
+
type Story = StoryObj<typeof Badge>;
|
|
13
|
+
export declare const Default: Story;
|
|
14
|
+
export declare const High: Story;
|
|
15
|
+
export declare const Medium: Story;
|
|
16
|
+
export declare const Low: Story;
|
|
17
|
+
export declare const Stable: Story;
|
|
18
|
+
export declare const Informational: Story;
|
|
19
|
+
export declare const Draft: Story;
|
|
20
|
+
export declare const None: Story;
|
|
21
|
+
export declare const AllIntents: Story;
|
|
22
|
+
//# sourceMappingURL=index.story.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.story.d.ts","sourceRoot":"","sources":["../../../src/badge/stories/index.story.tsx"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAMvD,OAAO,oCAAoC,CAAC;AAE5C;;GAEG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC,QAAA,MAAM,IAAI,EAAE,IAAI,CAAE,OAAO,KAAK,CAI7B,CAAC;AACF,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG,QAAQ,CAAE,OAAO,KAAK,CAAE,CAAC;AAEtC,eAAO,MAAM,OAAO,EAAE,KAIrB,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,KAMlB,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,KAMpB,CAAC;AAEF,eAAO,MAAM,GAAG,EAAE,KAMjB,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,KAMpB,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,KAM3B,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,KAMnB,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,KAMlB,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,KA8CxB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { type ComponentProps } from '../utils/types';
|
|
5
|
+
export interface BadgeProps extends ComponentProps<'span'> {
|
|
6
|
+
/**
|
|
7
|
+
* The text to display in the badge.
|
|
8
|
+
*/
|
|
9
|
+
children: string;
|
|
10
|
+
/**
|
|
11
|
+
* The semantic intent of the badge, communicating its meaning through color.
|
|
12
|
+
*
|
|
13
|
+
* @default "none"
|
|
14
|
+
*/
|
|
15
|
+
intent?: 'high' | 'medium' | 'low' | 'stable' | 'informational' | 'draft' | 'none';
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/badge/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAErD,MAAM,WAAW,UAAW,SAAQ,cAAc,CAAE,MAAM,CAAE;IAC3D;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;;;OAIG;IACH,MAAM,CAAC,EACJ,MAAM,GACN,QAAQ,GACR,KAAK,GACL,QAAQ,GACR,eAAe,GACf,OAAO,GACP,MAAM,CAAC;CACV"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"box.d.ts","sourceRoot":"","sources":["../../src/box/box.tsx"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"box.d.ts","sourceRoot":"","sources":["../../src/box/box.tsx"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,SAAS,CAAC;AAkExC;;;GAGG;AACH,eAAO,MAAM,GAAG,qGAiDb,CAAC"}
|
|
@@ -1,14 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
1
|
import { type Meta, type StoryObj } from '@storybook/react';
|
|
5
|
-
/**
|
|
6
|
-
* WordPress dependencies
|
|
7
|
-
*/
|
|
8
2
|
import '@wordpress/theme/design-tokens.css';
|
|
9
|
-
/**
|
|
10
|
-
* Internal dependencies
|
|
11
|
-
*/
|
|
12
3
|
import { Box } from '../box';
|
|
13
4
|
declare const meta: Meta<typeof Box>;
|
|
14
5
|
export default meta;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.story.d.ts","sourceRoot":"","sources":["../../../src/box/stories/index.story.tsx"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.story.d.ts","sourceRoot":"","sources":["../../../src/box/stories/index.story.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,EAAE,KAAK,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5D,OAAO,oCAAoC,CAAC;AAC5C,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAE7B,QAAA,MAAM,IAAI,EAAE,IAAI,CAAE,OAAO,GAAG,CAI3B,CAAC;AACF,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG,QAAQ,CAAE,OAAO,GAAG,CAAE,CAAC;AAEpC,eAAO,MAAM,OAAO,EAAE,KAgBrB,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,KAUhC,CAAC"}
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
* Internal dependencies
|
|
3
|
-
*/
|
|
1
|
+
import { type PaddingSize, type BorderRadiusSize, type BorderWidthSize, type Target, type SurfaceBackgroundColor, type ContentForegroundColor, type SurfaceStrokeColor } from '@wordpress/theme';
|
|
4
2
|
import { type ComponentProps } from '../utils/types';
|
|
5
|
-
type SizeToken = '2xs' | 'xs' | 'sm' | 'md' | 'lg';
|
|
6
|
-
type Size = number | SizeToken;
|
|
7
|
-
type BackgroundColor = 'neutral' | 'neutral-strong' | 'neutral-weak' | 'brand' | 'success' | 'success-weak' | 'info' | 'info-weak' | 'warning' | 'warning-weak' | 'caution' | 'caution-weak' | 'error' | 'error-weak';
|
|
8
|
-
type ForegroundColor = 'neutral' | 'neutral-weak' | 'success' | 'success-weak' | 'info' | 'info-weak' | 'warning' | 'warning-weak' | 'caution' | 'caution-weak' | 'error' | 'error-weak';
|
|
9
|
-
type StrokeColor = 'brand' | 'brand-strong' | 'error' | 'error-strong' | 'info' | 'info-strong' | 'neutral' | 'neutral-strong' | 'neutral-weak' | 'success' | 'success-strong' | 'warning' | 'warning-strong';
|
|
10
3
|
type DimensionVariant<T> = {
|
|
11
4
|
block?: T;
|
|
12
5
|
blockStart?: T;
|
|
@@ -19,31 +12,31 @@ export interface BoxProps extends ComponentProps<'div'> {
|
|
|
19
12
|
/**
|
|
20
13
|
* The target rendering element design token grouping to use for the box.
|
|
21
14
|
*/
|
|
22
|
-
target?:
|
|
15
|
+
target?: Target;
|
|
23
16
|
/**
|
|
24
17
|
* The surface background design token for box background color.
|
|
25
18
|
*/
|
|
26
|
-
backgroundColor?:
|
|
19
|
+
backgroundColor?: SurfaceBackgroundColor;
|
|
27
20
|
/**
|
|
28
21
|
* The surface foreground design token for box text color.
|
|
29
22
|
*/
|
|
30
|
-
color?:
|
|
23
|
+
color?: ContentForegroundColor;
|
|
31
24
|
/**
|
|
32
25
|
* The surface spacing design token or base unit multiplier for box padding.
|
|
33
26
|
*/
|
|
34
|
-
padding?:
|
|
27
|
+
padding?: PaddingSize | DimensionVariant<PaddingSize>;
|
|
35
28
|
/**
|
|
36
29
|
* The surface border radius design token.
|
|
37
30
|
*/
|
|
38
|
-
borderRadius?:
|
|
31
|
+
borderRadius?: BorderRadiusSize;
|
|
39
32
|
/**
|
|
40
33
|
* The surface border width design token.
|
|
41
34
|
*/
|
|
42
|
-
borderWidth?:
|
|
35
|
+
borderWidth?: BorderWidthSize;
|
|
43
36
|
/**
|
|
44
37
|
* The surface border stroke color design token.
|
|
45
38
|
*/
|
|
46
|
-
borderColor?:
|
|
39
|
+
borderColor?: SurfaceStrokeColor;
|
|
47
40
|
/**
|
|
48
41
|
* The content to be rendered inside the component.
|
|
49
42
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/box/types.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/box/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,MAAM,EACX,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC3B,KAAK,kBAAkB,EACvB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAErD,KAAK,gBAAgB,CAAE,CAAC,IAAK;IAC5B,KAAK,CAAC,EAAE,CAAC,CAAC;IACV,UAAU,CAAC,EAAE,CAAC,CAAC;IACf,QAAQ,CAAC,EAAE,CAAC,CAAC;IACb,MAAM,CAAC,EAAE,CAAC,CAAC;IACX,WAAW,CAAC,EAAE,CAAC,CAAC;IAChB,SAAS,CAAC,EAAE,CAAC,CAAC;CACd,CAAC;AAEF,MAAM,WAAW,QAAS,SAAQ,cAAc,CAAE,KAAK,CAAE;IACxD;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,eAAe,CAAC,EAAE,sBAAsB,CAAC;IAEzC;;OAEG;IACH,KAAK,CAAC,EAAE,sBAAsB,CAAC;IAE/B;;OAEG;IACH,OAAO,CAAC,EAAE,WAAW,GAAG,gBAAgB,CAAE,WAAW,CAAE,CAAC;IAExD;;OAEG;IACH,YAAY,CAAC,EAAE,gBAAgB,CAAC;IAEhC;;OAEG;IACH,WAAW,CAAC,EAAE,eAAe,CAAC;IAE9B;;OAEG;IACH,WAAW,CAAC,EAAE,kBAAkB,CAAC;IAEjC;;OAEG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B"}
|
package/build-types/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/stack/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/stack/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -1,13 +1,4 @@
|
|
|
1
|
-
import { type StackProps
|
|
2
|
-
/**
|
|
3
|
-
* Normalizes the gap value. When given a positive number, it will be converted
|
|
4
|
-
* to a CSS calculation. When given a string, it will be returned as is.
|
|
5
|
-
*
|
|
6
|
-
* @param gap The gap value to normalize.
|
|
7
|
-
*
|
|
8
|
-
* @return The normalized gap value.
|
|
9
|
-
*/
|
|
10
|
-
export declare function getNormalizedGap(gap: number | SizeToken | React.CSSProperties['gap']): string;
|
|
1
|
+
import { type StackProps } from './types';
|
|
11
2
|
/**
|
|
12
3
|
* A flexible layout component using CSS Flexbox for consistent spacing and alignment.
|
|
13
4
|
* Built on design tokens for predictable spacing values.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stack.d.ts","sourceRoot":"","sources":["../../src/stack/stack.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,KAAK,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"stack.d.ts","sourceRoot":"","sources":["../../src/stack/stack.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,SAAS,CAAC;AAG1C;;;GAGG;AACH,eAAO,MAAM,KAAK,uGAoBf,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.story.d.ts","sourceRoot":"","sources":["../../../src/stack/stories/index.story.tsx"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEvD;;GAEG;AACH,OAAO,oCAAoC,CAAC;AAE5C;;GAEG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAGjC,QAAA,MAAM,IAAI,EAAE,IAAI,CAAE,OAAO,KAAK,CAI7B,CAAC;AACF,eAAe,IAAI,CAAC;AAYpB,KAAK,KAAK,GAAG,QAAQ,CAAE,OAAO,KAAK,CAAE,CAAC;AAEtC,eAAO,MAAM,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.story.d.ts","sourceRoot":"","sources":["../../../src/stack/stories/index.story.tsx"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEvD;;GAEG;AACH,OAAO,oCAAoC,CAAC;AAE5C;;GAEG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAGjC,QAAA,MAAM,IAAI,EAAE,IAAI,CAAE,OAAO,KAAK,CAI7B,CAAC;AACF,eAAe,IAAI,CAAC;AAYpB,KAAK,KAAK,GAAG,QAAQ,CAAE,OAAO,KAAK,CAAE,CAAC;AAEtC,eAAO,MAAM,OAAO,EAAE,KA4DrB,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,KAsBpB,CAAC"}
|
|
@@ -1,20 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
* Internal dependencies
|
|
3
|
-
*/
|
|
1
|
+
import { type GapSize } from '@wordpress/theme';
|
|
4
2
|
import { type ComponentProps } from '../utils/types';
|
|
5
|
-
export type SizeToken = '2xs' | 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
6
3
|
export interface StackProps extends ComponentProps<'div'> {
|
|
7
4
|
/**
|
|
8
5
|
* The direction of the stack.
|
|
9
6
|
*/
|
|
10
7
|
direction?: Exclude<React.CSSProperties['flexDirection'], 'row-reverse' | 'column-reverse'>;
|
|
11
8
|
/**
|
|
12
|
-
* The amount of space between each child element
|
|
13
|
-
* multiple of the design system grid spacing.
|
|
9
|
+
* The amount of space between each child element using design system tokens.
|
|
14
10
|
*
|
|
15
|
-
* @default
|
|
11
|
+
* @default undefined
|
|
16
12
|
*/
|
|
17
|
-
gap?:
|
|
13
|
+
gap?: GapSize;
|
|
18
14
|
/**
|
|
19
15
|
* The alignment of the stack items along the cross axis.
|
|
20
16
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/stack/types.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/stack/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAErD,MAAM,WAAW,UAAW,SAAQ,cAAc,CAAE,KAAK,CAAE;IAC1D;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAClB,KAAK,CAAC,aAAa,CAAE,eAAe,CAAE,EACtC,aAAa,GAAG,gBAAgB,CAChC,CAAC;IAEF;;;;OAIG;IACH,GAAG,CAAC,EAAE,OAAO,CAAC;IAEd;;;;OAIG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAE,YAAY,CAAE,CAAC;IAE5C;;;;OAIG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC,aAAa,CAAE,gBAAgB,CAAE,CAAC;IAElD;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAE,KAAK,CAAC,aAAa,CAAE,UAAU,CAAE,EAAE,cAAc,CAAE,CAAC;IAEpE;;OAEG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../src/test/index.test.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.1-next.738bb1424.0",
|
|
4
4
|
"description": "Themeable React UI components for the WordPress Design System.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -22,13 +22,21 @@
|
|
|
22
22
|
"node": ">=20.10.0",
|
|
23
23
|
"npm": ">=10.2.3"
|
|
24
24
|
},
|
|
25
|
-
"
|
|
25
|
+
"files": [
|
|
26
|
+
"src",
|
|
27
|
+
"build",
|
|
28
|
+
"build-module",
|
|
29
|
+
"build-types",
|
|
30
|
+
"*.md"
|
|
31
|
+
],
|
|
32
|
+
"type": "module",
|
|
33
|
+
"main": "build/index.cjs",
|
|
26
34
|
"module": "build-module/index.js",
|
|
27
35
|
"exports": {
|
|
28
36
|
".": {
|
|
29
37
|
"types": "./build-types/index.d.ts",
|
|
30
38
|
"import": "./build-module/index.js",
|
|
31
|
-
"default": "./build/index.
|
|
39
|
+
"default": "./build/index.cjs"
|
|
32
40
|
},
|
|
33
41
|
"./package.json": "./package.json"
|
|
34
42
|
},
|
|
@@ -36,12 +44,11 @@
|
|
|
36
44
|
"types": "build-types",
|
|
37
45
|
"sideEffects": false,
|
|
38
46
|
"dependencies": {
|
|
39
|
-
"@wordpress/element": "^6.36.1-next.
|
|
40
|
-
"@wordpress/private-apis": "^1.36.1-next.6deb34194.0",
|
|
47
|
+
"@wordpress/element": "^6.36.1-next.738bb1424.0",
|
|
41
48
|
"clsx": "^2.1.1"
|
|
42
49
|
},
|
|
43
50
|
"devDependencies": {
|
|
44
|
-
"@wordpress/theme": "^0.
|
|
51
|
+
"@wordpress/theme": "^0.4.1-next.738bb1424.0"
|
|
45
52
|
},
|
|
46
53
|
"peerDependencies": {
|
|
47
54
|
"react": "^18.0.0",
|
|
@@ -50,5 +57,5 @@
|
|
|
50
57
|
"publishConfig": {
|
|
51
58
|
"access": "public"
|
|
52
59
|
},
|
|
53
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "ab1b004c0d61c295aa34bc86ea07f979343983ce"
|
|
54
61
|
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { forwardRef } from '@wordpress/element';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { Box } from '../box';
|
|
10
|
+
import { type BoxProps } from '../box/types';
|
|
11
|
+
import { type BadgeProps } from './types';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Default render function that renders a span element with the given props.
|
|
15
|
+
*
|
|
16
|
+
* @param props The props to apply to the HTML element.
|
|
17
|
+
*/
|
|
18
|
+
const DEFAULT_RENDER = ( props: React.ComponentPropsWithoutRef< 'span' > ) => (
|
|
19
|
+
<span { ...props } />
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Maps intent values to Box backgroundColor and color props.
|
|
24
|
+
* Uses strong emphasis styles (as emphasis prop has been removed).
|
|
25
|
+
* @param intent
|
|
26
|
+
*/
|
|
27
|
+
const getIntentStyles = (
|
|
28
|
+
intent: BadgeProps[ 'intent' ]
|
|
29
|
+
): Partial< BoxProps > => {
|
|
30
|
+
switch ( intent ) {
|
|
31
|
+
case 'high':
|
|
32
|
+
return {
|
|
33
|
+
backgroundColor: 'error',
|
|
34
|
+
color: 'error',
|
|
35
|
+
};
|
|
36
|
+
case 'medium':
|
|
37
|
+
return {
|
|
38
|
+
backgroundColor: 'warning',
|
|
39
|
+
color: 'warning',
|
|
40
|
+
};
|
|
41
|
+
case 'low':
|
|
42
|
+
return {
|
|
43
|
+
backgroundColor: 'caution',
|
|
44
|
+
color: 'caution',
|
|
45
|
+
};
|
|
46
|
+
case 'stable':
|
|
47
|
+
return {
|
|
48
|
+
backgroundColor: 'success',
|
|
49
|
+
color: 'success',
|
|
50
|
+
};
|
|
51
|
+
case 'informational':
|
|
52
|
+
return {
|
|
53
|
+
backgroundColor: 'info',
|
|
54
|
+
color: 'info',
|
|
55
|
+
};
|
|
56
|
+
case 'draft':
|
|
57
|
+
return {
|
|
58
|
+
backgroundColor: 'neutral-weak',
|
|
59
|
+
color: 'neutral',
|
|
60
|
+
};
|
|
61
|
+
case 'none':
|
|
62
|
+
default:
|
|
63
|
+
return {
|
|
64
|
+
backgroundColor: 'neutral',
|
|
65
|
+
color: 'neutral-weak',
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* A badge component for displaying labels with semantic intent.
|
|
72
|
+
* Built on the Box primitive for consistent theming and accessibility.
|
|
73
|
+
*/
|
|
74
|
+
export const Badge = forwardRef< HTMLDivElement, BadgeProps >( function Badge(
|
|
75
|
+
{ children, intent = 'none', render = DEFAULT_RENDER, ...props },
|
|
76
|
+
ref
|
|
77
|
+
) {
|
|
78
|
+
const intentStyles = getIntentStyles( intent );
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<Box
|
|
82
|
+
{ ...intentStyles }
|
|
83
|
+
padding={ { inline: 'xs', block: '2xs' } }
|
|
84
|
+
borderRadius="lg"
|
|
85
|
+
render={ render }
|
|
86
|
+
style={ {
|
|
87
|
+
fontFamily: 'var(--wpds-font-family-body)',
|
|
88
|
+
fontSize: 'var(--wpds-font-size-small)',
|
|
89
|
+
fontWeight: '400',
|
|
90
|
+
lineHeight: 'var(--wpds-font-line-height-x-small)',
|
|
91
|
+
...props.style,
|
|
92
|
+
} }
|
|
93
|
+
ref={ ref }
|
|
94
|
+
>
|
|
95
|
+
{ children }
|
|
96
|
+
</Box>
|
|
97
|
+
);
|
|
98
|
+
} );
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Badge } from './badge';
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { Meta } from '@storybook/blocks';
|
|
2
|
+
import { Badge } from '../index';
|
|
3
|
+
|
|
4
|
+
<Meta title="Design System/Components/Badge/Choosing intent" />
|
|
5
|
+
|
|
6
|
+
# Choosing intent
|
|
7
|
+
|
|
8
|
+
<div style={ { padding: '2rem', display: 'flex', justifyContent: 'center', gap: '0.5rem', flexWrap: 'wrap', border: '1px solid #e0e0e0', borderRadius: '0.5rem' } }>
|
|
9
|
+
<Badge intent="high">high</Badge>
|
|
10
|
+
<Badge intent="medium">medium</Badge>
|
|
11
|
+
<Badge intent="low">low</Badge>
|
|
12
|
+
<Badge intent="stable">stable</Badge>
|
|
13
|
+
<Badge intent="informational">informational</Badge>
|
|
14
|
+
<Badge intent="draft">draft</Badge>
|
|
15
|
+
<Badge intent="none">none</Badge>
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
It can be difficult to determine which badge intent to use because the component's properties are not tied to any specific product view. Those properties should be balanced against the requirements of the view in which the badge appears, all while keeping an eye on high-level consistency (global statuses that appear across multiple views).
|
|
19
|
+
|
|
20
|
+
Here is a decision tree to help identify which badge to use.
|
|
21
|
+
|
|
22
|
+
## 1. Ask first: should this draw the eye?
|
|
23
|
+
|
|
24
|
+
If the user scans this screen, should their attention be drawn to this badge?
|
|
25
|
+
|
|
26
|
+
- If **no** → use `none` (or even just plain text; no badge), even if the state is positive or "stable".
|
|
27
|
+
- If **yes** → pick an intent based on how important the action or awareness is.
|
|
28
|
+
|
|
29
|
+
## 2. High / Medium / Low = action priority
|
|
30
|
+
|
|
31
|
+
Use when there's something for the user to act on.
|
|
32
|
+
|
|
33
|
+
### `high` – Critical / top priority
|
|
34
|
+
|
|
35
|
+
* Needs attention as soon as possible
|
|
36
|
+
* _E.g. "Payment declined", "Security issue"_
|
|
37
|
+
|
|
38
|
+
<Badge intent="high">Payment declined</Badge> <Badge intent="high">Security issue</Badge>
|
|
39
|
+
|
|
40
|
+
### `medium` – Important / blocks progress
|
|
41
|
+
|
|
42
|
+
* Blocks a key task, should be handled soon
|
|
43
|
+
* _E.g. "Approval required", "Review needed"_
|
|
44
|
+
|
|
45
|
+
<Badge intent="medium">Approval required</Badge> <Badge intent="medium">Review needed</Badge>
|
|
46
|
+
|
|
47
|
+
### `low` – Worth noticing / non‑urgent
|
|
48
|
+
|
|
49
|
+
* Good to be aware of; action may be optional or later
|
|
50
|
+
* _E.g. "Pending", "Queued", "Minor issues", "Optional setup"_
|
|
51
|
+
|
|
52
|
+
<Badge intent="low">Pending</Badge> <Badge intent="low">Queued</Badge>
|
|
53
|
+
|
|
54
|
+
## 3. Informational / draft = special non-final states
|
|
55
|
+
|
|
56
|
+
### `informational` – Notable, no action / fix needed
|
|
57
|
+
|
|
58
|
+
* Context only; no clear action
|
|
59
|
+
* _E.g. "Scheduled", "Beta", "Internal only"_
|
|
60
|
+
|
|
61
|
+
<Badge intent="informational">Scheduled</Badge> <Badge intent="informational">Beta</Badge>
|
|
62
|
+
|
|
63
|
+
### `draft` – Not final / work in progress
|
|
64
|
+
|
|
65
|
+
* _E.g. "Draft", "Unpublished", "Work in progress"_
|
|
66
|
+
|
|
67
|
+
<Badge intent="draft">Draft</Badge> <Badge intent="draft">Unpublished</Badge>
|
|
68
|
+
|
|
69
|
+
## 4. Stable / none = normal states
|
|
70
|
+
|
|
71
|
+
### `stable` – Positive / "healthy" state
|
|
72
|
+
|
|
73
|
+
* Use when confirming success or "all good" is important in that view
|
|
74
|
+
* _E.g. "Healthy", "Active", "Live"_
|
|
75
|
+
|
|
76
|
+
<Badge intent="stable">Healthy</Badge> <Badge intent="stable">Active</Badge>
|
|
77
|
+
|
|
78
|
+
### `none` – Default for normal / background states
|
|
79
|
+
|
|
80
|
+
* Especially in dense lists where too much color creates visual noise
|
|
81
|
+
* _E.g. "Inactive", "Expired"_
|
|
82
|
+
|
|
83
|
+
<Badge intent="none">Inactive</Badge> <Badge intent="none">Expired</Badge>
|
|
84
|
+
|
|
85
|
+
## Examples
|
|
86
|
+
|
|
87
|
+
### Comment status:
|
|
88
|
+
|
|
89
|
+
- "Approved" → `none`: <Badge intent="none">Approved</Badge>
|
|
90
|
+
- "Approval required" → `medium`: <Badge intent="medium">Approval required</Badge>
|
|
91
|
+
|
|
92
|
+
### Page status:
|
|
93
|
+
|
|
94
|
+
- "Published" → `none`: <Badge intent="none">Published</Badge>
|
|
95
|
+
- "Pending" → `low`: <Badge intent="low">Pending</Badge>
|
|
96
|
+
- "Draft" → `draft`: <Badge intent="draft">Draft</Badge>
|
|
97
|
+
- "Scheduled" → `informational`: <Badge intent="informational">Scheduled</Badge>
|
|
98
|
+
- "Private" → `informational`: <Badge intent="informational">Private</Badge>
|
|
99
|
+
|
|
100
|
+
### Plugin status:
|
|
101
|
+
|
|
102
|
+
- "Active" → `stable`: <Badge intent="stable">Active</Badge>
|
|
103
|
+
- "Inactive" → `none`: <Badge intent="none">Inactive</Badge>
|
|
104
|
+
|
|
105
|
+
## 5. When in doubt…
|
|
106
|
+
|
|
107
|
+
Use the least attention‑grabbing intent that still:
|
|
108
|
+
|
|
109
|
+
- Makes it clear what needs attention,
|
|
110
|
+
- Marks what isn't final, or
|
|
111
|
+
- Confirms a key success state in that context.
|
|
112
|
+
|