spoko-design-system 0.3.8 → 0.3.9
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.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "spoko-design-system",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.9",
|
|
4
4
|
"private": false,
|
|
5
5
|
"main": "./index.ts",
|
|
6
6
|
"module": "./index.ts",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"@iconify/vue": "^4.3.0",
|
|
75
75
|
"@playform/compress": "^0.1.7",
|
|
76
76
|
"@playform/inline": "^0.1.1",
|
|
77
|
-
"@types/node": "^22.13.
|
|
77
|
+
"@types/node": "^22.13.4",
|
|
78
78
|
"@unocss/astro": "^65.4.3",
|
|
79
79
|
"@unocss/preset-attributify": "^65.4.3",
|
|
80
80
|
"@unocss/preset-typography": "^65.4.3",
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"@unocss/preset-wind": "^65.4.3",
|
|
84
84
|
"@unocss/reset": "^65.4.3",
|
|
85
85
|
"@vite-pwa/astro": "^0.5.0",
|
|
86
|
-
"@vueuse/core": "^12.
|
|
86
|
+
"@vueuse/core": "^12.6.1",
|
|
87
87
|
"astro-i18next": "1.0.0-beta.21",
|
|
88
88
|
"astro-icon": "^1.1.5",
|
|
89
89
|
"astro-meta-tags": "^0.3.1",
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"astro-remote": "^0.3.3",
|
|
93
93
|
"dotenv": "^16.4.7",
|
|
94
94
|
"i18next": "^24.2.2",
|
|
95
|
-
"i18next-browser-languagedetector": "^8.0.
|
|
95
|
+
"i18next-browser-languagedetector": "^8.0.3",
|
|
96
96
|
"i18next-fs-backend": "^2.6.0",
|
|
97
97
|
"i18next-http-backend": "^3.0.2",
|
|
98
98
|
"i18next-vue": "^5.1.0",
|
|
@@ -4,11 +4,18 @@ import CategoryViewToggler from './CategoryViewToggler.astro';
|
|
|
4
4
|
import { Icon } from 'astro-icon/components';
|
|
5
5
|
import { t } from "i18next";
|
|
6
6
|
|
|
7
|
-
const {
|
|
7
|
+
const {
|
|
8
|
+
category,
|
|
9
|
+
subcategory,
|
|
10
|
+
subtitle,
|
|
11
|
+
subsubtitle,
|
|
12
|
+
titleSmall,
|
|
13
|
+
locale,
|
|
14
|
+
showViewToggler,
|
|
15
|
+
viewerLabels
|
|
16
|
+
} = Astro.props;
|
|
8
17
|
|
|
9
|
-
// Compute base URL for localization
|
|
10
18
|
const baseURL = locale === 'en' ? '' : `/${locale}`;
|
|
11
|
-
|
|
12
19
|
---
|
|
13
20
|
|
|
14
21
|
<div
|
|
@@ -16,67 +23,38 @@ const baseURL = locale === 'en' ? '' : `/${locale}`;
|
|
|
16
23
|
transition:name="category-details"
|
|
17
24
|
transition:animate="fade"
|
|
18
25
|
>
|
|
19
|
-
<CategorySidebarToggler onclick="toggleSidebar()">
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
</CategorySidebarToggler>
|
|
26
|
+
<CategorySidebarToggler onclick="toggleSidebar()">
|
|
27
|
+
<!-- Desktop expanded -->
|
|
28
|
+
<Icon
|
|
29
|
+
name="ant-design:menu-fold-outlined"
|
|
30
|
+
class="toggler-btn md:[&:not(.hidden)]:block"
|
|
31
|
+
aria-hidden="true"
|
|
32
|
+
/>
|
|
33
|
+
<!-- Desktop collapsed -->
|
|
34
|
+
<Icon
|
|
35
|
+
name="ant-design:menu-unfold-outlined"
|
|
36
|
+
class="toggler-btn hidden md:[&:not(.hidden)]:block"
|
|
37
|
+
aria-hidden="true"
|
|
38
|
+
/>
|
|
39
|
+
<!-- Mobile icon -->
|
|
40
|
+
<Icon
|
|
41
|
+
name="ant-design:menu-outlined"
|
|
42
|
+
class="toggler-btn block md:hidden"
|
|
43
|
+
aria-hidden="true"
|
|
44
|
+
/>
|
|
45
|
+
</CategorySidebarToggler>
|
|
39
46
|
|
|
40
|
-
|
|
41
|
-
{subtitle ? (
|
|
42
|
-
<>
|
|
43
|
-
<a class="text-lg font-vw-headregular whitespace-nowrap block" href={`${baseURL}/${category.slug}/`}>
|
|
44
|
-
{category.name}
|
|
45
|
-
{titleSmall && <small>{titleSmall}</small>}
|
|
46
|
-
</a>
|
|
47
|
-
<span class="text-neutral-lighter text-lg inline-block px-1 font-headlight">/</span>
|
|
48
|
-
{!subsubtitle ? (
|
|
49
|
-
<h1 class="text-lg py-2.5 sm:py-0 whitespace-nowrap underline underline-offset-6 decoration-blue-300 decoration-0.5">
|
|
50
|
-
{subtitle} <span class="sr-only"> {t('catalog.extra-short')}</span>
|
|
51
|
-
</h1>
|
|
52
|
-
) : (
|
|
53
|
-
<>
|
|
54
|
-
<div class="text-lg py-2.5 sm:py-0 whitespace-nowrap ">
|
|
55
|
-
<a href={`${baseURL}/${category.slug}/${subcategory.slug}/`}>
|
|
56
|
-
{subtitle}
|
|
57
|
-
</a>
|
|
58
|
-
</div>
|
|
59
|
-
<span class="text-neutral-lighter text-lg inline-block px-1 font-headlight">/</span>
|
|
60
|
-
<h1 class="text-lg py-2.5 sm:py-0 whitespace-nowrap underline underline-offset-6 decoration-blue-300 decoration-0.5">
|
|
61
|
-
{subsubtitle} <span class="sr-only"> {t('catalog.extra-short')}</span>
|
|
62
|
-
</h1>
|
|
63
|
-
</>
|
|
64
|
-
)}
|
|
65
|
-
</>
|
|
66
|
-
) : (
|
|
67
|
-
<h1 class="text-lg py-2.5 sm:py-0 whitespace-nowrap">
|
|
68
|
-
{category.name}
|
|
69
|
-
{titleSmall && (<small>{titleSmall}</small>)}
|
|
70
|
-
<span class="sr-only"> {t('catalog.extra-short')}</span>
|
|
71
|
-
</h1>
|
|
72
|
-
)}
|
|
73
|
-
</div>
|
|
74
|
-
|
|
75
|
-
{ showViewToggler && ( <CategoryViewToggler {...viewerLabels} class="hidden lg:flex items-center gap-2 ml-auto" /> ) }
|
|
47
|
+
<!-- Rest of the existing template code -->
|
|
76
48
|
|
|
49
|
+
{ showViewToggler && (
|
|
50
|
+
<CategoryViewToggler
|
|
51
|
+
{...viewerLabels}
|
|
52
|
+
class="hidden lg:flex items-center gap-2 ml-auto"
|
|
53
|
+
/>
|
|
54
|
+
)}
|
|
77
55
|
</div>
|
|
78
56
|
|
|
79
|
-
<script
|
|
57
|
+
<script>
|
|
80
58
|
function initializeSidebar() {
|
|
81
59
|
const sidebar = document.getElementById('sidebar');
|
|
82
60
|
const savedState = localStorage.getItem('sidebarState') || 'open';
|
|
@@ -114,13 +92,35 @@ const baseURL = locale === 'en' ? '' : `/${locale}`;
|
|
|
114
92
|
}
|
|
115
93
|
}
|
|
116
94
|
}
|
|
95
|
+
|
|
96
|
+
// Initialize on every page load to maintain state during navigation
|
|
97
|
+
document.addEventListener('astro:page-load', initializeSidebar);
|
|
117
98
|
|
|
99
|
+
// Initialize on initial page load
|
|
118
100
|
document.addEventListener('DOMContentLoaded', initializeSidebar);
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
101
|
+
|
|
102
|
+
// Handle state during view transitions
|
|
103
|
+
document.addEventListener('astro:before-swap', () => {
|
|
104
|
+
const sidebarState = localStorage.getItem('sidebarState');
|
|
105
|
+
if (sidebarState) {
|
|
106
|
+
// Store state temporarily during transition
|
|
107
|
+
sessionStorage.setItem('tempSidebarState', sidebarState);
|
|
125
108
|
}
|
|
126
|
-
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
document.addEventListener('astro:after-swap', () => {
|
|
112
|
+
const tempState = sessionStorage.getItem('tempSidebarState');
|
|
113
|
+
if (tempState) {
|
|
114
|
+
// Restore state after transition
|
|
115
|
+
localStorage.setItem('sidebarState', tempState);
|
|
116
|
+
sessionStorage.removeItem('tempSidebarState');
|
|
117
|
+
initializeSidebar();
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
</script>
|
|
121
|
+
|
|
122
|
+
<style>
|
|
123
|
+
.toggler-btn {
|
|
124
|
+
@apply md:-mt-0.5;
|
|
125
|
+
}
|
|
126
|
+
</style>
|
|
@@ -42,35 +42,41 @@ const {
|
|
|
42
42
|
</div>
|
|
43
43
|
</div>
|
|
44
44
|
|
|
45
|
+
<script>
|
|
46
|
+
function initializeView() {
|
|
47
|
+
const savedView = localStorage.getItem('categoryView') || 'list';
|
|
48
|
+
updateUI(savedView);
|
|
49
|
+
|
|
50
|
+
// Clean up existing listeners to prevent duplicates
|
|
51
|
+
document.querySelectorAll('.view-toggle').forEach(btn => {
|
|
52
|
+
btn.removeEventListener('click', handleViewToggle);
|
|
53
|
+
btn.addEventListener('click', handleViewToggle);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
45
56
|
|
|
46
|
-
<script >
|
|
47
57
|
function handleViewToggle(e) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const view = button.dataset.view;
|
|
58
|
+
if (!(e.currentTarget instanceof HTMLElement)) return;
|
|
59
|
+
const view = e.currentTarget.dataset.view;
|
|
52
60
|
if (!view) return;
|
|
53
|
-
|
|
61
|
+
|
|
54
62
|
localStorage.setItem('categoryView', view);
|
|
55
63
|
updateUI(view);
|
|
56
64
|
}
|
|
57
|
-
|
|
65
|
+
|
|
58
66
|
function updateUI(view) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
67
|
+
// Update toggle buttons
|
|
68
|
+
document.querySelectorAll('.view-toggle').forEach(btn => {
|
|
69
|
+
btn.classList.toggle('bg-neutral-lightest', btn.dataset.view === view);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
// Update products container
|
|
63
73
|
const productsContainer = document.querySelector('.products-container');
|
|
64
74
|
if (productsContainer) {
|
|
65
75
|
productsContainer.classList.remove('view-grid', 'view-list');
|
|
66
76
|
productsContainer.classList.add(`view-${view}`);
|
|
67
77
|
}
|
|
68
78
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
document.querySelectorAll('.view-toggle')
|
|
74
|
-
.forEach(btn => btn.addEventListener('click', handleViewToggle));
|
|
75
|
-
}, { once: true });
|
|
76
|
-
</script>
|
|
79
|
+
|
|
80
|
+
// Initialize on page load and view transitions
|
|
81
|
+
document.addEventListener('astro:page-load', initializeView);
|
|
82
|
+
</script>
|