athena-ui-js 2.1.0 → 2.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.
Files changed (33) hide show
  1. package/README.md +81 -3
  2. package/docs/styling.md +21 -6
  3. package/package.json +9 -1
  4. package/src/athena-ui.js +4 -1
  5. package/src/libs/config/config.js +1 -1
  6. package/src/libs/core/gridLayout.js +102 -0
  7. package/src/libs/core/i18n.js +32 -0
  8. package/src/libs/core/motion.js +358 -0
  9. package/src/libs/core/theme.js +12 -0
  10. package/src/libs/hephaestus/chartGenerator/chartGenerator.js +9 -5
  11. package/src/libs/hephaestus/componentGenerator/componentGenerator.js +17 -0
  12. package/src/libs/hephaestus/dialogGenerator/dialogGenerator.js +2 -1
  13. package/src/libs/hephaestus/feedbackGenerator/feedbackGenerator.js +3 -1
  14. package/src/libs/hephaestus/router/router.js +18 -9
  15. package/src/libs/hephaestus/tableGenerator/tableGenerator.js +25 -0
  16. package/src/motion.js +6 -0
  17. package/src/res/themes/default/style.css +413 -10
  18. package/src/res/themes/tokens.css +25 -0
  19. package/src/widgets.js +7 -0
  20. package/types/athena-ui.d.ts +99 -96
  21. package/types/libs/config/config.d.ts +3 -3
  22. package/types/libs/core/gridLayout.d.ts +45 -0
  23. package/types/libs/core/motion.d.ts +123 -0
  24. package/types/libs/core/popover.d.ts +36 -36
  25. package/types/libs/core/theme.d.ts +2 -0
  26. package/types/libs/hephaestus/chartGenerator/chartGenerator.d.ts +2 -0
  27. package/types/libs/hephaestus/componentGenerator/componentGenerator.d.ts +238 -224
  28. package/types/libs/hephaestus/navigationGenerator/navigationGenerator.d.ts +153 -153
  29. package/types/libs/hephaestus/router/router.d.ts +4 -0
  30. package/types/libs/hephaestus/tableGenerator/tableGenerator.d.ts +3 -0
  31. package/types/libs/hephaestus/widgetGrid/widgetGrid.d.ts +117 -0
  32. package/types/motion.d.ts +1 -0
  33. package/types/widgets.d.ts +2 -0
@@ -261,7 +261,7 @@ textarea {
261
261
  border-radius: 10px;
262
262
  background-color: var(--athena-line);
263
263
  position: relative;
264
- transition: background-color 0.15s;
264
+ transition: background-color var(--athena-duration-fast) var(--athena-ease-standard);
265
265
  }
266
266
 
