@wordpress/admin-ui 1.0.1-next.47f435fc9.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 (38) hide show
  1. package/CHANGELOG.md +3 -0
  2. package/LICENSE.md +788 -0
  3. package/README.md +33 -0
  4. package/build/index.js +42 -0
  5. package/build/index.js.map +7 -0
  6. package/build/navigable-region/index.js +55 -0
  7. package/build/navigable-region/index.js.map +7 -0
  8. package/build/page/header.js +61 -0
  9. package/build/page/header.js.map +7 -0
  10. package/build/page/index.js +64 -0
  11. package/build/page/index.js.map +7 -0
  12. package/build-module/index.js +7 -0
  13. package/build-module/index.js.map +7 -0
  14. package/build-module/navigable-region/index.js +25 -0
  15. package/build-module/navigable-region/index.js.map +7 -0
  16. package/build-module/page/header.js +45 -0
  17. package/build-module/page/header.js.map +7 -0
  18. package/build-module/page/index.js +34 -0
  19. package/build-module/page/index.js.map +7 -0
  20. package/build-style/style-rtl.css +150 -0
  21. package/build-style/style.css +150 -0
  22. package/build-types/index.d.ts +3 -0
  23. package/build-types/index.d.ts.map +1 -0
  24. package/build-types/navigable-region/index.d.ts +13 -0
  25. package/build-types/navigable-region/index.d.ts.map +1 -0
  26. package/build-types/page/header.d.ts +9 -0
  27. package/build-types/page/header.d.ts.map +1 -0
  28. package/build-types/page/index.d.ts +12 -0
  29. package/build-types/page/index.d.ts.map +1 -0
  30. package/package.json +48 -0
  31. package/src/index.ts +2 -0
  32. package/src/navigable-region/index.tsx +42 -0
  33. package/src/page/header.tsx +53 -0
  34. package/src/page/index.tsx +55 -0
  35. package/src/page/style.scss +74 -0
  36. package/src/style.scss +1 -0
  37. package/tsconfig.json +5 -0
  38. package/tsconfig.tsbuildinfo +1 -0
