@gopherium/godmin 0.2.1 → 0.3.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/README.md CHANGED
@@ -19,7 +19,7 @@ here duplicates something upstream ships.
19
19
 
20
20
  | Entry point | Contents |
21
21
  | --- | --- |
22
- | `@gopherium/godmin` | `AdminRoot`, `Frame`, `Page`, `PageTitle`, `NavScreen`, `ErrorNotice`, `LoadMore`, `Toaster`, `useToaster`, `useMediaQuery`, `useTokenDocument`, the breakpoints, `SUPPORTED_WPDS` |
22
+ | `@gopherium/godmin` | `AdminRoot`, `Frame`, `Page`, `PageTitle`, `NavScreen`, `ErrorNotice`, `LoadMore`, `LoadingScreen`, `LoadingRows`, `Toaster`, `useToaster`, `useMediaQuery`, `useTokenDocument`, the breakpoints, `SUPPORTED_WPDS` |
23
23
  | `@gopherium/godmin/base.css` | cascade layer order, design tokens, host rules, frame and screen styles |
24
24
  | `@gopherium/godmin/router` | `useCanvas`, `useFrameLocation`, the `canvas` route static data |
25
25
  | `@gopherium/godmin/testing` | `installTestEnvironment`, `renderAdmin`, `setViewport`, `getAnnouncement`, `clearAnnouncements`, `assertElementPatched`, `WPDS_IGNORE_SELECTOR` |
@@ -136,6 +136,25 @@ supply so the kit stays router free.
136
136
  </NavScreen>