267
267
  .switch-track::after {
@@ -273,7 +273,7 @@ textarea {
273
273
  height: 16px;
274
274
  border-radius: 50%;
275
275
  background-color: #fff;
276
- transition: transform 0.15s;
276
+ transition: transform var(--athena-duration-fast) var(--athena-ease-standard);
277
277
  }
278
278
 
279
279
  .switch input:checked + .switch-track {
@@ -395,7 +395,7 @@ textarea {
395
395
  .progress-fill {
396
396
  height: 100%;
397
397
  background-color: var(--progress-color, var(--athena-accent));
398
- transition: width 0.2s;
398
+ transition: width var(--athena-duration-base) var(--athena-ease-standard);
399
399
  }
400
400
 
401
401
  .progress-success {
@@ -595,7 +595,7 @@ dialog.dialog::backdrop {
595
595
  .accordion-icon::before {
596
596
  content: "▾";
597
597
  display: inline-block;
598
- transition: transform 0.15s;
598
+ transition: transform var(--athena-duration-fast) var(--athena-ease-standard);
599
599
  }
600
600
 
601
601
  .accordion-item[open] > .accordion-header .accordion-icon::before,
@@ -897,7 +897,7 @@ dialog.dialog::backdrop {
897
897
  pointer-events: none;
898
898
  visibility: hidden;
899
899
  opacity: 0;
900
- transition: opacity 0.12s;
900
+ transition: opacity var(--athena-duration-fast) var(--athena-ease-standard);
901
901
  }
902
902
 
903
903
  .has-tooltip:hover > .tooltip-text,
@@ -1282,15 +1282,17 @@ dialog.dialog::backdrop {
1282
1282
  }
1283
1283
  }
1284
1284
 
1285
+ /* Reduced motion: a spinner and an indeterminate bar still have to say "busy", but slowly. The transitions read the duration tokens (0). */
1285
1286
  @media (prefers-reduced-motion: reduce) {
1286
- .spinner,
1287
- .progress-indeterminate .progress-fill {
1287
+ :root:not([data-motion="full"]) .spinner,
1288
+ :root:not([data-motion="full"]) .progress-indeterminate .progress-fill {
1288
1289
  animation-duration: 3s;
1289
1290
  }
1291
+ }
1290
1292
 
1291
- * {
1292
- transition: none !important;
1293
- }
1293
+ :root[data-motion="reduce"] .spinner,
1294
+ :root[data-motion="reduce"] .progress-indeterminate .progress-fill {
1295
+ animation-duration: 3s;
1294
1296
  }
1295
1297
 
1296
1298
  /* Menu submenus */
@@ -2156,4 +2158,405 @@ dialog.dialog::backdrop {
2156
2158
  .stat.is-warn .stat-value { color: var(--athena-warning); }
2157
2159
  .stat.is-bad .stat-value { color: var(--athena-danger); }
2158
2160
 
2161
+
2162
+ /* ------------------------------------------------------------ Motion
2163
+ Everything reads the --athena-duration-* and --athena-ease-* tokens: 0 under reduced motion. Entering uses @starting-style, leaving
2164
+ uses transition-behavior: allow-discrete, so a closed dialog or popover fades out before it is taken off the screen. A browser that
2165
+ does not know them just shows and hides without motion. */
2166
+
2167
+ dialog.dialog {
2168
+ opacity: 0;
2169
+ translate: 0 8px;
2170
+ transition:
2171
+ opacity var(--athena-duration-base) var(--athena-ease-out),
2172
+ translate var(--athena-duration-base) var(--athena-ease-out),
2173
+ overlay var(--athena-duration-base) allow-discrete,
2174
+ display var(--athena-duration-base) allow-discrete;
2175
+ }
2176
+
2177
+ dialog.dialog[open] {
2178
+ opacity: 1;
2179
+ translate: 0 0;
2180
+ }
2181
+
2182
+ dialog.dialog::backdrop {
2183
+ opacity: 0;
2184
+ transition:
2185
+ opacity var(--athena-duration-base) var(--athena-ease-out),
2186
+ overlay var(--athena-duration-base) allow-discrete,
2187
+ display var(--athena-duration-base) allow-discrete;
2188
+ }
2189
+
2190
+ dialog.dialog[open]::backdrop {
2191
+ opacity: 1;
2192
+ }
2193
+
2194
+ @starting-style {
2195
+ dialog.dialog[open] {
2196
+ opacity: 0;
2197
+ translate: 0 8px;
2198
+ }
2199
+
2200
+ dialog.dialog[open]::backdrop {
2201
+ opacity: 0;
2202
+ }
2203
+ }
2204
+
2205
+ .athena-popover[popover] {
2206
+ opacity: 0;
2207
+ scale: 0.97;
2208
+ transform-origin: top;
2209
+ transition:
2210
+ opacity var(--athena-duration-fast) var(--athena-ease-out),
2211
+ scale var(--athena-duration-fast) var(--athena-ease-out),
2212
+ overlay var(--athena-duration-fast) allow-discrete,
2213
+ display var(--athena-duration-fast) allow-discrete;
2214
+ }
2215
+
2216
+ .athena-popover[popover]:popover-open {
2217
+ opacity: 1;
2218
+ scale: 1;
2219
+ }
2220
+
2221
+ .athena-popover-above[popover] {
2222
+ transform-origin: bottom;
2223
+ }
2224
+
2225
+ @starting-style {
2226
+ .athena-popover[popover]:popover-open {
2227
+ opacity: 0;
2228
+ scale: 0.97;
2229
+ }
2230
+ }
2231
+
2232
+ /* Toasts slide in from the side, and out again when they are closed */
2233
+ .toast {
2234
+ transition:
2235
+ opacity var(--athena-duration-base) var(--athena-ease-out),
2236
+ translate var(--athena-duration-base) var(--athena-ease-out);
2237
+ }
2238
+
2239
+ @starting-style {
2240
+ .toast {
2241
+ opacity: 0;
2242
+ translate: 16px 0;
2243
+ }
2244
+ }
2245
+
2246
+ .toast.is-leaving {
2247
+ opacity: 0;
2248
+ translate: 16px 0;
2249
+ }
2250
+
2251
+ /* The panel of an accordion opens and closes smoothly (a browser without ::details-content opens it at once) */
2252
+ .accordion-item {
2253
+ interpolate-size: allow-keywords;
2254
+ }
2255
+
2256
+ .accordion-item::details-content {
2257
+ block-size: 0;
2258
+ overflow: clip;
2259
+ transition:
2260
+ block-size var(--athena-duration-base) var(--athena-ease-standard),
2261
+ content-visibility var(--athena-duration-base) allow-discrete;
2262
+ }
2263
+
2264
+ .accordion-item[open]::details-content {
2265
+ block-size: auto;
2266
+ }
2267
+
2268
+ /* The mark of the active item, and hover, move gently */
2269
+ .athena-menu .menu-control {
2270
+ transition:
2271
+ background-color var(--athena-duration-fast) var(--athena-ease-standard),
2272
+ box-shadow var(--athena-duration-fast) var(--athena-ease-standard);
2273
+ }
2274
+
2275
+ /* A place holder for what is loading: a skeleton with a shimmer (generateSkeleton) */
2276
+ .athena-skeleton {
2277
+ display: block;
2278
+ min-height: 1em;
2279
+ border-radius: var(--athena-radius);
2280
+ background: linear-gradient(90deg, var(--athena-surface) 25%, var(--athena-hover) 50%, var(--athena-surface) 75%);
2281
+ background-size: 200% 100%;
2282
+ animation: athena-shimmer 1.4s linear infinite;
2283
+ }
2284
+
2285
+ .athena-skeleton-line + .athena-skeleton-line {
2286
+ margin-top: var(--athena-space-2);
2287
+ }
2288
+
2289
+ .athena-skeleton-line:last-child:not(:only-child) {
2290
+ width: 60%;
2291
+ }
2292
+
2293
+ @keyframes athena-shimmer {
2294
+ to {
2295
+ background-position: -200% 0;
2296
+ }
2297
+ }
2298
+
2299
+ @media (prefers-reduced-motion: reduce) {
2300
+ :root:not([data-motion="full"]) .athena-skeleton {
2301
+ animation: none;
2302
+ }
2303
+ }
2304
+
2305
+ :root[data-motion="reduce"] .athena-skeleton {
2306
+ animation: none;
2307
+ }
2308
+
2309
+ /* A theme or mode change cross-fades instead of flashing (the theme manager sets the class for a moment) */
2310
+ .athena-switching,
2311
+ .athena-switching *,
2312
+ .athena-switching *::before,
2313
+ .athena-switching *::after {
2314
+ transition:
2315
+ background-color var(--athena-duration-slow) var(--athena-ease-standard),
2316
+ color var(--athena-duration-slow) var(--athena-ease-standard),
2317
+ border-color var(--athena-duration-slow) var(--athena-ease-standard),
2318
+ fill var(--athena-duration-slow) var(--athena-ease-standard),
2319
+ stroke var(--athena-duration-slow) var(--athena-ease-standard);
2320
+ }
2321
+
2322
+ /* Page transitions of the router (router({ transition: true })) */
2323
+ ::view-transition-old(root),
2324
+ ::view-transition-new(root) {
2325
+ animation-duration: var(--athena-duration-base);
2326
+ animation-timing-function: var(--athena-ease-standard);
2327
+ }
2328
+
2329
+ /* Charts draw themselves when they appear: bars grow, lines are drawn, slices pop in (only the first time, not when a chart streams or is zoomed) */
2330
+ @keyframes athena-grow {
2331
+ from {
2332
+ scale: 1 0;
2333
+ }
2334
+ }
2335
+
2336
+ @keyframes athena-draw {
2337
+ from {
2338
+ stroke-dashoffset: 1;
2339
+ }
2340
+ }
2341
+
2342
+ @keyframes athena-appear {
2343
+ from {
2344
+ opacity: 0;
2345
+ }
2346
+ }
2347
+
2348
+ @keyframes athena-pop {
2349
+ from {
2350
+ opacity: 0;
2351
+ scale: 0.6;
2352
+ }
2353
+ }
2354
+
2355
+ .athena-chart-animated .chart-bar {
2356
+ transform-box: fill-box;
2357
+ transform-origin: 50% 100%;
2358
+ animation: athena-grow var(--athena-duration-slow) var(--athena-ease-out) backwards;
2359
+ }
2360
+
2361
+ .athena-chart-animated .chart-line {
2362
+ stroke-dasharray: 1;
2363
+ animation: athena-draw var(--athena-duration-slow) var(--athena-ease-out) backwards;
2364
+ }
2365
+
2366
+ .athena-chart-animated .chart-area,
2367
+ .athena-chart-animated .chart-point {
2368
+ animation: athena-appear var(--athena-duration-slow) var(--athena-ease-out) backwards;
2369
+ }
2370
+
2371
+ .athena-chart-animated .chart-slice {
2372
+ transform-box: fill-box;
2373
+ transform-origin: center;
2374
+ animation: athena-pop var(--athena-duration-slow) var(--athena-ease-out) backwards;
2375
+ }
2376
+
2377
+
2378
+ /* ------------------------------------------------------------ Widgets
2379
+ createWidgetGrid: a CSS grid. The columns, the row height and the gap are classes (wg-cols-12, wg-rh-80, wg-gap-12) and so is the place of every
2380
+ widget (wg-x-1, wg-y-1, wg-w-3, wg-h-2), written into a constructed style sheet: no style attribute, so a strict Content-Security-Policy is fine.
2381
+ The controls of the edit mode (handle, buttons, resize edges) exist in every widget and are shown only in .is-editable. */
2382
+
2383
+ .athena-widget-grid {
2384
+ display: grid;
2385
+ position: relative;
2386
+ align-items: stretch;
2387
+ }
2388
+
2389
+ .widget {
2390
+ position: relative;
2391
+ display: flex;
2392
+ flex-direction: column;
2393
+ min-width: 0;
2394
+ min-height: 0;
2395
+ border: var(--athena-border-width) solid var(--athena-line);
2396
+ border-radius: var(--athena-radius);
2397
+ background: var(--athena-surface);
2398
+ color: var(--athena-fg);
2399
+ overflow: hidden;
2400
+ transition: box-shadow var(--athena-duration-fast) var(--athena-ease-standard), border-color var(--athena-duration-fast) var(--athena-ease-standard);
2401
+ }
2402
+
2403
+ .widget-header {
2404
+ display: flex;
2405
+ align-items: center;
2406
+ gap: 6px;
2407
+ padding: 6px 10px;
2408
+ border-bottom: var(--athena-border-width) solid var(--athena-line);
2409
+ background: var(--athena-surface-alt);
2410
+ }
2411
+
2412
+ .widget-title {
2413
+ flex: 1;
2414
+ min-width: 0;
2415
+ margin: 0;
2416
+ font-size: 0.95rem;
2417
+ font-weight: 600;
2418
+ overflow: hidden;
2419
+ text-overflow: ellipsis;
2420
+ white-space: nowrap;
2421
+ }
2422
+
2423
+ .widget-body {
2424
+ flex: 1;
2425
+ min-height: 0;
2426
+ padding: 10px;
2427
+ overflow: auto;
2428
+ }
2429
+
2430
+ .widget-note {
2431
+ margin: 0;
2432
+ color: var(--athena-muted);
2433
+ }
2434
+
2435
+ .widget.is-unknown,
2436
+ .widget.is-failed {
2437
+ border-style: dashed;
2438
+ }
2439
+
2440
+ .widget-handle,
2441
+ .widget-actions,
2442
+ .widget-resize {
2443
+ display: none;
2444
+ }
2445
+
2446
+ .widget-actions {
2447
+ gap: 2px;
2448
+ }
2449
+
2450
+ .widget-handle,
2451
+ .widget-action {
2452
+ padding: 2px 6px;
2453
+ border: var(--athena-border-width) solid transparent;
2454
+ border-radius: var(--athena-radius);
2455
+ background: transparent;
2456
+ color: var(--athena-fg);
2457
+ font: inherit;
2458
+ line-height: 1.2;
2459
+ cursor: pointer;
2460
+ }
2461
+
2462
+ .widget-handle:hover,
2463
+ .widget-action:hover {
2464
+ background: var(--athena-hover);
2465
+ }
2466
+
2467
+ .widget-handle:focus-visible,
2468
+ .widget-action:focus-visible {
2469
+ outline: var(--athena-focus-width) solid var(--athena-focus);
2470
+ outline-offset: 1px;
2471
+ }
2472
+
2473
+ .widget-handle {
2474
+ cursor: grab;
2475
+ touch-action: none;
2476
+ }
2477
+
2478
+ .widget-handle[aria-pressed="true"] {
2479
+ background: var(--athena-accent);
2480
+ color: var(--athena-accent-fg);
2481
+ }
2482
+
2483
+ .is-editable .widget-handle {
2484
+ display: inline-block;
2485
+ }
2486
+
2487
+ .is-editable .widget-actions {
2488
+ display: flex;
2489
+ }
2490
+
2491
+ .is-editable .widget {
2492
+ border-color: var(--athena-border);
2493
+ }
2494
+
2495
+ .is-editable .widget.is-locked .widget-handle,
2496
+ .is-editable .widget.is-locked .widget-resize {
2497
+ display: none;
2498
+ }
2499
+
2500
+ .is-editable .widget.is-locked .widget-title::after {
2501
+ content: " 🔒";
2502
+ }
2503
+
2504
+ .widget.is-dragging {
2505
+ z-index: 2;
2506
+ border-color: var(--athena-accent);
2507
+ box-shadow: var(--athena-shadow);
2508
+ }
2509
+
2510
+ .is-editable .widget-resize {
2511
+ display: block;
2512
+ position: absolute;
2513
+ z-index: 1;
2514
+ touch-action: none;
2515
+ }
2516
+
2517
+ .widget-resize-n,
2518
+ .widget-resize-s {
2519
+ left: 12px;
2520
+ right: 12px;
2521
+ height: 8px;
2522
+ cursor: ns-resize;
2523
+ }
2524
+
2525
+ .widget-resize-e,
2526
+ .widget-resize-w {
2527
+ top: 12px;
2528
+ bottom: 12px;
2529
+ width: 8px;
2530
+ cursor: ew-resize;
2531
+ }
2532
+
2533
+ .widget-resize-n { top: 0; }
2534
+ .widget-resize-s { bottom: 0; }
2535
+ .widget-resize-e { right: 0; }
2536
+ .widget-resize-w { left: 0; }
2537
+
2538
+ .widget-resize-ne,
2539
+ .widget-resize-nw,
2540
+ .widget-resize-se,
2541
+ .widget-resize-sw {
2542
+ width: 14px;
2543
+ height: 14px;
2544
+ }
2545
+
2546
+ .widget-resize-ne { top: 0; right: 0; cursor: nesw-resize; }
2547
+ .widget-resize-nw { top: 0; left: 0; cursor: nwse-resize; }
2548
+ .widget-resize-se { bottom: 0; right: 0; cursor: nwse-resize; }
2549
+ .widget-resize-sw { bottom: 0; left: 0; cursor: nesw-resize; }
2550
+
2551
+ .widget-resize-se::after {
2552
+ content: "";
2553
+ position: absolute;
2554
+ right: 3px;
2555
+ bottom: 3px;
2556
+ width: 8px;
2557
+ height: 8px;
2558
+ border-right: 2px solid var(--athena-muted);
2559
+ border-bottom: 2px solid var(--athena-muted);
2560
+ }
2561
+
2159
2562
  }
@@ -47,6 +47,31 @@
47
47
  --athena-dialog-medium: 480px;
48
48
  --athena-dialog-large: 720px;
49
49
  --athena-row-height: 36px; /* rows of a virtual table; generateTable({ virtual: { rowHeight } }) sets --row-height on the table */
50
+
51
+ /* motion: every transition and animation of Athena UI reads these, so one variable slows down or switches off all of it */
52
+ --athena-duration-fast: 120ms;
53
+ --athena-duration-base: 200ms;
54
+ --athena-duration-slow: 360ms;
55
+ --athena-ease-standard: cubic-bezier(0.2, 0, 0, 1);
56
+ --athena-ease-in: cubic-bezier(0.4, 0, 1, 1);
57
+ --athena-ease-out: cubic-bezier(0, 0, 0.2, 1);
58
+ --athena-ease-spring: linear(0, 0.009, 0.035 2.1%, 0.141 4.4%, 0.723 12.9%, 0.938 16.7%, 1.017 19.4%, 1.077 22.8%, 1.121 26.7%, 1.149 31.2%, 1.159 36.2%, 1.138 49.9%, 1.115 56.3%, 1.043 69.7%, 1.009 81.2%, 0.998 92.1%, 1);
59
+ }
60
+
61
+ /* Less motion: the durations are 0. The system asks for it (prefers-reduced-motion), or the person does (data-motion="reduce" on <html>, see setMotion
62
+ in athena-ui-js/motion); data-motion="full" keeps the motion although the system asks for less. */
63
+ @media (prefers-reduced-motion: reduce) {
64
+ :root:not([data-motion="full"]) {
65
+ --athena-duration-fast: 0ms;
66
+ --athena-duration-base: 0ms;
67
+ --athena-duration-slow: 0ms;
68
+ }
69
+ }
70
+
71
+ :root[data-motion="reduce"] {
72
+ --athena-duration-fast: 0ms;
73
+ --athena-duration-base: 0ms;
74
+ --athena-duration-slow: 0ms;
50
75
  }
51
76
 
52
77
  /* The dark colours: chosen with data-mode="dark" ... */
package/src/widgets.js ADDED
@@ -0,0 +1,7 @@
1
+ //widgets entry of Athena UI: a dashboard of widgets (registerWidget, createWidgetGrid) and the grid maths
2
+ //Import only what you use: `import { registerWidget, createWidgetGrid } from "athena-ui-js/widgets"`.
3
+ //LICENCE: MIT
4
+ //Repository: https://github.com/csabatibortoth/athena-ui
5
+
6
+ export * from "./libs/hephaestus/widgetGrid/widgetGrid.js";
7
+ export * from "./libs/core/gridLayout.js";