@statsbygg/layout 0.0.1 → 0.0.3

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 (34) hide show
  1. package/dist/index.js +1 -0
  2. package/dist/index.js.map +1 -1
  3. package/dist/index.mjs +2 -0
  4. package/dist/index.mjs.map +1 -1
  5. package/package.json +2 -1
  6. package/.turbo/turbo-build.log +0 -89
  7. package/src/components/Breadcrumbs/Breadcrumbs.module.css +0 -22
  8. package/src/components/Breadcrumbs/Breadcrumbs.tsx +0 -49
  9. package/src/components/Breadcrumbs/Breadcrumbs.types.ts +0 -4
  10. package/src/components/Breadcrumbs/index.ts +0 -2
  11. package/src/components/GlobalFooter/GlobalFooter.module.css +0 -28
  12. package/src/components/GlobalFooter/GlobalFooter.tsx +0 -23
  13. package/src/components/GlobalFooter/GlobalFooter.types.ts +0 -3
  14. package/src/components/GlobalFooter/index.ts +0 -2
  15. package/src/components/GlobalHeader/GlobalHeader.module.css +0 -70
  16. package/src/components/GlobalHeader/GlobalHeader.tsx +0 -38
  17. package/src/components/GlobalHeader/GlobalHeader.types.ts +0 -4
  18. package/src/components/GlobalHeader/index.ts +0 -2
  19. package/src/components/MenuButton/MenuButton.module.css +0 -41
  20. package/src/components/MenuButton/MenuButton.tsx +0 -57
  21. package/src/components/MenuButton/MenuButton.types.ts +0 -3
  22. package/src/components/MenuButton/index.ts +0 -2
  23. package/src/components/RootLayout/RootLayout.module.css +0 -9
  24. package/src/components/RootLayout/RootLayout.tsx +0 -39
  25. package/src/components/RootLayout/RootLayout.types.ts +0 -5
  26. package/src/components/RootLayout/index.ts +0 -2
  27. package/src/index.ts +0 -6
  28. package/src/logo.svg +0 -9
  29. package/src/routes.ts +0 -211
  30. package/src/store/globalState.ts +0 -40
  31. package/src/types/css.d.ts +0 -8
  32. package/src/utils/routeRegistry.ts +0 -92
  33. package/tsconfig.json +0 -20
  34. package/tsup.config.ts +0 -15
