dash-startup-loading-plugin 0.3.0__tar.gz → 0.4.0__tar.gz
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.
- {dash_startup_loading_plugin-0.3.0/src/dash_startup_loading_plugin.egg-info → dash_startup_loading_plugin-0.4.0}/PKG-INFO +102 -28
- {dash_startup_loading_plugin-0.3.0 → dash_startup_loading_plugin-0.4.0}/README.md +100 -22
- {dash_startup_loading_plugin-0.3.0 → dash_startup_loading_plugin-0.4.0}/pyproject.toml +6 -6
- {dash_startup_loading_plugin-0.3.0 → dash_startup_loading_plugin-0.4.0}/src/dash_startup_loading_plugin/__init__.py +3 -1
- dash_startup_loading_plugin-0.4.0/src/dash_startup_loading_plugin/examples/__init__.py +5 -0
- dash_startup_loading_plugin-0.4.0/src/dash_startup_loading_plugin/examples/__main__.py +5 -0
- dash_startup_loading_plugin-0.4.0/src/dash_startup_loading_plugin/examples/antd.py +109 -0
- dash_startup_loading_plugin-0.4.0/src/dash_startup_loading_plugin/examples/basic.py +49 -0
- dash_startup_loading_plugin-0.4.0/src/dash_startup_loading_plugin/examples/cli.py +89 -0
- dash_startup_loading_plugin-0.4.0/src/dash_startup_loading_plugin/examples/fac.py +110 -0
- dash_startup_loading_plugin-0.4.0/src/dash_startup_loading_plugin/examples/mantine.py +79 -0
- dash_startup_loading_plugin-0.4.0/src/dash_startup_loading_plugin/examples/shared.py +33 -0
- {dash_startup_loading_plugin-0.3.0 → dash_startup_loading_plugin-0.4.0}/src/dash_startup_loading_plugin/plugin.py +47 -26
- dash_startup_loading_plugin-0.4.0/src/dash_startup_loading_plugin/resources/loading.css +64 -0
- dash_startup_loading_plugin-0.3.0/src/dash_startup_loading_plugin/resources/startup-loading.js → dash_startup_loading_plugin-0.4.0/src/dash_startup_loading_plugin/resources/loading.js +6 -6
- dash_startup_loading_plugin-0.3.0/src/dash_startup_loading_plugin/resources/startup-theme.js → dash_startup_loading_plugin-0.4.0/src/dash_startup_loading_plugin/resources/theme.js +2 -2
- {dash_startup_loading_plugin-0.3.0 → dash_startup_loading_plugin-0.4.0/src/dash_startup_loading_plugin.egg-info}/PKG-INFO +102 -28
- dash_startup_loading_plugin-0.4.0/src/dash_startup_loading_plugin.egg-info/SOURCES.txt +24 -0
- dash_startup_loading_plugin-0.4.0/src/dash_startup_loading_plugin.egg-info/entry_points.txt +5 -0
- dash_startup_loading_plugin-0.4.0/src/dash_startup_loading_plugin.egg-info/requires.txt +1 -0
- dash_startup_loading_plugin-0.4.0/tests/test_examples.py +150 -0
- {dash_startup_loading_plugin-0.3.0 → dash_startup_loading_plugin-0.4.0}/tests/test_plugin.py +64 -23
- dash_startup_loading_plugin-0.3.0/src/dash_startup_loading_plugin/resources/startup-loading.css +0 -64
- dash_startup_loading_plugin-0.3.0/src/dash_startup_loading_plugin.egg-info/SOURCES.txt +0 -15
- dash_startup_loading_plugin-0.3.0/src/dash_startup_loading_plugin.egg-info/entry_points.txt +0 -2
- dash_startup_loading_plugin-0.3.0/src/dash_startup_loading_plugin.egg-info/requires.txt +0 -7
- {dash_startup_loading_plugin-0.3.0 → dash_startup_loading_plugin-0.4.0}/LICENSE +0 -0
- {dash_startup_loading_plugin-0.3.0 → dash_startup_loading_plugin-0.4.0}/setup.cfg +0 -0
- {dash_startup_loading_plugin-0.3.0 → dash_startup_loading_plugin-0.4.0}/src/dash_startup_loading_plugin.egg-info/dependency_links.txt +0 -0
- {dash_startup_loading_plugin-0.3.0 → dash_startup_loading_plugin-0.4.0}/src/dash_startup_loading_plugin.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dash-startup-loading-plugin
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: A configurable full-screen startup loading overlay for Dash apps, packaged as a Dash Hooks plugin.
|
|
5
5
|
Author-email: Ethan Zhang <ethan.zhang2016@gmail.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -9,11 +9,7 @@ Classifier: Framework :: Dash
|
|
|
9
9
|
Requires-Python: >=3.9
|
|
10
10
|
Description-Content-Type: text/markdown
|
|
11
11
|
License-File: LICENSE
|
|
12
|
-
Requires-Dist: dash
|
|
13
|
-
Provides-Extra: test
|
|
14
|
-
Requires-Dist: pytest>=8; extra == "test"
|
|
15
|
-
Provides-Extra: mantine
|
|
16
|
-
Requires-Dist: dash-mantine-components>=2.6.0; extra == "mantine"
|
|
12
|
+
Requires-Dist: dash>=3.0.3
|
|
17
13
|
Dynamic: license-file
|
|
18
14
|
|
|
19
15
|
# dash-startup-loading-plugin
|
|
@@ -53,7 +49,7 @@ discovery, resource hooks, and the index hook described in the official
|
|
|
53
49
|
## Installation
|
|
54
50
|
|
|
55
51
|
```bash
|
|
56
|
-
pip install "dash-startup-loading-plugin>=0.
|
|
52
|
+
pip install "dash-startup-loading-plugin>=0.4.0"
|
|
57
53
|
```
|
|
58
54
|
|
|
59
55
|
The package declares the following entry point:
|
|
@@ -68,7 +64,13 @@ package therefore enables the default startup overlay for Dash applications in
|
|
|
68
64
|
that Python environment; an explicit import is only needed when changing its
|
|
69
65
|
configuration or using its Python API.
|
|
70
66
|
|
|
71
|
-
|
|
67
|
+
When `dash_antd_components` from Dash Ant Design is installed in the same
|
|
68
|
+
environment, the plugin detects it during automatic hook discovery and applies
|
|
69
|
+
the matching `#ffffff` and `#121212` loading backgrounds. Dash Ant Design
|
|
70
|
+
applications therefore only need to install this plugin; calling
|
|
71
|
+
`configure_antd()` is optional and is reserved for explicit overrides.
|
|
72
|
+
|
|
73
|
+
## What's new in 0.4.0
|
|
72
74
|
|
|
73
75
|
- Adds `configure_antd()` with matching `#ffffff` and `#121212` loading
|
|
74
76
|
backgrounds plus explicit light/dark overrides.
|
|
@@ -77,6 +79,9 @@ configuration or using its Python API.
|
|
|
77
79
|
- Updates the Dash Ant Design example for the structured
|
|
78
80
|
`ConfigProvider.theme.algorithm` API.
|
|
79
81
|
- Adds a Dash Mantine Components example with persisted theme switching.
|
|
82
|
+
- Adds `configure_fac()` and a feffery-antd-components example.
|
|
83
|
+
- Uses one shared set of display copy across all packaged examples.
|
|
84
|
+
- Supports Dash versions from 3.0.3 onward.
|
|
80
85
|
|
|
81
86
|
## What's new in 0.2.0
|
|
82
87
|
|
|
@@ -131,17 +136,57 @@ app.layout = html.Div(
|
|
|
131
136
|
)
|
|
132
137
|
```
|
|
133
138
|
|
|
134
|
-
|
|
139
|
+
## Installed demos
|
|
140
|
+
|
|
141
|
+
The example applications are included in the installed Python package. Select a
|
|
142
|
+
packaged example with the `dash-startup-loading-plugin` command:
|
|
143
|
+
|
|
144
|
+
Component libraries are not dependencies of this plugin. Install the library
|
|
145
|
+
used by the selected example separately:
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
pip install dash-mantine-components
|
|
149
|
+
pip install dash-ant-design
|
|
150
|
+
pip install "feffery-antd-components>=0.4.0"
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
If the selected component library cannot be imported, the command exits with
|
|
154
|
+
an error naming the failed import and the package to install.
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
# Framework-neutral Dash
|
|
158
|
+
dash-startup-loading-plugin examples.dash
|
|
159
|
+
|
|
160
|
+
# Dash Mantine Components
|
|
161
|
+
dash-startup-loading-plugin examples.dash-mantine-components
|
|
162
|
+
|
|
163
|
+
# Dash Ant Design
|
|
164
|
+
dash-startup-loading-plugin examples.dash-ant-design
|
|
165
|
+
|
|
166
|
+
# feffery-antd-components
|
|
167
|
+
dash-startup-loading-plugin examples.feffery-antd-components
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
Server options can be supplied directly:
|
|
135
171
|
|
|
136
|
-
|
|
137
|
-
-
|
|
138
|
-
|
|
172
|
+
```bash
|
|
173
|
+
dash-startup-loading-plugin examples.dash-mantine-components \
|
|
174
|
+
--host 0.0.0.0 --port 8050 --debug
|
|
175
|
+
```
|
|
139
176
|
|
|
140
|
-
|
|
177
|
+
The same launcher is available through Python when a console-script path is not
|
|
178
|
+
available:
|
|
141
179
|
|
|
142
180
|
```bash
|
|
143
|
-
|
|
144
|
-
|
|
181
|
+
python -m dash_startup_loading_plugin.examples examples.dash-mantine-components
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
Application code can create a selected demo without starting its server:
|
|
185
|
+
|
|
186
|
+
```python
|
|
187
|
+
from dash_startup_loading_plugin.examples import create_demo_app
|
|
188
|
+
|
|
189
|
+
app = create_demo_app("dash-mantine-components")
|
|
145
190
|
```
|
|
146
191
|
|
|
147
192
|
## Readiness behavior
|
|
@@ -172,7 +217,7 @@ immutable `StartupLoadingConfig` instance.
|
|
|
172
217
|
| Option | Default | Description |
|
|
173
218
|
|---|---:|---|
|
|
174
219
|
| `enabled` | `True` | Inject the startup overlay. Set to `False` to disable it. |
|
|
175
|
-
| `overlay_id` | `"dash-
|
|
220
|
+
| `overlay_id` | `"dash-loading"` | HTML `id` of the injected overlay; also used by the browser API. |
|
|
176
221
|
| `aria_label` | `"Loading"` | Accessible label on the overlay's `role="status"` element. |
|
|
177
222
|
| `root_selector` | `"#react-entry-point"` | Dash renderer root observed for mounted content. |
|
|
178
223
|
| `required_selectors` | `("#react-entry-point",)` | Iterable of document-level CSS selectors that must all exist. A single string is not accepted. |
|
|
@@ -207,7 +252,7 @@ in this order:
|
|
|
207
252
|
followed by the common `theme`, `color-theme`, and `color-scheme` keys.
|
|
208
253
|
6. `prefers-color-scheme`.
|
|
209
254
|
|
|
210
|
-
The result is written to `data-dash-
|
|
255
|
+
The result is written to `data-dash-loading-theme` before the body is
|
|
211
256
|
parsed. This isolates the overlay styling without changing classes or data
|
|
212
257
|
attributes owned by Tailwind, Dash Mantine Components, or the application.
|
|
213
258
|
The stylesheet also adjusts its animation for `prefers-reduced-motion`.
|
|
@@ -238,9 +283,8 @@ app.layout = dmc.MantineProvider(
|
|
|
238
283
|
)
|
|
239
284
|
```
|
|
240
285
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
for the complete runnable example.
|
|
286
|
+
Run `dash-startup-loading-plugin examples.dash-mantine-components` for the
|
|
287
|
+
complete example.
|
|
244
288
|
|
|
245
289
|
`configure_mantine()` keeps DMC optional. When used, it registers DMC's
|
|
246
290
|
pre-render color-scheme hook, disables the Dash Ant Design placeholder check,
|
|
@@ -310,8 +354,34 @@ configure_antd(
|
|
|
310
354
|
)
|
|
311
355
|
```
|
|
312
356
|
|
|
313
|
-
|
|
314
|
-
|
|
357
|
+
Run `dash-startup-loading-plugin examples.dash-ant-design` for the complete
|
|
358
|
+
switcher.
|
|
359
|
+
|
|
360
|
+
### feffery-antd-components persistence
|
|
361
|
+
|
|
362
|
+
FAC 0.4 and later supports Dash 3 and exposes Ant Design's theme algorithm
|
|
363
|
+
through `AntdConfigProvider.algorithm`. Use `configure_fac()` before creating
|
|
364
|
+
the app, persist a semantic system/light/dark selection, and return either
|
|
365
|
+
`"default"` or `"dark"` to the provider:
|
|
366
|
+
|
|
367
|
+
```python
|
|
368
|
+
import feffery_antd_components as fac
|
|
369
|
+
from dash import Dash
|
|
370
|
+
from dash_startup_loading_plugin import configure_fac
|
|
371
|
+
|
|
372
|
+
configure_fac(required_selectors=["#fac-app-ready"])
|
|
373
|
+
|
|
374
|
+
app = Dash(__name__)
|
|
375
|
+
app.layout = fac.AntdConfigProvider(
|
|
376
|
+
fac.AntdButton("Example component", id="fac-app-ready"),
|
|
377
|
+
id="fac-theme-provider",
|
|
378
|
+
algorithm="default",
|
|
379
|
+
)
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
Run `dash-startup-loading-plugin examples.feffery-antd-components` for the
|
|
383
|
+
complete persisted-theme example. FAC remains an external dependency and is
|
|
384
|
+
imported only when that example is selected.
|
|
315
385
|
|
|
316
386
|
### Custom loader markup
|
|
317
387
|
|
|
@@ -339,6 +409,7 @@ from dash_startup_loading_plugin import (
|
|
|
339
409
|
StartupLoadingConfig,
|
|
340
410
|
configure,
|
|
341
411
|
configure_antd,
|
|
412
|
+
configure_fac,
|
|
342
413
|
configure_mantine,
|
|
343
414
|
get_config,
|
|
344
415
|
reset_config,
|
|
@@ -347,7 +418,10 @@ from dash_startup_loading_plugin import (
|
|
|
347
418
|
|
|
348
419
|
- `configure(**changes)` validates and applies a partial configuration update.
|
|
349
420
|
- `configure_antd(**changes)` matches the loading backgrounds to Dash Ant
|
|
350
|
-
Design's light and dark themes
|
|
421
|
+
Design's light and dark themes. Installed Dash Ant Design is detected
|
|
422
|
+
automatically, so this helper is only needed for explicit overrides.
|
|
423
|
+
- `configure_fac(**changes)` applies the equivalent light and dark loading
|
|
424
|
+
backgrounds for feffery-antd-components.
|
|
351
425
|
- `configure_mantine(**changes)` applies DMC theme defaults and registers DMC's
|
|
352
426
|
pre-render color-scheme hook.
|
|
353
427
|
- `get_config()` returns the current immutable configuration.
|
|
@@ -363,21 +437,21 @@ The plugin exposes two methods for integrations that need explicit control:
|
|
|
363
437
|
|
|
364
438
|
```javascript
|
|
365
439
|
// Recheck the configured readiness conditions.
|
|
366
|
-
window.
|
|
440
|
+
window.dashLoading.check();
|
|
367
441
|
|
|
368
442
|
// Begin a manual dismissal.
|
|
369
|
-
window.
|
|
443
|
+
window.dashLoading.finish();
|
|
370
444
|
|
|
371
445
|
// A custom overlay_id can be supplied to either method.
|
|
372
|
-
window.
|
|
446
|
+
window.dashLoading.finish("my-loading-overlay");
|
|
373
447
|
```
|
|
374
448
|
|
|
375
449
|
Before fading out, the overlay dispatches a bubbling
|
|
376
|
-
`dash-
|
|
450
|
+
`dash-loading:ready` event. Its `detail.reason` is `"ready"`,
|
|
377
451
|
`"timeout"`, or `"manual"`:
|
|
378
452
|
|
|
379
453
|
```javascript
|
|
380
|
-
document.addEventListener("dash-
|
|
454
|
+
document.addEventListener("dash-loading:ready", function (event) {
|
|
381
455
|
console.log("Startup overlay finished:", event.detail.reason);
|
|
382
456
|
});
|
|
383
457
|
```
|
|
@@ -35,7 +35,7 @@ discovery, resource hooks, and the index hook described in the official
|
|
|
35
35
|
## Installation
|
|
36
36
|
|
|
37
37
|
```bash
|
|
38
|
-
pip install "dash-startup-loading-plugin>=0.
|
|
38
|
+
pip install "dash-startup-loading-plugin>=0.4.0"
|
|
39
39
|
```
|
|
40
40
|
|
|
41
41
|
The package declares the following entry point:
|
|
@@ -50,7 +50,13 @@ package therefore enables the default startup overlay for Dash applications in
|
|
|
50
50
|
that Python environment; an explicit import is only needed when changing its
|
|
51
51
|
configuration or using its Python API.
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
When `dash_antd_components` from Dash Ant Design is installed in the same
|
|
54
|
+
environment, the plugin detects it during automatic hook discovery and applies
|
|
55
|
+
the matching `#ffffff` and `#121212` loading backgrounds. Dash Ant Design
|
|
56
|
+
applications therefore only need to install this plugin; calling
|
|
57
|
+
`configure_antd()` is optional and is reserved for explicit overrides.
|
|
58
|
+
|
|
59
|
+
## What's new in 0.4.0
|
|
54
60
|
|
|
55
61
|
- Adds `configure_antd()` with matching `#ffffff` and `#121212` loading
|
|
56
62
|
backgrounds plus explicit light/dark overrides.
|
|
@@ -59,6 +65,9 @@ configuration or using its Python API.
|
|
|
59
65
|
- Updates the Dash Ant Design example for the structured
|
|
60
66
|
`ConfigProvider.theme.algorithm` API.
|
|
61
67
|
- Adds a Dash Mantine Components example with persisted theme switching.
|
|
68
|
+
- Adds `configure_fac()` and a feffery-antd-components example.
|
|
69
|
+
- Uses one shared set of display copy across all packaged examples.
|
|
70
|
+
- Supports Dash versions from 3.0.3 onward.
|
|
62
71
|
|
|
63
72
|
## What's new in 0.2.0
|
|
64
73
|
|
|
@@ -113,17 +122,57 @@ app.layout = html.Div(
|
|
|
113
122
|
)
|
|
114
123
|
```
|
|
115
124
|
|
|
116
|
-
|
|
125
|
+
## Installed demos
|
|
126
|
+
|
|
127
|
+
The example applications are included in the installed Python package. Select a
|
|
128
|
+
packaged example with the `dash-startup-loading-plugin` command:
|
|
129
|
+
|
|
130
|
+
Component libraries are not dependencies of this plugin. Install the library
|
|
131
|
+
used by the selected example separately:
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
pip install dash-mantine-components
|
|
135
|
+
pip install dash-ant-design
|
|
136
|
+
pip install "feffery-antd-components>=0.4.0"
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
If the selected component library cannot be imported, the command exits with
|
|
140
|
+
an error naming the failed import and the package to install.
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
# Framework-neutral Dash
|
|
144
|
+
dash-startup-loading-plugin examples.dash
|
|
145
|
+
|
|
146
|
+
# Dash Mantine Components
|
|
147
|
+
dash-startup-loading-plugin examples.dash-mantine-components
|
|
148
|
+
|
|
149
|
+
# Dash Ant Design
|
|
150
|
+
dash-startup-loading-plugin examples.dash-ant-design
|
|
151
|
+
|
|
152
|
+
# feffery-antd-components
|
|
153
|
+
dash-startup-loading-plugin examples.feffery-antd-components
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Server options can be supplied directly:
|
|
117
157
|
|
|
118
|
-
|
|
119
|
-
-
|
|
120
|
-
|
|
158
|
+
```bash
|
|
159
|
+
dash-startup-loading-plugin examples.dash-mantine-components \
|
|
160
|
+
--host 0.0.0.0 --port 8050 --debug
|
|
161
|
+
```
|
|
121
162
|
|
|
122
|
-
|
|
163
|
+
The same launcher is available through Python when a console-script path is not
|
|
164
|
+
available:
|
|
123
165
|
|
|
124
166
|
```bash
|
|
125
|
-
|
|
126
|
-
|
|
167
|
+
python -m dash_startup_loading_plugin.examples examples.dash-mantine-components
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
Application code can create a selected demo without starting its server:
|
|
171
|
+
|
|
172
|
+
```python
|
|
173
|
+
from dash_startup_loading_plugin.examples import create_demo_app
|
|
174
|
+
|
|
175
|
+
app = create_demo_app("dash-mantine-components")
|
|
127
176
|
```
|
|
128
177
|
|
|
129
178
|
## Readiness behavior
|
|
@@ -154,7 +203,7 @@ immutable `StartupLoadingConfig` instance.
|
|
|
154
203
|
| Option | Default | Description |
|
|
155
204
|
|---|---:|---|
|
|
156
205
|
| `enabled` | `True` | Inject the startup overlay. Set to `False` to disable it. |
|
|
157
|
-
| `overlay_id` | `"dash-
|
|
206
|
+
| `overlay_id` | `"dash-loading"` | HTML `id` of the injected overlay; also used by the browser API. |
|
|
158
207
|
| `aria_label` | `"Loading"` | Accessible label on the overlay's `role="status"` element. |
|
|
159
208
|
| `root_selector` | `"#react-entry-point"` | Dash renderer root observed for mounted content. |
|
|
160
209
|
| `required_selectors` | `("#react-entry-point",)` | Iterable of document-level CSS selectors that must all exist. A single string is not accepted. |
|
|
@@ -189,7 +238,7 @@ in this order:
|
|
|
189
238
|
followed by the common `theme`, `color-theme`, and `color-scheme` keys.
|
|
190
239
|
6. `prefers-color-scheme`.
|
|
191
240
|
|
|
192
|
-
The result is written to `data-dash-
|
|
241
|
+
The result is written to `data-dash-loading-theme` before the body is
|
|
193
242
|
parsed. This isolates the overlay styling without changing classes or data
|
|
194
243
|
attributes owned by Tailwind, Dash Mantine Components, or the application.
|
|
195
244
|
The stylesheet also adjusts its animation for `prefers-reduced-motion`.
|
|
@@ -220,9 +269,8 @@ app.layout = dmc.MantineProvider(
|
|
|
220
269
|
)
|
|
221
270
|
```
|
|
222
271
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
for the complete runnable example.
|
|
272
|
+
Run `dash-startup-loading-plugin examples.dash-mantine-components` for the
|
|
273
|
+
complete example.
|
|
226
274
|
|
|
227
275
|
`configure_mantine()` keeps DMC optional. When used, it registers DMC's
|
|
228
276
|
pre-render color-scheme hook, disables the Dash Ant Design placeholder check,
|
|
@@ -292,8 +340,34 @@ configure_antd(
|
|
|
292
340
|
)
|
|
293
341
|
```
|
|
294
342
|
|
|
295
|
-
|
|
296
|
-
|
|
343
|
+
Run `dash-startup-loading-plugin examples.dash-ant-design` for the complete
|
|
344
|
+
switcher.
|
|
345
|
+
|
|
346
|
+
### feffery-antd-components persistence
|
|
347
|
+
|
|
348
|
+
FAC 0.4 and later supports Dash 3 and exposes Ant Design's theme algorithm
|
|
349
|
+
through `AntdConfigProvider.algorithm`. Use `configure_fac()` before creating
|
|
350
|
+
the app, persist a semantic system/light/dark selection, and return either
|
|
351
|
+
`"default"` or `"dark"` to the provider:
|
|
352
|
+
|
|
353
|
+
```python
|
|
354
|
+
import feffery_antd_components as fac
|
|
355
|
+
from dash import Dash
|
|
356
|
+
from dash_startup_loading_plugin import configure_fac
|
|
357
|
+
|
|
358
|
+
configure_fac(required_selectors=["#fac-app-ready"])
|
|
359
|
+
|
|
360
|
+
app = Dash(__name__)
|
|
361
|
+
app.layout = fac.AntdConfigProvider(
|
|
362
|
+
fac.AntdButton("Example component", id="fac-app-ready"),
|
|
363
|
+
id="fac-theme-provider",
|
|
364
|
+
algorithm="default",
|
|
365
|
+
)
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
Run `dash-startup-loading-plugin examples.feffery-antd-components` for the
|
|
369
|
+
complete persisted-theme example. FAC remains an external dependency and is
|
|
370
|
+
imported only when that example is selected.
|
|
297
371
|
|
|
298
372
|
### Custom loader markup
|
|
299
373
|
|
|
@@ -321,6 +395,7 @@ from dash_startup_loading_plugin import (
|
|
|
321
395
|
StartupLoadingConfig,
|
|
322
396
|
configure,
|
|
323
397
|
configure_antd,
|
|
398
|
+
configure_fac,
|
|
324
399
|
configure_mantine,
|
|
325
400
|
get_config,
|
|
326
401
|
reset_config,
|
|
@@ -329,7 +404,10 @@ from dash_startup_loading_plugin import (
|
|
|
329
404
|
|
|
330
405
|
- `configure(**changes)` validates and applies a partial configuration update.
|
|
331
406
|
- `configure_antd(**changes)` matches the loading backgrounds to Dash Ant
|
|
332
|
-
Design's light and dark themes
|
|
407
|
+
Design's light and dark themes. Installed Dash Ant Design is detected
|
|
408
|
+
automatically, so this helper is only needed for explicit overrides.
|
|
409
|
+
- `configure_fac(**changes)` applies the equivalent light and dark loading
|
|
410
|
+
backgrounds for feffery-antd-components.
|
|
333
411
|
- `configure_mantine(**changes)` applies DMC theme defaults and registers DMC's
|
|
334
412
|
pre-render color-scheme hook.
|
|
335
413
|
- `get_config()` returns the current immutable configuration.
|
|
@@ -345,21 +423,21 @@ The plugin exposes two methods for integrations that need explicit control:
|
|
|
345
423
|
|
|
346
424
|
```javascript
|
|
347
425
|
// Recheck the configured readiness conditions.
|
|
348
|
-
window.
|
|
426
|
+
window.dashLoading.check();
|
|
349
427
|
|
|
350
428
|
// Begin a manual dismissal.
|
|
351
|
-
window.
|
|
429
|
+
window.dashLoading.finish();
|
|
352
430
|
|
|
353
431
|
// A custom overlay_id can be supplied to either method.
|
|
354
|
-
window.
|
|
432
|
+
window.dashLoading.finish("my-loading-overlay");
|
|
355
433
|
```
|
|
356
434
|
|
|
357
435
|
Before fading out, the overlay dispatches a bubbling
|
|
358
|
-
`dash-
|
|
436
|
+
`dash-loading:ready` event. Its `detail.reason` is `"ready"`,
|
|
359
437
|
`"timeout"`, or `"manual"`:
|
|
360
438
|
|
|
361
439
|
```javascript
|
|
362
|
-
document.addEventListener("dash-
|
|
440
|
+
document.addEventListener("dash-loading:ready", function (event) {
|
|
363
441
|
console.log("Startup overlay finished:", event.detail.reason);
|
|
364
442
|
});
|
|
365
443
|
```
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "dash-startup-loading-plugin"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.4.0"
|
|
8
8
|
description = "A configurable full-screen startup loading overlay for Dash apps, packaged as a Dash Hooks plugin."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.9"
|
|
@@ -16,16 +16,16 @@ classifiers = ["Framework :: Dash"]
|
|
|
16
16
|
license = "MIT"
|
|
17
17
|
license-files = ["LICENSE"]
|
|
18
18
|
dependencies = [
|
|
19
|
-
"dash
|
|
19
|
+
"dash>=3.0.3",
|
|
20
20
|
]
|
|
21
21
|
|
|
22
|
-
[
|
|
22
|
+
[dependency-groups]
|
|
23
23
|
test = [
|
|
24
24
|
"pytest>=8",
|
|
25
25
|
]
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
|
|
27
|
+
[project.scripts]
|
|
28
|
+
dash-startup-loading-plugin = "dash_startup_loading_plugin.examples:main"
|
|
29
29
|
|
|
30
30
|
[project.entry-points."dash_hooks"]
|
|
31
31
|
dash_startup_loading_plugin = "dash_startup_loading_plugin"
|
|
@@ -5,12 +5,13 @@ from importlib.metadata import PackageNotFoundError, version
|
|
|
5
5
|
try:
|
|
6
6
|
__version__ = version("dash-startup-loading-plugin")
|
|
7
7
|
except PackageNotFoundError: # pragma: no cover - source tree fallback
|
|
8
|
-
__version__ = "0.
|
|
8
|
+
__version__ = "0.4.0"
|
|
9
9
|
|
|
10
10
|
from .plugin import (
|
|
11
11
|
StartupLoadingConfig,
|
|
12
12
|
configure,
|
|
13
13
|
configure_antd,
|
|
14
|
+
configure_fac,
|
|
14
15
|
configure_mantine,
|
|
15
16
|
get_config,
|
|
16
17
|
reset_config,
|
|
@@ -21,6 +22,7 @@ __all__ = [
|
|
|
21
22
|
"__version__",
|
|
22
23
|
"configure",
|
|
23
24
|
"configure_antd",
|
|
25
|
+
"configure_fac",
|
|
24
26
|
"configure_mantine",
|
|
25
27
|
"get_config",
|
|
26
28
|
"reset_config",
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"""Dash Ant Design theme persistence demonstration."""
|
|
2
|
+
|
|
3
|
+
from dash import Dash, Input, Output, clientside_callback, html
|
|
4
|
+
|
|
5
|
+
from ..plugin import configure_antd
|
|
6
|
+
from .cli import DemoDependencyError
|
|
7
|
+
from .shared import (
|
|
8
|
+
DEMO_ACTION_TEXT,
|
|
9
|
+
DEMO_DESCRIPTION,
|
|
10
|
+
DEMO_READY_TEXT,
|
|
11
|
+
DEMO_READY_TITLE,
|
|
12
|
+
DEMO_TITLE,
|
|
13
|
+
MAIN_STYLE,
|
|
14
|
+
PANEL_STYLE,
|
|
15
|
+
THEME_OPTIONS,
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def create_app() -> Dash:
|
|
20
|
+
"""Create the Dash Ant Design example application."""
|
|
21
|
+
|
|
22
|
+
try:
|
|
23
|
+
import dash_antd_components as dac
|
|
24
|
+
except ModuleNotFoundError as error:
|
|
25
|
+
if error.name != "dash_antd_components":
|
|
26
|
+
raise
|
|
27
|
+
raise DemoDependencyError(
|
|
28
|
+
"Failed to import dash_antd_components. "
|
|
29
|
+
"Install it with: pip install dash-ant-design"
|
|
30
|
+
) from error
|
|
31
|
+
|
|
32
|
+
configure_antd(
|
|
33
|
+
required_selectors=["#antd-app-ready"],
|
|
34
|
+
minimum_display_ms=250,
|
|
35
|
+
fade_duration_ms=180,
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
app = Dash(__name__)
|
|
39
|
+
app.layout = dac.ConfigProvider(
|
|
40
|
+
html.Main(
|
|
41
|
+
[
|
|
42
|
+
html.H1(DEMO_TITLE),
|
|
43
|
+
html.P(DEMO_DESCRIPTION),
|
|
44
|
+
dac.Segmented(
|
|
45
|
+
id="theme-mode",
|
|
46
|
+
options=THEME_OPTIONS,
|
|
47
|
+
value="system",
|
|
48
|
+
block=True,
|
|
49
|
+
persistence=True,
|
|
50
|
+
persisted_props=["value"],
|
|
51
|
+
persistence_type="local",
|
|
52
|
+
),
|
|
53
|
+
html.Section(
|
|
54
|
+
[
|
|
55
|
+
html.H2(DEMO_READY_TITLE),
|
|
56
|
+
html.P(DEMO_READY_TEXT),
|
|
57
|
+
html.Button(DEMO_ACTION_TEXT),
|
|
58
|
+
],
|
|
59
|
+
style=PANEL_STYLE,
|
|
60
|
+
),
|
|
61
|
+
],
|
|
62
|
+
id="antd-app-ready",
|
|
63
|
+
style=MAIN_STYLE,
|
|
64
|
+
),
|
|
65
|
+
id="theme-provider",
|
|
66
|
+
theme={"algorithm": "default"},
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
clientside_callback(
|
|
70
|
+
"""function(mode) {
|
|
71
|
+
const selected = mode || "system";
|
|
72
|
+
const media = window.matchMedia("(prefers-color-scheme: dark)");
|
|
73
|
+
|
|
74
|
+
try {
|
|
75
|
+
localStorage.setItem("theme", JSON.stringify(selected));
|
|
76
|
+
} catch (_) {}
|
|
77
|
+
|
|
78
|
+
function applyDocumentScheme(dark) {
|
|
79
|
+
document.documentElement.style.colorScheme = dark ? "dark" : "light";
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const dark = selected === "dark"
|
|
83
|
+
|| (selected === "system" && media.matches);
|
|
84
|
+
applyDocumentScheme(dark);
|
|
85
|
+
|
|
86
|
+
if (!window.__dashLoadingAntdThemeListener) {
|
|
87
|
+
window.__dashLoadingAntdThemeListener = function(event) {
|
|
88
|
+
let current = "system";
|
|
89
|
+
try {
|
|
90
|
+
current = JSON.parse(localStorage.getItem("theme")) || "system";
|
|
91
|
+
} catch (_) {}
|
|
92
|
+
if (current !== "system") return;
|
|
93
|
+
applyDocumentScheme(event.matches);
|
|
94
|
+
dash_clientside.set_props("theme-provider", {
|
|
95
|
+
theme: {algorithm: event.matches ? "dark" : "default"}
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
media.addEventListener(
|
|
99
|
+
"change",
|
|
100
|
+
window.__dashLoadingAntdThemeListener
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return {algorithm: dark ? "dark" : "default"};
|
|
105
|
+
}""",
|
|
106
|
+
Output("theme-provider", "theme"),
|
|
107
|
+
Input("theme-mode", "value"),
|
|
108
|
+
)
|
|
109
|
+
return app
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"""Framework-neutral Dash demonstration."""
|
|
2
|
+
|
|
3
|
+
from dash import Dash, html
|
|
4
|
+
|
|
5
|
+
from ..plugin import configure
|
|
6
|
+
from .shared import (
|
|
7
|
+
DEMO_ACTION_TEXT,
|
|
8
|
+
DEMO_DESCRIPTION,
|
|
9
|
+
DEMO_READY_TEXT,
|
|
10
|
+
DEMO_READY_TITLE,
|
|
11
|
+
DEMO_TITLE,
|
|
12
|
+
MAIN_STYLE,
|
|
13
|
+
PANEL_STYLE,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def create_app() -> Dash:
|
|
18
|
+
"""Create the framework-neutral example application."""
|
|
19
|
+
|
|
20
|
+
configure(
|
|
21
|
+
required_selectors=["#dash-app-ready"],
|
|
22
|
+
minimum_display_ms=250,
|
|
23
|
+
fade_duration_ms=180,
|
|
24
|
+
theme_mode="light",
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
app = Dash(__name__)
|
|
28
|
+
app.layout = html.Main(
|
|
29
|
+
[
|
|
30
|
+
html.H1(DEMO_TITLE),
|
|
31
|
+
html.P(DEMO_DESCRIPTION),
|
|
32
|
+
html.Section(
|
|
33
|
+
[
|
|
34
|
+
html.H2(DEMO_READY_TITLE),
|
|
35
|
+
html.P(DEMO_READY_TEXT),
|
|
36
|
+
html.Button(DEMO_ACTION_TEXT),
|
|
37
|
+
],
|
|
38
|
+
style=PANEL_STYLE,
|
|
39
|
+
),
|
|
40
|
+
],
|
|
41
|
+
id="dash-app-ready",
|
|
42
|
+
style=MAIN_STYLE
|
|
43
|
+
| {
|
|
44
|
+
"color": "#212529",
|
|
45
|
+
"background": "#ffffff",
|
|
46
|
+
"colorScheme": "light",
|
|
47
|
+
},
|
|
48
|
+
)
|
|
49
|
+
return app
|