11---
22import { Icon } from " astro-icon/components" ;
33import Logo from " ./Logo.astro" ;
4+ import { Focus } from " ../schema.ts" ;
45
56const links = [
6- { title: " プロジェクト" , to: " /projects/ " },
7- { title: " 記事" , to: " /articles/ " },
8- { title: " メンバー" , to: " /members/ " },
9- { title: " 参加" , to: " /join/ " },
10- { title: " お問い合わせ" , to: " /contact/ " },
7+ { title: " プロジェクト" , to: " /projects" , focus: Focus . projects },
8+ { title: " 記事" , to: " /articles" , focus: Focus . articles },
9+ { title: " メンバー" , to: " /members" , focus: Focus . members },
10+ { title: " 参加" , to: " /join" , focus: Focus . join },
11+ { title: " お問い合わせ" , to: " /contact" , focus: Focus . contact },
1112];
13+
14+ interface Props {
15+ focus: Focus ;
16+ }
17+ const { focus } = Astro .props ;
1218---
1319
1420<header class =" sticky" >
@@ -40,7 +46,10 @@ const links = [
4046 <li >
4147 <a
4248 href = { link .to }
43- class = " flex items-center h-full px-6 hover:bg-gray-100"
49+ class :list = { [
50+ " flex items-center h-full px-6 hover:bg-gray-100 navigation-bar" ,
51+ focus === link .focus && " bg-amber-50" ,
52+ ]}
4453 >
4554 { link .title }
4655 </a >
@@ -57,28 +66,32 @@ const links = [
5766 <Icon name =" feather:menu" class =" w-6 h-6 text-gray-600" />
5867 </button >
5968 </div >
60- </header >
61- <div
62- id =" navigation_panel"
63- popover
64- class =" w-full
69+ <div
70+ id =" navigation_panel"
71+ popover
72+ class =" w-full
6573 absolute
6674 top-16
6775 transition-opacity
6876 duration-300"
69- >
70- <ul class =" " >
71- {
72- links .map ((link ) => (
73- <li >
74- <a href = { link .to } class = " block px-4 py-2 hover:bg-gray-100" >
75- { link .title }
76- </a >
77- </li >
78- ))
79- }
80- </ul >
81- </div >
77+ >
78+ <ul class =" " >
79+ {
80+ links .map ((link ) => (
81+ <li >
82+ <a
83+ href = { link .to }
84+ class = " block px-4 py-2 hover:bg-gray-100 transition-all duration-300"
85+ >
86+ { link .title }
87+ </a >
88+ </li >
89+ ))
90+ }
91+ </ul >
92+ </div >
93+ </header >
94+
8295<style >
8396 /* https://stackoverflow.com/questions/77042256/css-transition-animation-not-working-for-popover-attribute */
8497 /* TODO: not working now */
@@ -93,4 +106,14 @@ const links = [
93106 opacity 0.3s,
94107 display 0.3s allow-discrete;
95108 }
109+
110+ .navigation-bar {
111+ background: linear-gradient(currentColor 0 0) bottom left/
112+ var(--underline-width, 0%) 0.1em no-repeat;
113+ text-decoration: none;
114+ transition: background-size 0.5s;
115+ }
116+ .navigation-bar:hover {
117+ --underline-width: 100%;
118+ }
96119</style >
0 commit comments