@@ -1,40 +0,0 @@
1
- import { create, StateCreator } from 'zustand';
2
- import { persist, createJSONStorage } from 'zustand/middleware';
3
-
4
- export type Theme = 'light' | 'dark' | 'system';
5
-
6
- export type GlobalState = {
7
- user?: { id: string; name?: string } | null;
8
- theme: Theme;
9
- locale: string;
10
- setUser: (user: GlobalState['user']) => void;
11
- setTheme: (theme: Theme) => void;
12
- setLocale: (locale: string) => void;
13
- initialize: () => void | Promise<void>;
14
- };
15
-
16
- const creator: StateCreator<GlobalState, [['zustand/persist', unknown]]> = (set, get) => ({
17
- user: null,
18
- theme: 'light',
19
- locale: 'no',
20
- setUser: (user) => set({ user }),
21
- setTheme: (theme) => {
22
- set({ theme });
23
- if (typeof document !== 'undefined') {
24
- document.documentElement.setAttribute('data-color-scheme', theme);
25
- }
26
- },
27
- setLocale: (locale) => set({ locale }),
28
- initialize: () => {
29
- if (typeof document !== 'undefined') {
30
- document.documentElement.setAttribute('data-color-scheme', get().theme);
31
- }
32
- },
33
- });
34
-
35
- export const useGlobalStore = create<GlobalState>()(
36
- persist(creator, {
37
- name: 'statsbygg-global-state',
38
- storage: createJSONStorage(() => localStorage),
39
- })
40
- );
@@ -1,8 +0,0 @@
1
- declare module '*.module.css' {
2
- const classes: { [key: string]: string };
3
- export default classes;
4
- }
5
- declare module '*.svg' {
6
- const src: string;
7
- export default src;
8
- }
@@ -1,92 +0,0 @@
1
- export interface Breadcrumb {
2
- label: string;
3
- href: string;
4
- }
5
-
6
- export interface RouteDefinition {
7
- path: string;
8
- label: string;
9
- zone: string;
10
- }
11
-
12
- const STORAGE_KEY = 'statsbygg-route-registry';
13
- let routesCache = new Map<string, RouteDefinition>();
14
- let isLoaded = false;
15
-
16
- function loadRoutes(): void {
17
- if (isLoaded || typeof window === 'undefined') return;
18
-
19
- try {
20
- const stored = localStorage.getItem(STORAGE_KEY);
21
- if (stored) {
22
- routesCache = new Map(JSON.parse(stored));
23
- }
24
- isLoaded = true;
25
- } catch (error) {
26
- console.error('Failed to load route registry:', error);
27
- }
28
- }
29
-
30
- function saveRoutes(): void {
31
- if (typeof window === 'undefined') return;
32
-
33
- try {
34
- localStorage.setItem(
35
- STORAGE_KEY,
36
- JSON.stringify(Array.from(routesCache.entries()))
37
- );
38
- } catch (error) {
39
- console.error('Failed to save route registry:', error);
40
- }
41
- }
42
-
43
- export function registerRoutes(zoneRoutes: RouteDefinition[]): void {
44
- loadRoutes();
45
- zoneRoutes.forEach((route) => routesCache.set(route.path, route));
46
- saveRoutes();
47
- }
48
-
49
- export function buildBreadcrumbs(currentPath: string): Breadcrumb[] {
50
- loadRoutes();
51
-
52
- const segments = currentPath.split('/').filter(Boolean);
53
- const breadcrumbs: Breadcrumb[] = [{ label: 'Hjem', href: '/' }];
54
-
55
- let accumulatedPath = '';
56
-
57
- segments.forEach((segment) => {
58
- accumulatedPath += '/' + segment;
59
- const route = routesCache.get(accumulatedPath);
60
-
61
- if (route) {
62
- breadcrumbs.push({ label: route.label, href: accumulatedPath });
63
- } else {
64
- const label = formatSegmentLabel(segment);
65
- breadcrumbs.push({ label, href: accumulatedPath });
66
- }
67
- });
68
-
69
- return breadcrumbs;
70
- }
71
-
72
- export function getRoute(path: string): RouteDefinition | undefined {
73
- loadRoutes();
74
- return routesCache.get(path);
75
- }
76
-
77
- export function getAllRoutes(): RouteDefinition[] {
78
- loadRoutes();
79
- return Array.from(routesCache.values());
80
- }
81
-
82
- export function clearRoutes(): void {
83
- routesCache.clear();
84
- if (typeof window !== 'undefined') {
85
- localStorage.removeItem(STORAGE_KEY);
86
- }
87
- isLoaded = false;
88
- }
89
-
90
- function formatSegmentLabel(segment: string): string {
91
- return segment.charAt(0).toUpperCase() + segment.slice(1).replace(/-/g, ' ');
92
- }
package/tsconfig.json DELETED
@@ -1,20 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2018",
4
- "lib": ["DOM", "ES2020"],
5
- "jsx": "react-jsx",
6
- "strict": true,
7
- "skipLibCheck": true,
8
- "module": "ESNext",
9
- "moduleResolution": "Node",
10
- "resolveJsonModule": true,
11
- "esModuleInterop": true,
12
- "forceConsistentCasingInFileNames": true,
13
- "noEmit": true,
14
- "baseUrl": ".",
15
- "paths": {
16
- "@/*": ["./src/*"]
17
- }
18
- },
19
- "include": ["src"]
20
- }
package/tsup.config.ts DELETED
@@ -1,15 +0,0 @@
1
- import { defineConfig } from 'tsup';
2
-
3
- export default defineConfig({
4
- entry: ['src/index.ts'],
5
- format: ['cjs', 'esm'],
6
- dts: true,
7
- splitting: false,
8
- sourcemap: true,
9
- clean: true,
10
- external: ['react', 'react-dom', 'next', '@digdir/designsystemet-react', 'clsx', 'zustand', 'lucide-react'],
11
- loader: {
12
- '.css': 'local-css',
13
- '.svg': 'file',
14
- },
15
- });