tera-system-ui 0.1.69 → 0.1.70

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.
@@ -24,6 +24,9 @@ export declare const SCREEN_BREAK_POINTS: {
24
24
  lg: number;
25
25
  xl: number;
26
26
  };
27
+ export declare function saveXlSideNavState(state: string | undefined): void;
28
+ export declare function loadXlSideNavState(): string | undefined;
29
+ export declare function restoreSideNavStateForXl(): void;
27
30
  export declare const mainLayout: () => HTMLElement | null;
28
31
  export declare const getSideNavState: () => string | undefined;
29
32
  export declare const setSideNavState: (state: any) => void;
@@ -11,6 +11,25 @@ export const SCREEN_BREAK_POINTS = {
11
11
  lg: 1024,
12
12
  xl: 1280,
13
13
  };
14
+ const SIDE_NAV_XL_STATE_KEY = 'side-nav-xl-state';
15
+ export function saveXlSideNavState(state) {
16
+ if (state === undefined) {
17
+ localStorage.removeItem(SIDE_NAV_XL_STATE_KEY);
18
+ }
19
+ else {
20
+ localStorage.setItem(SIDE_NAV_XL_STATE_KEY, state);
21
+ }
22
+ }
23
+ export function loadXlSideNavState() {
24
+ return localStorage.getItem(SIDE_NAV_XL_STATE_KEY) ?? undefined;
25
+ }
26
+ export function restoreSideNavStateForXl() {
27
+ const screenWidth = getScreenWidth();
28
+ if (screenWidth >= SCREEN_BREAK_POINTS.xl) {
29
+ const saved = loadXlSideNavState();
30
+ setSideNavState(saved);
31
+ }
32
+ }
14
33
  export const mainLayout = () => document?.getElementById('side-nav_main-layout');
15
34
  export const getSideNavState = () => {
16
35
  return mainLayout()?.getAttribute('data-side-nav-state') || undefined;
@@ -38,6 +57,7 @@ export function toggleSideNavigation() {
38
57
  }
39
58
  else if (screenWidth >= SCREEN_BREAK_POINTS.xl) {
40
59
  state = currentSideNavState === undefined ? "compact" : undefined;
60
+ saveXlSideNavState(state);
41
61
  }
42
62
  setSideNavState(state);
43
63
  }
@@ -1,4 +1,5 @@
1
- <script lang="ts">import { SCREEN_BREAK_POINTS, mainLayout, setSideNavState, toggleSideNavigation, getSideNavState } from "./SideNavigation";
1
+ <script lang="ts">import { onMount } from "svelte";
2
+ import { mainLayout, SCREEN_BREAK_POINTS, setSideNavState, restoreSideNavStateForXl, toggleSideNavigation } from "./SideNavigation";
2
3
  import { clickOutside } from "../../actions/clickOutside";
3
4
  import { Button } from "../button";
4
5
  import { IconCoinConvert, IconHamburger } from "../icons";
@@ -70,6 +71,9 @@ let selectedIndex = (() => {
70
71
  return (item.exactHref ?? item.href) === resolvedSideNavHref;
71
72
  });
72
73
  })();
74
+ onMount(() => {
75
+ restoreSideNavStateForXl();
76
+ });
73
77
  </script>
74
78
 
75
79
  <nav class="side-nav_main-side-bar grid grid-rows-[auto_1fr_auto]"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tera-system-ui",
3
- "version": "0.1.69",
3
+ "version": "0.1.70",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "npm run customPrepublish && npm run generate-index && npm run generate-llms && vite build && npm run package && npm run copy-docs && npm run copy-llms && npm run postpublish",