athena-ui-js 2.1.0 → 2.2.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.
@@ -274,7 +274,7 @@ function drawLine(svg, ctx) {
274
274
  const outline = [`M${points[0][0]},${baseline}`, ...points.map(p => `L${p.join(",")}`), `L${points.at(-1)[0]},${baseline}`, "Z"];
275
275
  clipped.append(svgEl("path", { d: outline.join(" "), class: "chart-area" }));
276
276
  }
277
- clipped.append(svgEl("polyline", { points: points.map(p => p.join(",")).join(" "), class: "chart-line", fill: "none" }));
277
+ clipped.append(svgEl("polyline", { points: points.map(p => p.join(",")).join(" "), class: "chart-line", fill: "none", pathLength: 1 }));
278
278
  group.append(clipped);
279
279
  if (dotted) {
280
280
  for (const i of inside) {
@@ -524,6 +524,7 @@ function buildDataTable({ labels, series, times, title, type }) {
524
524
  * @param {(range: ({from: number, to: number}|null)) => void} [options.onZoom] called when a person zooms or resets
525
525
  * @param {number} [options.maxPoints] `push` keeps at most this many points per series (the oldest are dropped)
526
526
  * @param {number[]} [options.hiddenSeries] the series (or slices) that are hidden at the start; a person hides and shows them with the legend, and a redraw keeps that
527
+ * @param {boolean} [options.animate=true] the first drawing animates: bars grow, a line is drawn, slices pop in (not when it is redrawn, and not under reduced motion)
527
528
  * @param {boolean} [options.interactive=true] line and area charts: false leaves out the pointer layer (tooltip that follows the pointer, zoom)
528
529
  * @returns {(SVGElement & {element: SVGElement, update: (options?: object) => SVGElement, destroy: () => void,
529
530
  * zoom: (from: number, to: number) => void, resetZoom: () => void, getZoom: () => ({from: number, to: number}|null),
@@ -539,6 +540,8 @@ export function generateChart(options = {}) {
539
540
  if (options.labels) state.used.labels = [...options.labels];
540
541
  if (options.times) state.used.times = [...options.times];
541
542
  const hidden = new Set(options.hiddenSeries ?? []);
543
+ // Only the first drawing animates (bars grow, the line is drawn, slices pop in): a redraw while streaming or zooming must not start it again
544
+ let firstDrawing = options.animate !== false;
542
545
  const hooks = {
543
546
  legend: (series, off) => {
544
547
  if (off) hidden.add(series);
@@ -554,7 +557,7 @@ export function generateChart(options = {}) {
554
557
  const handle = {
555
558
  element: () => state.current.svg,
556
559
  redraw() {
557
- const next = buildChart(state.used, hooks);
560
+ const next = buildChart(state.used, hooks, { animate: false });
558
561
  if (!next) return state.current?.svg;
559
562
  // A redraw replaces the whole SVG (every second while streaming, and when someone zooms). The keyboard focus would be lost
560
563
  // with it, so it goes to the same place in the new one: the same legend entry, the same point, or the plot.
@@ -623,7 +626,8 @@ export function generateChart(options = {}) {
623
626
  dataTable: { get: () => state.current.table ?? null, configurable: true }
624
627
  });
625
628
 
626
- const built = buildChart(state.used, hooks);
629
+ const built = buildChart(state.used, hooks, { animate: firstDrawing });
630
+ firstDrawing = false;
627
631
  if (!built) return null;
628
632
  state.current = built;
629
633
  const host = resolveElement(options.parent ?? "wrapper") ?? document.body;
@@ -632,7 +636,7 @@ export function generateChart(options = {}) {
632
636
  return attach(built.svg);
633
637
  }
634
638
 
635
- function buildChart(options = {}, hooks) {
639
+ function buildChart(options = {}, hooks, { animate = false } = {}) {
636
640
  const { type = "bar", id, title } = options;
637
641
  const sparkline = type === "sparkline";
638
642
  const width = options.width ?? (sparkline ? 120 : 600);
@@ -652,7 +656,7 @@ function buildChart(options = {}, hooks) {
652
656
  return null;
653
657
  }
654
658
 
655
- const svg = svgEl("svg", { viewBox: `0 0 ${width} ${height}`, width, height, class: `athena-chart athena-chart-${type}`, role: "img" });
659
+ const svg = svgEl("svg", { viewBox: `0 0 ${width} ${height}`, width, height, class: `athena-chart athena-chart-${type}${animate && type !== "sparkline" ? " athena-chart-animated" : ""}`, role: "img" });
656
660
  if (id) svg.id = id;
657
661
  const summary = `${title ?? translate(`chart.${type}`)}: ${series.map(s => s.name ?? "").filter(Boolean).join(", ")}`.replace(/: $/, "");
658
662
  svg.setAttribute("aria-label", options.ariaLabel ?? summary);
@@ -326,6 +326,23 @@ export function generateEmptyState(options = {}) {
326
326
  return asHandle({ element });
327
327
  }
328
328
 
329
+ /**
330
+ * A skeleton: grey lines with a shimmer where text or a card will be, so the page does not jump when it arrives. It is a live region that says
331
+ * "Loading..." to a screen reader; the shimmer stops under reduced motion.
332
+ *
333
+ * @param {object} [options]
334
+ * @param {string|Element} [options.parent]
335
+ * @param {number} [options.lines=3] the last of several lines is shorter
336
+ * @param {string} [options.class] e.g. "skeleton-card" in your own CSS gives the box a height
337
+ */
338
+ export function generateSkeleton(options = {}) {
339
+ const lines = Array.from({ length: Math.max(1, options.lines ?? 3) }, () => el("span", { class: "athena-skeleton athena-skeleton-line", attrs: { "aria-hidden": "true" } }));
340
+ const element = el("div", { id: options.id, class: cx("athena-skeleton-box", options.class), attrs: { role: "status", "aria-live": "polite" } },
341
+ ...lines, el("span", { class: "athena-visually-hidden", text: translate("loading") }));
342
+ mount(options.parent, element);
343
+ return asHandle({ element });
344
+ }
345
+
329
346
  /**
330
347
  * A placeholder while something loads: a spinner and a text (a live region, so a screen reader says it).
331
348
  *
@@ -4,6 +4,7 @@
4
4
  //Repository: https://github.com/csabatibortoth/athena-ui
5
5
 
6
6
  import { cx, el, setContent, uid } from "../../core/dom.js";
7
+ import { removeAfterTransition } from "../../core/motion.js";
7
8
  import { translate } from "../../core/i18n.js";
8
9
  import { generateButton, generateForm } from "../formGenerator/formBuilder.js";
9
10
 
@@ -48,8 +49,8 @@ export function showDialog(options = {}) {
48
49
  return;
49
50
  }
50
51
  if (dialog.open) dialog.close();
51
- dialog.remove();
52
52
  resolve(value);
53
+ removeAfterTransition(dialog); // it fades out first (at once under reduced motion)
53
54
  };
54
55
 
55
56
  // Esc: the browser asks (cancel); a dialog that cannot be dismissed stays, and beforeClose can still say no
@@ -4,6 +4,7 @@
4
4
  //Repository: https://github.com/csabatibortoth/athena-ui
5
5
 
6
6
  import { asHandle, cx, el, mount, setContent } from "../../core/dom.js";
7
+ import { removeAfterTransition } from "../../core/motion.js";
7
8
  import { translate } from "../../core/i18n.js";
8
9
 
9
10
  const TOAST_CONTAINER_ID = "athena-toasts";
@@ -38,7 +39,8 @@ export function showToast(options) {
38
39
  let timer;
39
40
  const close = () => {
40
41
  clearTimeout(timer);
41
- toast.remove();
42
+ toast.classList.add("is-leaving");
43
+ removeAfterTransition(toast);
42
44
  };
43
45
  const toast = el("div", {
44
46
  class: cx("toast", `alert-${type}`),
@@ -4,6 +4,7 @@
4
4
  //Repository: https://github.com/csabatibortoth/athena-ui
5
5
 
6
6
  import { resolveElement } from "../../core/dom.js";
7
+ import { viewTransition } from "../../core/motion.js";
7
8
  import { matchRoute, normalizePath, parseQuery } from "./matchRoute.js";
8
9
 
9
10
  /**
@@ -25,6 +26,9 @@ import { matchRoute, normalizePath, parseQuery } from "./matchRoute.js";
25
26
  * @param {boolean} [options.focusContent=false] after a page is shown the outlet gets the focus (it is made focusable for that), so a
26
27
  * screen reader starts reading the new page and the keyboard continues there
27
28
  * @param {boolean} [options.scrollTop=false] scroll to the top after a page is shown
29
+ * @param {boolean} [options.transition=false] a page change is a view transition (document.startViewTransition): the old page cross-fades into the new one,
30
+ * and elements with a `view-transition-name` move from one page to the next. Without the API, or under reduced motion, nothing changes. The old page
31
+ * stays on the screen until the page function of the new one is done, so pages that need long to build should draw something quickly.
28
32
  * @param {object} [options.auth] sign-in rules for routes, see the route options below
29
33
  * @param {() => boolean} [options.auth.isSignedIn]
30
34
  * @param {(role: string) => boolean} [options.auth.hasRole]
@@ -91,15 +95,20 @@ export function createRouter(options = {}) {
91
95
  }
92
96
 
93
97
  const host = resolveElement(outlet);
94
- host?.replaceChildren();
95
- currentContext = context;
96
- options.onRender?.(context, matched?.route);
97
- if (!matched) {
98
- notFound?.(context);
99
- } else {
100
- if (matched.route.title) document.title = titlePrefix + matched.route.title;
101
- await matched.route.handler(context);
102
- }
98
+ const show = async () => {
99
+ if (token !== renderToken) return; // a newer navigation took over while the transition was starting
100
+ host?.replaceChildren();
101
+ currentContext = context;
102
+ options.onRender?.(context, matched?.route);
103
+ if (!matched) {
104
+ notFound?.(context);
105
+ } else {
106
+ if (matched.route.title) document.title = titlePrefix + matched.route.title;
107
+ await matched.route.handler(context);
108
+ }
109
+ };
110
+ if (options.transition) await viewTransition(show);
111
+ else await show();
103
112
  if (token !== renderToken) return;
104
113
  if (options.focusContent && host) {
105
114
  if (!host.hasAttribute("tabindex")) host.setAttribute("tabindex", "-1");
@@ -6,6 +6,7 @@
6
6
  import { downloadFile, toCsv } from "../../core/csv.js";
7
7
  import { asHandle, resolveElement } from "../../core/dom.js";
8
8
  import { translate } from "../../core/i18n.js";
9
+ import { animate, fadeIn, prefersReducedMotion } from "../../core/motion.js";
9
10
  import { clampWidth, virtualWindow } from "../../core/tableMath.js";
10
11
 
11
12
  const el = (tag, className, text) => {
@@ -65,6 +66,8 @@ const compare = (a, b) =>
65
66
  * in chunks of `chunkSize` (`page` is the chunk number), rows that have not arrived yet show a placeholder, and sorting or the filter
66
67
  * start again from the top.
67
68
  * @param {number} [options.chunkSize=50] rows per request of a data source with `virtual`
69
+ * @param {boolean} [options.animateRows=false] rows slide to their new place when the table is sorted, filtered or changes page, and new rows fade in
70
+ * (at most 60 rows are animated, none under reduced motion, none in a virtual table)
68
71
  * @param {number} [options.filterDelay=300] ms to wait after typing before the data source is asked
69
72
  * @param {{label: string, onclick: (row: object) => void, danger?: boolean, hidden?: (row: object) => boolean, ariaLabel?: (row: object) => string}[]} [options.rowActions]
70
73
  * a column of buttons at the end of every row
@@ -355,8 +358,12 @@ export function generateTable(options = {}) {
355
358
  return tr;
356
359
  }
357
360
 
361
+ const rowOf = new WeakMap(); // the element of a row -> its row object, to find the same row again after a redraw (animateRows)
362
+ let rendered = false;
363
+
358
364
  function renderRow(row, index) {
359
365
  const tr = el("tr");
366
+ if (row !== undefined) rowOf.set(tr, row);
360
367
  if (virtual) tr.setAttribute("aria-rowindex", String(index + 2));
361
368
  if (row === undefined) {
362
369
  // A row of a data source that has not arrived yet
@@ -558,10 +565,28 @@ export function generateTable(options = {}) {
558
565
  root.classList.toggle("athena-table-is-loading", remote && server.loading);
559
566
  renderPager(current.length);
560
567
  if (virtual) table.setAttribute("aria-rowcount", String(current.length + 1));
568
+ // Where the rows were before (FLIP): the same row object is the same row
569
+ const before = options.animateRows && rendered && !virtual && !prefersReducedMotion()
570
+ ? new Map([...(table.tBodies[0]?.rows ?? [])].slice(0, 60).map(tr => [rowOf.get(tr), tr.getBoundingClientRect()]).filter(([row]) => row !== undefined))
571
+ : null;
561
572
  const parts = [renderHead(current), renderBody()];
562
573
  if (resizableColumns || Object.keys(widths).length) parts.unshift(renderColgroup());
563
574
  if (options.caption) parts.unshift(el("caption", null, options.caption));
564
575
  table.replaceChildren(...parts);
576
+ if (before?.size) {
577
+ for (const tr of [...table.tBodies[0].rows].slice(0, 60)) {
578
+ const row = rowOf.get(tr);
579
+ if (row === undefined) continue;
580
+ const old = before.get(row);
581
+ if (!old) {
582
+ fadeIn(tr);
583
+ continue;
584
+ }
585
+ const now = tr.getBoundingClientRect();
586
+ if (Math.abs(old.top - now.top) > 1) animate(tr, [{ translate: `0 ${old.top - now.top}px` }, { translate: "0 0" }], { easing: "cubic-bezier(0.2, 0, 0, 1)" });
587
+ }
588
+ }
589
+ rendered = true;
565
590
  if (Object.keys(widths).length) applyWidths();
566
591
  if (scroller) scroller.scrollTop = scrollTop;
567
592
  }
package/src/motion.js ADDED
@@ -0,0 +1,6 @@
1
+ //motion entry of Athena UI: animate, transition, flip, tween, spring, stagger, viewTransition, setMotion
2
+ //Import only what you use: `import { animate } from "athena-ui-js/motion"`.
3
+ //LICENCE: MIT
4
+ //Repository: https://github.com/csabatibortoth/athena-ui
5
+
6
+ export * from "./libs/core/motion.js";
@@ -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,220 @@ 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
+
2159
2377
  }
@@ -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" ... */