Skip to content

Commit 648fabf

Browse files
authored
Merge pull request #34 from scesi/feature/astro-transitions
Feature/astro transitions
2 parents 16a8bff + eadf804 commit 648fabf

File tree

3 files changed

+72
-3
lines changed

3 files changed

+72
-3
lines changed

eslint.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import css from '@eslint/css';
55
import { defineConfig } from 'eslint/config';
66

77
export default defineConfig([
8+
{
9+
ignores: ['dist/**', '.astro/**', 'node_modules/**', '.astro/content.d.ts'],
10+
},
811
{
912
files: ['**/*.{js,mjs,cjs,ts,mts,cts}'],
1013
plugins: { js },

src/components/Header.astro

Lines changed: 68 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
2-
2+
// Nota: 'astro:transitions' no disponible (tipos no presentes). Usamos clase utilitaria para fade.
3+
const navFade = 'fade-link';
34
---
45

56
<a
@@ -27,30 +28,40 @@
2728
>
2829
<a
2930
href="/cronograma"
31+
transition:persist
32+
class:list={[navFade]}
3033
data-section="cronograma"
3134
class="nav-link px-4 py-2 rounded-lg border-2 border-transparent hover:text-[#FFC727] focus-visible:text-[#FFC727] focus-visible:border-[#FFC727] focus:outline-none transition"
3235
>Cronograma</a
3336
>
3437
<a
3538
href="/#ubicacion"
39+
transition:persist
40+
class:list={[navFade]}
3641
data-section="ubicacion"
3742
class="nav-link px-4 py-2 rounded-lg border-2 border-transparent hover:text-[#FFC727] focus-visible:text-[#FFC727] focus-visible:border-[#FFC727] focus:outline-none transition"
3843
>Ubicación</a
3944
>
4045
<a
4146
href="/#sponsors"
47+
transition:persist
48+
class:list={[navFade]}
4249
data-section="sponsors"
4350
class="nav-link px-4 py-2 rounded-lg border-2 border-transparent hover:text-[#FFC727] focus-visible:text-[#FFC727] focus-visible:border-[#FFC727] focus:outline-none transition"
4451
>Sponsors</a
4552
>
4653
<a
4754
href="/#sobre-nosotros"
55+
transition:persist
56+
class:list={[navFade]}
4857
data-section="sobre-nosotros"
4958
class="nav-link px-4 py-2 rounded-lg border-2 border-transparent hover:text-[#FFC727] focus-visible:text-[#FFC727] focus-visible:border-[#FFC727] focus:outline-none transition"
5059
>Sobre nosotros</a
5160
>
5261
<a
5362
href="/faqs"
63+
transition:persist
64+
class:list={[navFade]}
5465
data-section="faqs"
5566
class="nav-link px-4 py-2 rounded-lg border-2 border-transparent hover:text-[#FFC727] focus-visible:text-[#FFC727] focus-visible:border-[#FFC727] focus:outline-none transition"
5667
>FAQs</a
@@ -109,42 +120,54 @@
109120
<li>
110121
<a
111122
href="/cronograma"
123+
transition:persist
124+
class:list={[navFade]}
112125
class="block py-3 px-3 rounded-lg border-2 border-transparent hover:bg-white/10 transition"
113126
>Cronograma</a
114127
>
115128
</li>
116129
<li>
117130
<a
118131
href="/#ubicacion"
132+
transition:persist
133+
class:list={[navFade]}
119134
class="block py-3 px-3 rounded-lg border-2 border-transparent hover:bg-white/10 transition"
120135
>Ubicación</a
121136
>
122137
</li>
123138
<li>
124139
<a
125140
href="/#sponsors"
141+
transition:persist
142+
class:list={[navFade]}
126143
class="block py-3 px-3 rounded-lg border-2 border-transparent hover:bg-white/10 transition"
127144
>Sponsors</a
128145
>
129146
</li>
130147
<li>
131148
<a
132149
href="/#sobre-nosotros"
150+
transition:persist
151+
class:list={[navFade]}
133152
class="block py-3 px-3 rounded-lg border-2 border-transparent hover:bg-white/10 transition"
134153
>Sobre nosotros</a
135154
>
136155
</li>
137156
<li>
138157
<a
139158
href="/faqs"
159+
transition:persist
160+
class:list={[navFade]}
140161
class="block py-3 px-3 rounded-lg border-2 border-transparent hover:bg-white/10 transition"
141162
>FAQs</a
142163
>
143164
</li>
144165
</ul>
145166
<div class="pt-3">
146167
<a
147-
href="#"
168+
href="https://forms.gle/5tt3AwhfMw22aKBD6"
169+
target="_blank"
170+
rel="noopener noreferrer"
148171
aria-label="Registrate"
149172
class="block text-center bg-[#178F4E] hover:bg-[#11733E] text-white hover:text-[#FFC727] font-bold py-3 px-10 rounded-md border-2 border-white hover:border-[#FFC727] transition shadow-sm tracking-wide text-[20px] leading-none focus:outline-none"
150173
>
@@ -261,6 +284,32 @@
261284
}
262285
});
263286
}
287+
288+
// View Transition + smooth scroll para enlaces hash internos
289+
const hashLinks = document.querySelectorAll('a[href^="/#"], a[href^="#"]');
290+
hashLinks.forEach((el) => {
291+
const link = el as HTMLAnchorElement;
292+
link.addEventListener('click', (e) => {
293+
const url = new URL(link.href, window.location.origin);
294+
const hash = url.hash.replace('#', '');
295+
if (!hash) return;
296+
const target = document.getElementById(hash);
297+
if (!target) return;
298+
// Solo manejar si es misma página
299+
if (url.pathname === window.location.pathname) {
300+
e.preventDefault();
301+
const doScroll = () => {
302+
target.scrollIntoView({ behavior: 'smooth', block: 'start' });
303+
history.pushState(null, '', '#' + hash);
304+
};
305+
if (document.startViewTransition) {
306+
document.startViewTransition(doScroll);
307+
} else {
308+
doScroll();
309+
}
310+
}
311+
});
312+
});
264313
</script>
265314
</header>
266315
<style>
@@ -270,3 +319,20 @@
270319
font-size: 20px;
271320
}
272321
</style>
322+
<style>
323+
.fade-link {
324+
view-transition-name: fade-link;
325+
}
326+
::view-transition-old(fade-link),
327+
::view-transition-new(fade-link) {
328+
animation: fade-link-fade 0.4s ease;
329+
}
330+
@keyframes fade-link-fade {
331+
from {
332+
opacity: 0;
333+
}
334+
to {
335+
opacity: 1;
336+
}
337+
}
338+
</style>

src/components/Hero.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import Countdown from './Countdown.astro';
1313
<img
1414
src="/clean-up-hack.svg"
1515
alt="CleanUp Hack Logo"
16-
class="w-full max-w-[1100px] px-2 md:px-4 drop-shadow-md"
16+
class="w-full max-w-[1100px] px-2 md:px-4 drop-shadow-md view-transition-hero"
1717
/>
1818
<h2
1919
style="font-family: 'Cabin Sketch', cursive;"

0 commit comments

Comments
 (0)