@@ -0,0 +1,150 @@
1
+ /**
2
+ * Colors
3
+ */
4
+ /**
5
+ * SCSS Variables.
6
+ *
7
+ * Please use variables from this sheet to ensure consistency across the UI.
8
+ * Don't add to this sheet unless you're pretty sure the value will be reused in many places.
9
+ * For example, don't add rules to this sheet that affect block visuals. It's purely for UI.
10
+ */
11
+ /**
12
+ * Fonts & basic variables.
13
+ */
14
+ /**
15
+ * Typography
16
+ */
17
+ /**
18
+ * Grid System.
19
+ * https://make.wordpress.org/design/2019/10/31/proposal-a-consistent-spacing-system-for-wordpress/
20
+ */
21
+ /**
22
+ * Radius scale.
23
+ */
24
+ /**
25
+ * Elevation scale.
26
+ */
27
+ /**
28
+ * Dimensions.
29
+ */
30
+ /**
31
+ * Mobile specific styles
32
+ */
33
+ /**
34
+ * Editor styles.
35
+ */
36
+ /**
37
+ * Block & Editor UI.
38
+ */
39
+ /**
40
+ * Block paddings.
41
+ */
42
+ /**
43
+ * React Native specific.
44
+ * These variables do not appear to be used anywhere else.
45
+ */
46
+ /**
47
+ * Typography
48
+ */
49
+ /**
50
+ * Breakpoints & Media Queries
51
+ */
52
+ /**
53
+ * Converts a hex value into the rgb equivalent.
54
+ *
55
+ * @param {string} hex - the hexadecimal value to convert
56
+ * @return {string} comma separated rgb values
57
+ */
58
+ /**
59
+ * Long content fade mixin
60
+ *
61
+ * Creates a fading overlay to signify that the content is longer
62
+ * than the space allows.
63
+ */
64
+ /**
65
+ * Breakpoint mixins
66
+ */
67
+ /**
68
+ * Focus styles.
69
+ */
70
+ /**
71
+ * Applies editor left position to the selector passed as argument
72
+ */
73
+ /**
74
+ * Styles that are reused verbatim in a few places
75
+ */
76
+ /**
77
+ * Allows users to opt-out of animations via OS-level preferences.
78
+ */
79
+ /**
80
+ * Reset default styles for JavaScript UI based pages.
81
+ * This is a WP-admin agnostic reset
82
+ */
83
+ /**
84
+ * Reset the WP Admin page styles for Gutenberg-like pages.
85
+ */
86
+ .admin-ui-page {
87
+ display: flex;
88
+ height: 100%;
89
+ background-color: #fff;
90
+ color: #2f2f2f;
91
+ position: relative;
92
+ z-index: 1;
93
+ flex-flow: column;
94
+ container: admin-ui-page/inline-size;
95
+ }
96
+ @media not (prefers-reduced-motion) {
97
+ .admin-ui-page {
98
+ transition: width ease-out 0.2s;
99
+ }
100
+ }
101
+
102
+ .admin-ui-page__header {
103
+ padding: 16px 48px;
104
+ border-bottom: 1px solid #f0f0f0;
105
+ background: #fff;
106
+ position: sticky;
107
+ top: 0;
108
+ }
109
+ @container (max-width: 430px) {
110
+ .admin-ui-page__header {
111
+ padding: 16px 24px;
112
+ }
113
+ }
114
+
115
+ .admin-ui-page__header-subtitle {
116
+ padding-block-end: 8px;
117
+ color: #757575;
118
+ font-family: -apple-system, "system-ui", "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
119
+ font-weight: 400;
120
+ font-size: 13px;
121
+ line-height: 20px;
122
+ margin: 0;
123
+ }
124
+
125
+ .admin-ui-page__content {
126
+ flex-grow: 1;
127
+ overflow: auto;
128
+ display: flex;
129
+ flex-direction: column;
130
+ }
131
+ .admin-ui-page__content.has-padding {
132
+ padding: 16px 20px;
133
+ }
134
+ @container (max-width: 430px) {
135
+ .admin-ui-page__content.has-padding {
136
+ padding: 16px 24px;
137
+ }
138
+ }
139
+
140
+ .show-icon-labels .admin-ui-page__header-actions .components-button.has-icon {
141
+ width: auto;
142
+ padding: 0 8px;
143
+ }
144
+ .show-icon-labels .admin-ui-page__header-actions .components-button.has-icon svg {
145
+ display: none;
146
+ }
147
+ .show-icon-labels .admin-ui-page__header-actions .components-button.has-icon::after {
148
+ content: attr(aria-label);
149
+ font-size: 12px;
150
+ }
@@ -0,0 +1,3 @@
1
+ export { default as NavigableRegion } from './navigable-region';
2
+ export { default as Page } from './page';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,QAAQ,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Type definitions
3
+ */
4
+ type NavigableRegionProps = {
5
+ children: React.ReactNode;
6
+ className?: string;
7
+ ariaLabel: string;
8
+ as?: React.ElementType;
9
+ [key: string]: any;
10
+ };
11
+ declare const NavigableRegion: import("react").ForwardRefExoticComponent<Omit<NavigableRegionProps, "ref"> & import("react").RefAttributes<HTMLElement>>;
12
+ export default NavigableRegion;
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/navigable-region/index.tsx"],"names":[],"mappings":"AAUA;;GAEG;AACH,KAAK,oBAAoB,GAAG;IAC3B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,EAAE,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC;IACvB,CAAE,GAAG,EAAE,MAAM,GAAI,GAAG,CAAC;CACrB,CAAC;AAGF,QAAA,MAAM,eAAe,2HAepB,CAAC;AAIF,eAAe,eAAe,CAAC"}
@@ -0,0 +1,9 @@
1
+ export default function Header({ breadcrumbs, badges, title, subTitle, actions, }: {
2
+ breadcrumbs?: React.ReactNode;
3
+ badges?: React.ReactNode;
4
+ title?: React.ReactNode;
5
+ subTitle: React.ReactNode;
6
+ actions?: React.ReactNode;
7
+ showSidebarToggle?: boolean;
8
+ }): import("react").JSX.Element;
9
+ //# sourceMappingURL=header.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"header.d.ts","sourceRoot":"","sources":["../../src/page/header.tsx"],"names":[],"mappings":"AASA,MAAM,CAAC,OAAO,UAAU,MAAM,CAAE,EAC/B,WAAW,EACX,MAAM,EACN,KAAK,EACL,QAAQ,EACR,OAAO,GACP,EAAE;IACF,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC9B,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACzB,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC5B,+BA8BA"}
@@ -0,0 +1,12 @@
1
+ declare function Page({ breadcrumbs, badges, title, subTitle, children, className, actions, hasPadding, }: {
2
+ breadcrumbs?: React.ReactNode;
3
+ badges?: React.ReactNode;
4
+ title?: React.ReactNode;
5
+ subTitle?: React.ReactNode;
6
+ children: React.ReactNode;
7
+ className?: string;
8
+ actions?: React.ReactNode;
9
+ hasPadding?: boolean;
10
+ }): import("react").JSX.Element;
11
+ export default Page;
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/page/index.tsx"],"names":[],"mappings":"AAWA,iBAAS,IAAI,CAAE,EACd,WAAW,EACX,MAAM,EACN,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,OAAO,EACP,UAAkB,GAClB,EAAE;IACF,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC9B,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACzB,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,UAAU,CAAC,EAAE,OAAO,CAAC;CACrB,+BAuBA;AAED,eAAe,IAAI,CAAC"}
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@wordpress/admin-ui",
3
+ "version": "1.0.1-next.47f435fc9.0",
4
+ "description": "Generic components to be used in the Admin UI.",
5
+ "author": "The WordPress Contributors",
6
+ "license": "GPL-2.0-or-later",
7
+ "keywords": [
8
+ "wordpress",
9
+ "admin",
10
+ "ui"
11
+ ],
12
+ "homepage": "https://github.com/WordPress/gutenberg/tree/HEAD/packages/admin-ui/README.md",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "https://github.com/WordPress/gutenberg.git",
16
+ "directory": "packages/admin-ui"
17
+ },
18
+ "bugs": {
19
+ "url": "https://github.com/WordPress/gutenberg/issues"
20
+ },
21
+ "engines": {
22
+ "node": ">=18.12.0",
23
+ "npm": ">=8.19.2"
24
+ },
25
+ "main": "build/index.js",
26
+ "module": "build-module/index.js",
27
+ "exports": {
28
+ ".": {
29
+ "types": "./build-types/index.d.ts",
30
+ "import": "./build-module/index.js",
31
+ "require": "./build/index.js"
32
+ },
33
+ "./package.json": "./package.json"
34
+ },
35
+ "react-native": "src/index",
36
+ "types": "build-types",
37
+ "sideEffects": false,
38
+ "dependencies": {
39
+ "@wordpress/base-styles": "^6.8.1-next.47f435fc9.0",
40
+ "@wordpress/components": "^30.6.1-next.47f435fc9.0",
41
+ "@wordpress/element": "^6.32.1-next.47f435fc9.0",
42
+ "clsx": "^2.1.1"
43
+ },
44
+ "publishConfig": {
45
+ "access": "public"
46
+ },
47
+ "gitHead": "9720f22c138771d2ed1a0522725c3cdf1c242953"
48
+ }
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { default as NavigableRegion } from './navigable-region';
2
+ export { default as Page } from './page';
@@ -0,0 +1,42 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import clsx from 'clsx';
5
+
6
+ /**
7
+ * WordPress dependencies
8
+ */
9
+ import { forwardRef } from '@wordpress/element';
10
+
11
+ /**
12
+ * Type definitions
13
+ */
14
+ type NavigableRegionProps = {
15
+ children: React.ReactNode;
16
+ className?: string;
17
+ ariaLabel: string;
18
+ as?: React.ElementType;
19
+ [ key: string ]: any;
20
+ };
21
+
22
+ // This is a copy of the private `NavigableRegion` component from the '@wordpress/editor' private APIs.
23
+ const NavigableRegion = forwardRef< HTMLElement, NavigableRegionProps >(
24
+ ( { children, className, ariaLabel, as: Tag = 'div', ...props }, ref ) => {
25
+ return (
26
+ <Tag
27
+ ref={ ref }
28
+ className={ clsx( 'admin-ui-navigable-region', className ) }
29
+ aria-label={ ariaLabel }
30
+ role="region"
31
+ tabIndex="-1"
32
+ { ...props }
33
+ >
34
+ { children }
35
+ </Tag>
36
+ );
37
+ }
38
+ );
39
+
40
+ NavigableRegion.displayName = 'NavigableRegion';
41
+
42
+ export default NavigableRegion;
@@ -0,0 +1,53 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import {
5
+ __experimentalHeading as Heading,
6
+ __experimentalHStack as HStack,
7
+ __experimentalVStack as VStack,
8
+ } from '@wordpress/components';
9
+
10
+ export default function Header( {
11
+ breadcrumbs,
12
+ badges,
13
+ title,
14
+ subTitle,
15
+ actions,
16
+ }: {
17
+ breadcrumbs?: React.ReactNode;
18
+ badges?: React.ReactNode;
19
+ title?: React.ReactNode;
20
+ subTitle: React.ReactNode;
21
+ actions?: React.ReactNode;
22
+ showSidebarToggle?: boolean;
23
+ } ) {
24
+ return (
25
+ <VStack className="admin-ui-page__header" as="header">
26
+ <HStack
27
+ className="admin-ui-page__header-title"
28
+ justify="space-between"
29
+ spacing={ 2 }
30
+ >
31
+ <HStack spacing={ 2 }>
32
+ { title && (
33
+ <Heading as="h2" level={ 3 } weight={ 500 } truncate>
34
+ { title }
35
+ </Heading>
36
+ ) }
37
+ { breadcrumbs }
38
+ { badges }
39
+ </HStack>
40
+ <HStack
41
+ style={ { width: 'auto', flexShrink: 0 } }
42
+ spacing={ 2 }
43
+ className="admin-ui-page__header-actions"
44
+ >
45
+ { actions }
46
+ </HStack>
47
+ </HStack>
48
+ { subTitle && (
49
+ <p className="admin-ui-page__header-subtitle">{ subTitle }</p>
50
+ ) }
51
+ </VStack>
52
+ );
53
+ }
@@ -0,0 +1,55 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import clsx from 'clsx';
5
+
6
+ /**
7
+ * Internal dependencies
8
+ */
9
+ import Header from './header';
10
+ import NavigableRegion from '../navigable-region';
11
+
12
+ function Page( {
13
+ breadcrumbs,
14
+ badges,
15
+ title,
16
+ subTitle,
17
+ children,
18
+ className,
19
+ actions,
20
+ hasPadding = false,
21
+ }: {
22
+ breadcrumbs?: React.ReactNode;
23
+ badges?: React.ReactNode;
24
+ title?: React.ReactNode;
25
+ subTitle?: React.ReactNode;
26
+ children: React.ReactNode;
27
+ className?: string;
28
+ actions?: React.ReactNode;
29
+ hasPadding?: boolean;
30
+ } ) {
31
+ const classes = clsx( 'admin-ui-page', className );
32
+
33
+ return (
34
+ <NavigableRegion className={ classes } ariaLabel={ title }>
35
+ { ( title || breadcrumbs || badges ) && (
36
+ <Header
37
+ breadcrumbs={ breadcrumbs }
38
+ badges={ badges }
39
+ title={ title }
40
+ subTitle={ subTitle }
41
+ actions={ actions }
42
+ />
43
+ ) }
44
+ { hasPadding ? (
45
+ <div className="admin-ui-page__content has-padding">
46
+ { children }
47
+ </div>
48
+ ) : (
49
+ children
50
+ ) }
51
+ </NavigableRegion>
52
+ );
53
+ }
54
+
55
+ export default Page;
@@ -0,0 +1,74 @@
1
+ @use "@wordpress/base-styles/colors" as *;
2
+ @use "@wordpress/base-styles/variables" as *;
3
+ @use "@wordpress/base-styles/mixins" as *;
4
+ @use "@wordpress/base-styles/breakpoints" as *;
5
+
6
+ .admin-ui-page {
7
+ display: flex;
8
+ height: 100%;
9
+ background-color: $white;
10
+ color: $gray-800;
11
+ position: relative;
12
+ z-index: 1;
13
+ flex-flow: column;
14
+ container: admin-ui-page / inline-size;
15
+
16
+ @media not (prefers-reduced-motion) {
17
+ transition: width ease-out 0.2s;
18
+ }
19
+ }
20
+
21
+ .admin-ui-page__header {
22
+ padding: $grid-unit-20 $grid-unit-60;
23
+ border-bottom: 1px solid $gray-100;
24
+ background: $white;
25
+ position: sticky;
26
+ top: 0;
27
+
28
+ @container (max-width: 430px) {
29
+ padding: $grid-unit-20 $grid-unit-30;
30
+ }
31
+ }
32
+
33
+ .admin-ui-page__header-subtitle {
34
+ padding-block-end: $grid-unit-10;
35
+ color: $gray-700;
36
+ @include body-medium();
37
+ margin: 0;
38
+ }
39
+
40
+ .admin-ui-page__content {
41
+ flex-grow: 1;
42
+ overflow: auto;
43
+ display: flex;
44
+ flex-direction: column;
45
+
46
+ &.has-padding {
47
+ padding: $grid-unit-20 $grid-unit * 2.5;
48
+ @container (max-width: 430px) {
49
+ padding: $grid-unit-20 $grid-unit-30;
50
+ }
51
+ }
52
+ }
53
+
54
+ // Show button text labels when preference is enabled.
55
+ .show-icon-labels {
56
+ .admin-ui-page__header-actions {
57
+ .components-button.has-icon {
58
+ width: auto;
59
+ padding: 0 $grid-unit-10;
60
+
61
+ // Hide the button icons when labels are set to display...
62
+ svg {
63
+ display: none;
64
+ }
65
+ // ... and display labels.
66
+ &::after {
67
+ content: attr(aria-label);
68
+ font-size: $helptext-font-size;
69
+ }
70
+ }
71
+
72
+ }
73
+ }
74
+
package/src/style.scss ADDED
@@ -0,0 +1 @@
1
+ @use "./page/style.scss";
package/tsconfig.json ADDED
@@ -0,0 +1,5 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig.json",
3
+ "extends": "../../tsconfig.base.json",
4
+ "references": [ { "path": "../components" }, { "path": "../element" } ]
5
+ }