@gecko-ui-kit/motion 0.8.0 → 0.8.1

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/theme.js +6 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gecko-ui-kit/motion",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "description": "Animation helpers: stretchy indicator, page swap, text reveal, count-up, odometer, confetti, burger morph, drag & drop, theme reveal and more.",
5
5
  "keywords": [
6
6
  "vanilla-js",
package/src/theme.js CHANGED
@@ -2,10 +2,14 @@
2
2
  Falls back to an instant switch where the API is missing or motion is reduced. */
3
3
  import { RM } from './core.js';
4
4
 
5
+ /* Before 0.8.1 the default key was "tandem:theme": read it once as a fallback, so a saved choice is not lost. */
6
+ const LEGACY = { 'gecko:theme': 'tandem:theme' };
7
+ const readSaved = (key) => { const v = localStorage.getItem(key); return v ?? (LEGACY[key] ? localStorage.getItem(LEGACY[key]) : null); };
8
+
5
9
  export const getTheme = () => (document.documentElement.dataset.theme === 'dark' ? 'dark' : 'light');
6
10
 
7
11
  /** theme('dark', buttonEl, { storageKey: 'theme', duration: 450 }) */
8
- export const theme = (next, from, { storageKey = 'tandem:theme', duration = 450, easing = 'cubic-bezier(.65,0,.35,1)' } = {}) => {
12
+ export const theme = (next, from, { storageKey = 'gecko:theme', duration = 450, easing = 'cubic-bezier(.65,0,.35,1)' } = {}) => {
9
13
  const root = document.documentElement;
10
14
  if (getTheme() === next) return Promise.resolve();
11
15
  const apply = () => {
@@ -26,4 +30,4 @@ export const theme = (next, from, { storageKey = 'tandem:theme', duration = 450,
26
30
  };
27
31
  export const toggleTheme = (from, opts) => theme(getTheme() === 'dark' ? 'light' : 'dark', from, opts);
28
32
  /** Apply the saved theme on load (call early to avoid a flash). */
29
- export const restoreTheme = (storageKey = 'tandem:theme') => { try { const t = localStorage.getItem(storageKey); if (t) document.documentElement.dataset.theme = t; } catch {} };
33
+ export const restoreTheme = (storageKey = 'gecko:theme') => { try { const t = readSaved(storageKey); if (t) document.documentElement.dataset.theme = t; } catch {} };