137
137
  ```
138
138
 
139
+ ### While data loads
140
+
141
+ `LoadingScreen` stands in for a screen whose data has not arrived, and
142
+ `LoadingRows` stands in for a list body under chrome that is already there.
143
+ Both render a ghost built from the design system skeleton and announce their
144
+ label through a visually hidden status region, so give `label` the same
145
+ sentence you would have rendered as text.
146
+
147
+ ```tsx
148
+ if (report.data === undefined) {
149
+ return <LoadingScreen label="Loading the report." />
150
+ }
151
+
152
+ {reports.isPending ? <LoadingRows label="Loading reports." rows={8} /> : <ReportTable />}
153
+ ```
154
+
155
+ A ghost appears only after a short delay, so a load that resolves quickly
156
+ shows nothing at all rather than a flash.
157
+
139
158
  `base.css` also ships `godmin-empty`, `godmin-form`, `godmin-table` and
140
159
  `godmin-table-scroll`. The last two go together: a table wider than a phone
141
160
  scrolls inside its own region rather than dragging the page sideways.
package/dist/base.css CHANGED
@@ -85,6 +85,7 @@ body {
85
85
  left: 16px;
86
86
  bottom: 16px;
87
87
  z-index: 1;
88
+ width: 360px;
88
89
  max-width: calc(100vw - 32px);
89
90
  }
90
91
 
@@ -151,6 +152,56 @@ body {
151
152
  white-space: nowrap;
152
153
  }
153
154
 
155
+ .godmin-loading-screen,
156
+ .godmin-loading-rows {
157
+ opacity: 0;
158
+ animation: godmin-loading-appear var(--wpds-motion-duration-md)
159
+ var(--wpds-motion-easing-balanced) 200ms forwards;
160
+ }
161
+
162
+ @keyframes godmin-loading-appear {
163
+ 100% {
164
+ opacity: 1;
165
+ }
166
+ }
167
+
168
+ .godmin-loading-screen {
169
+ padding: var(--wpds-dimension-padding-xl);
170
+ }
171
+
172
+ .godmin-loading-screen__ghost {
173
+ display: flex;
174
+ flex-direction: column;
175
+ gap: var(--wpds-dimension-gap-lg);
176
+ max-width: var(--wpds-dimension-surface-width-sm);
177
+ }
178
+
179
+ .godmin-loading-screen__title {
180
+ height: 32px;
181
+ width: 40%;
182
+ border-radius: var(--wpds-border-radius-sm);
183
+ }
184
+
185
+ .godmin-loading-screen__stroke {
186
+ height: 14px;
187
+ border-radius: var(--wpds-border-radius-sm);
188
+ }
189
+
190
+ .godmin-loading-screen__stroke:last-child {
191
+ width: 70%;
192
+ }
193
+
194
+ .godmin-loading-rows__ghost {
195
+ display: flex;
196
+ flex-direction: column;
197
+ gap: var(--wpds-dimension-gap-sm);
198
+ }
199
+
200
+ .godmin-loading-rows__row {
201
+ height: var(--wpds-dimension-size-lg);
202
+ border-radius: var(--wpds-border-radius-sm);
203
+ }
204
+
154
205
  /* Small viewport overrides live together at the end of the sheet, so they
155
206
  always win over the rules above them without extra specificity. */
156
207
  @media (max-width: 639px) {
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@ export type { AdminRootProps } from './admin-root.js';
3
3
  export { DENSE_BREAKPOINT, RAIL_BREAKPOINT, SMALL_VIEWPORT } from './breakpoints.js';
4
4
  export { Frame } from './frame.js';
5
5
  export type { CanvasMode, FrameCanvasProps, FrameRailProps, FrameRootProps, } from './frame.js';
6
+ export { LoadingRows, LoadingScreen } from './loading.js';
6
7
  export { NavScreen } from './nav-screen.js';
7
8
  export type { NavScreenProps } from './nav-screen.js';
8
9
  export { ErrorNotice, LoadMore, Page, PageTitle } from './page.js';
package/dist/index.js CHANGED
@@ -2,6 +2,7 @@
2
2
  export { AdminRoot } from './admin-root.js';
3
3
  export { DENSE_BREAKPOINT, RAIL_BREAKPOINT, SMALL_VIEWPORT } from './breakpoints.js';
4
4
  export { Frame } from './frame.js';
5
+ export { LoadingRows, LoadingScreen } from './loading.js';
5
6
  export { NavScreen } from './nav-screen.js';
6
7
  export { ErrorNotice, LoadMore, Page, PageTitle } from './page.js';
7
8
  export { Toaster, useToaster } from './toaster.js';
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Renders a content-shaped ghost while a screen's data loads.
3
+ * @param props - The label a screen reader announces.
4
+ * @returns The loading screen element.
5
+ */
6
+ export declare function LoadingScreen({ label }: {
7
+ label: string;
8
+ }): import("react").JSX.Element;
9
+ /**
10
+ * Renders a stack of row-shaped ghosts while a list's data loads.
11
+ * @param props - The label a screen reader announces and the row count.
12
+ * @returns The loading rows element.
13
+ */
14
+ export declare function LoadingRows({ label, rows }: {
15
+ label: string;
16
+ rows?: number;
17
+ }): import("react").JSX.Element;
@@ -0,0 +1,20 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import { Skeleton, VisuallyHidden } from '@wordpress/ui';
4
+ const STROKES = 3;
5
+ /**
6
+ * Renders a content-shaped ghost while a screen's data loads.
7
+ * @param props - The label a screen reader announces.
8
+ * @returns The loading screen element.
9
+ */
10
+ export function LoadingScreen({ label }) {
11
+ return (_jsxs("div", { className: "godmin-loading-screen", children: [_jsx(VisuallyHidden, { role: "status", children: label }), _jsxs("div", { className: "godmin-loading-screen__ghost", "aria-hidden": "true", children: [_jsx(Skeleton, { className: "godmin-loading-screen__title" }), Array.from({ length: STROKES }, (_, stroke) => (_jsx(Skeleton, { className: "godmin-loading-screen__stroke" }, stroke)))] })] }));
12
+ }
13
+ /**
14
+ * Renders a stack of row-shaped ghosts while a list's data loads.
15
+ * @param props - The label a screen reader announces and the row count.
16
+ * @returns The loading rows element.
17
+ */
18
+ export function LoadingRows({ label, rows = 5 }) {
19
+ return (_jsxs("div", { className: "godmin-loading-rows", children: [_jsx(VisuallyHidden, { role: "status", children: label }), _jsx("div", { className: "godmin-loading-rows__ghost", "aria-hidden": "true", children: Array.from({ length: rows }, (_, row) => (_jsx(Skeleton, { className: "godmin-loading-rows__row" }, row))) })] }));
20
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gopherium/godmin",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "description": "The admin kit for Gopherium projects: host layer for React admin applications on the WordPress Design System.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",