libreria-astro-lefebvre 0.2.36 → 0.2.38
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
|
@@ -69,6 +69,19 @@ const categories: MenuItem[] = (categoriesProp && categoriesProp.length > 0)
|
|
|
69
69
|
|
|
70
70
|
const currentPath = Astro.url.pathname;
|
|
71
71
|
|
|
72
|
+
// Un enlace a la raíz ("/") está contenido en cualquier ruta; solo se considera activo en la propia home.
|
|
73
|
+
// Tolera null/undefined en el enlace y en subdirectory (el resto del componente ya los admitía).
|
|
74
|
+
const trimSlash = (p: unknown) => String(p ?? '').replace(/\/+$/, '');
|
|
75
|
+
const isActiveLink = (rawLink: unknown) => {
|
|
76
|
+
const link = String(rawLink ?? '');
|
|
77
|
+
const sub = String(subdirectory ?? '');
|
|
78
|
+
if (link === '') return false;
|
|
79
|
+
if (trimSlash(link) === trimSlash(sub)) {
|
|
80
|
+
return trimSlash(currentPath) === trimSlash(link) || trimSlash(sub + currentPath) === trimSlash(link);
|
|
81
|
+
}
|
|
82
|
+
return currentPath.includes(link) || (sub !== '' && (sub + currentPath).includes(link));
|
|
83
|
+
};
|
|
84
|
+
|
|
72
85
|
const identifier = 'header-cab-' + Math.random().toString(36).substring(2, 10);
|
|
73
86
|
|
|
74
87
|
// Los enlaces con esquema (https:, mailto:, tel:) o "//" ya son absolutos; solo a los relativos se les antepone el origen.
|
|
@@ -105,18 +118,18 @@ const categories: MenuItem[] = (categoriesProp && categoriesProp.length > 0)
|
|
|
105
118
|
---
|
|
106
119
|
|
|
107
120
|
<header class="sticky top-0 w-full font-body bg-[rgba(250,250,245,0.80)] backdrop-blur-lg z-50 flex flex-col justify-center align-center items-center p-0">
|
|
108
|
-
<div class="
|
|
121
|
+
<div class="cab-gua-bar px-4 py-3 w-full">
|
|
109
122
|
|
|
110
123
|
<div class="max-w-[1376px] flex items-center justify-between gap-2 mx-auto p-2">
|
|
111
|
-
<div class="flex flex-col items-start gap-
|
|
124
|
+
<div class="flex flex-col items-start gap-4 min-w-0">
|
|
112
125
|
<a href="https://lefebvre.es" class="flex items-center shrink-0">
|
|
113
126
|
<img src="https://assets.lefebvre.es/media/logos-2/svg/lefebvre.svg" class="h-7 w-auto" alt="Lefebvre" width="104" height="28" loading={loading}>
|
|
114
127
|
</a>
|
|
115
128
|
{firstItem && (
|
|
116
|
-
<a href={firstItem.link} target={firstItem.target ?? '_self'} class={`${firstItemClass} min-w-0 max-w-full truncate
|
|
129
|
+
<a href={firstItem.link} target={firstItem.target ?? '_self'} class={`${firstItemClass} min-w-0 max-w-full truncate pb-1 border-b-4 ${isActiveLink(firstItem.link) ? 'border-[#d71635]' : 'border-transparent'} cab-gua-mob`}>{firstItem.name}</a>
|
|
117
130
|
)}
|
|
118
131
|
</div>
|
|
119
|
-
<div class="flex items-
|
|
132
|
+
<div class="flex items-end gap-2 shrink-0 cab-gua-mob">
|
|
120
133
|
{label && (
|
|
121
134
|
<div class="flex items-center gap-4">
|
|
122
135
|
<a href={url} class={ctaClass}>{label}</a>
|
|
@@ -136,12 +149,11 @@ const categories: MenuItem[] = (categoriesProp && categoriesProp.length > 0)
|
|
|
136
149
|
|
|
137
150
|
</div>
|
|
138
151
|
</div>
|
|
139
|
-
<nav class="
|
|
152
|
+
<nav class="cab-gua-desk w-full px-8">
|
|
140
153
|
<div class="max-w-[1376px] flex items-center gap-6 mx-auto">
|
|
141
154
|
<ul class="flex items-center justify-start">
|
|
142
155
|
{categories.map((category, index) => {
|
|
143
|
-
const isActive =
|
|
144
|
-
(subdirectory !== '' && (subdirectory + currentPath).includes(category.link));
|
|
156
|
+
const isActive = isActiveLink(category.link);
|
|
145
157
|
const hasSub = category.subcategories?.length > 0;
|
|
146
158
|
const submenuId = `${identifier}-d-${index}`;
|
|
147
159
|
return (
|
|
@@ -188,14 +200,13 @@ const categories: MenuItem[] = (categoriesProp && categoriesProp.length > 0)
|
|
|
188
200
|
</div>
|
|
189
201
|
</nav>
|
|
190
202
|
|
|
191
|
-
<nav class="hidden
|
|
203
|
+
<nav class="hidden cab-gua-mob w-full bg-white border-[#e1c8b4]" id="navbar-default">
|
|
192
204
|
<div class="max-w-screen-xl flex flex-wrap items-center justify-between mx-auto">
|
|
193
205
|
|
|
194
206
|
<div class="w-full">
|
|
195
207
|
<ul>
|
|
196
208
|
{categories.map((category, index) => {
|
|
197
|
-
const isActive =
|
|
198
|
-
(subdirectory !== '' && (subdirectory + currentPath).includes(category.link));
|
|
209
|
+
const isActive = isActiveLink(category.link);
|
|
199
210
|
const hasSub = category.subcategories?.length > 0;
|
|
200
211
|
const submenuId = `${identifier}-m-${index}`;
|
|
201
212
|
if (category === firstItem) return null;
|
|
@@ -238,10 +249,20 @@ const categories: MenuItem[] = (categoriesProp && categoriesProp.length > 0)
|
|
|
238
249
|
</div>
|
|
239
250
|
</div>
|
|
240
251
|
</nav>
|
|
241
|
-
|
|
242
|
-
|
|
252
|
+
|
|
253
|
+
|
|
243
254
|
</header>
|
|
244
255
|
|
|
256
|
+
<style is:inline>
|
|
257
|
+
/* Breakpoint propio (992px): no depende de qué clases responsive genere el Tailwind del portal. */
|
|
258
|
+
.cab-gua-desk { display: none; }
|
|
259
|
+
@media (min-width: 992px) {
|
|
260
|
+
.cab-gua-mob { display: none !important; }
|
|
261
|
+
.cab-gua-desk { display: block; }
|
|
262
|
+
.cab-gua-bar { padding: 4px 32px !important; }
|
|
263
|
+
}
|
|
264
|
+
</style>
|
|
265
|
+
|
|
245
266
|
<script is:inline define:vars={{ identifier }}>
|
|
246
267
|
document.querySelectorAll(`.${identifier}-toggle`).forEach(btn => {
|
|
247
268
|
btn.addEventListener('click', (e) => {
|