@gopherium/godmin 0.4.0 → 0.5.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`, `LoadingScreen`, `LoadingRows`, `useLoadingGate`, `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` |
@@ -145,17 +145,15 @@ label through a visually hidden status region, so give `label` the same
145
145
  sentence you would have rendered as text.
146
146
 
147
147
  ```tsx
148
- const ghost = useLoadingGate(reports.isPending)
149
-
150
- if (ghost) {
148
+ if (reports.isPending) {
151
149
  return <LoadingRows label="Loading reports." rows={8} />
152
150
  }
151
+ return <ReportTable className="godmin-arrival" />
153
152
  ```
154
153
 
155
- `useLoadingGate` owns the timing: a load that resolves quickly shows no
156
- ghost at all, and a ghost that does appear stays long enough to read as
157
- intentional. Gate the pending flag rather than using it directly, or a
158
- mid speed load flashes the ghost for a moment.
154
+ A ghost fades in after a short delay, so a fast load never shows one.
155
+ Give the content that replaces a ghost the `godmin-arrival` class and it
156
+ fades in too, so the swap reads as one motion rather than a snap.
159
157
 
160
158
  `base.css` also ships `godmin-empty`, `godmin-form`, `godmin-table` and
161
159
  `godmin-table-scroll`. The last two go together: a table wider than a phone
package/dist/base.css CHANGED
@@ -152,6 +152,28 @@ body {
152
152
  white-space: nowrap;
153
153
  }
154
154
 
155
+ .godmin-loading-screen,
156
+ .godmin-loading-rows {
157
+ opacity: 0;
158
+ animation: godmin-fade-in var(--wpds-motion-duration-md)
159
+ var(--wpds-motion-easing-balanced) 150ms forwards;
160
+ }
161
+
162
+ .godmin-arrival {
163
+ animation: godmin-fade-in var(--wpds-motion-duration-md)
164
+ var(--wpds-motion-easing-balanced);
165
+ }
166
+
167
+ @keyframes godmin-fade-in {
168
+ 0% {
169
+ opacity: 0;
170
+ }
171
+
172
+ 100% {
173
+ opacity: 1;
174
+ }
175
+ }
176
+
155
177
  .godmin-loading-screen {
156
178
  padding: var(--wpds-dimension-padding-xl);
157
179
  }
package/dist/index.d.ts CHANGED
@@ -10,7 +10,6 @@ export { ErrorNotice, LoadMore, Page, PageTitle } from './page.js';
10
10
  export type { LoadMoreQuery, PageProps } from './page.js';
11
11
  export { Toaster, useToaster } from './toaster.js';
12
12
  export type { ToastAction, ToasterHandle, ToasterProps } from './toaster.js';
13
- export { useLoadingGate } from './use-loading-gate.js';
14
13
  export { useMediaQuery } from './use-media-query.js';
15
14
  export { useTokenDocument } from './use-token-document.js';
16
15
  /**
package/dist/index.js CHANGED
@@ -6,7 +6,6 @@ export { LoadingRows, LoadingScreen } from './loading.js';
6
6
  export { NavScreen } from './nav-screen.js';
7
7
  export { ErrorNotice, LoadMore, Page, PageTitle } from './page.js';
8
8
  export { Toaster, useToaster } from './toaster.js';
9
- export { useLoadingGate } from './use-loading-gate.js';
10
9
  export { useMediaQuery } from './use-media-query.js';
11
10
  export { useTokenDocument } from './use-token-document.js';
12
11
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gopherium/godmin",
3
- "version": "0.4.0",
3
+ "version": "0.5.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",
@@ -1,6 +0,0 @@
1
- /**
2
- * Returns whether a loading ghost should stand in for the pending work.
3
- * @param pending - Whether the work the ghost stands in for is still pending.
4
- * @returns Whether to render the ghost.
5
- */
6
- export declare function useLoadingGate(pending: boolean): boolean;
@@ -1,32 +0,0 @@
1
- // SPDX-License-Identifier: Apache-2.0
2
- import { useEffect, useRef, useState } from 'react';
3
- const SHOW_AFTER = 200;
4
- const SHOW_FOR = 500;
5
- /**
6
- * Returns whether a loading ghost should stand in for the pending work.
7
- * @param pending - Whether the work the ghost stands in for is still pending.
8
- * @returns Whether to render the ghost.
9
- */
10
- export function useLoadingGate(pending) {
11
- const [showing, setShowing] = useState(false);
12
- const holdUntil = useRef(0);
13
- useEffect(() => {
14
- if (pending && !showing) {
15
- const delay = setTimeout(() => {
16
- holdUntil.current = Date.now() + SHOW_FOR;
17
- setShowing(true);
18
- }, SHOW_AFTER);
19
- return () => clearTimeout(delay);
20
- }
21
- if (!pending && showing) {
22
- const left = holdUntil.current - Date.now();
23
- if (left <= 0) {
24
- setShowing(false);
25
- return;
26
- }
27
- const hold = setTimeout(() => setShowing(false), left);
28
- return () => clearTimeout(hold);
29
- }
30
- }, [pending, showing]);
31
- return showing;
32
- }