11---
2- import type { HTMLAttributes } from " astro/types" ;
3- import Heading from " ./Heading.astro" ;
4- import { useI18n } from " astro-nanostores-i18n:runtime" ;
2+ import type { HTMLAttributes } from ' astro/types' ;
3+ import Heading from ' ./Heading.astro' ;
4+ import { useI18n } from ' astro-nanostores-i18n:runtime' ;
55
66/**
77 * Accordion Item Component
88 *
99 * @description An individual accordion item that can be expanded/collapsed with smooth animations
1010 */
1111
12- type Props = HTMLAttributes <" li " > & {
12+ type Props = HTMLAttributes <' li ' > & {
1313 /**
1414 * Id of the item
1515 */
@@ -27,17 +27,17 @@ type Props = HTMLAttributes<"li"> & {
2727 * Heading level for the title (h1-h6)
2828 * @default ' h3'
2929 */
30- headingLevel? : " h1 " | " h2 " | " h3 " | " h4 " | " h5 " | " h6 " ;
30+ headingLevel? : ' h1 ' | ' h2 ' | ' h3 ' | ' h4 ' | ' h5 ' | ' h6 ' ;
3131 /**
3232 * Visual size of the heading (can differ from semantic level)
3333 * @default ' h6'
3434 */
35- headingSize? : " h1 " | " h2 " | " h3 " | " h4 " | " h5 " | " h6 " ;
35+ headingSize? : ' h1 ' | ' h2 ' | ' h3 ' | ' h4 ' | ' h5 ' | ' h6 ' ;
3636 /**
3737 * Visual style variant of the accordion
3838 * @default ' chevron'
3939 */
40- variant? : " minimal" | " chevron" ;
40+ variant? : ' minimal' | ' chevron' ;
4141 /**
4242 * Whether the accordion item is initially open
4343 * @default false
@@ -50,42 +50,54 @@ type Props = HTMLAttributes<"li"> & {
5050 openOnUrlReference? : boolean ;
5151};
5252
53- const translations = useI18n (" accordion.item" , {
54- more: " Mehr anzeigen" ,
55- less: " Weniger anzeigen" ,
53+ const translations = useI18n (' accordion.item' , {
54+ more: ' Mehr anzeigen' ,
55+ less: ' Weniger anzeigen' ,
5656});
5757
5858const {
5959 id,
6060 class : className,
6161 name,
62- headingLevel = " h3 " ,
63- headingSize = " h6 " ,
64- variant = " chevron" ,
62+ headingLevel = ' h3 ' ,
63+ headingSize = ' h6 ' ,
64+ variant = ' chevron' ,
6565 open = false ,
6666 openOnUrlReference = true ,
6767 ... rest
6868}: Props = Astro .props ;
6969---
7070
71- <li id ={ id } class:list ={ [" item" , className ]} {... rest } data-dynamic ={ openOnUrlReference } >
71+ <li id ={ id } class:list ={ [' item' , className ]} {... rest } data-dynamic ={ openOnUrlReference } >
7272 <slot name =" pretext" />
73- <details class:list ={ [" wrapper" , ` variant-${variant } ` ]} name ={ name } {... open ? { open } : {}}>
73+ <details class:list ={ [' wrapper' , ` variant-${variant } ` ]} name ={ name } {... ( open ? { open } : {}) }>
7474 <summary class =" header" >
7575 <div class =" title" >
76- { variant === " chevron" && (
76+ { variant === ' chevron' && (
7777 <Heading level = { headingLevel } size = { headingSize } >
7878 <>
7979 <slot name = " title" />
8080 <span class = " icon-chevron" >
81- <svg aria-hidden = " true" width = " 12" height = " 8" fill = " none" xmlns = " http://www.w3.org/2000/svg" >
82- <path d = " M1.4 1.6L6 6.2l4.6-4.6" stroke = " currentColor" stroke-width = " 2" stroke-linecap = " round" stroke-linejoin = " round" />
83- </svg >
81+ <svg
82+ aria-hidden = " true"
83+ width = " 12"
84+ height = " 8"
85+ fill = " none"
86+ xmlns = " http://www.w3.org/2000/svg"
87+ >
88+ <path
89+ d = " M1.4 1.6L6 6.2l4.6-4.6"
90+ stroke = " currentColor"
91+ stroke-width = " 2"
92+ stroke-linecap = " round"
93+ stroke-linejoin = " round"
94+ />
95+ </svg >
8496 </span >
8597 </>
8698 </Heading >
8799 )}
88- { variant === " minimal" && (
100+ { variant === ' minimal' && (
89101 <>
90102 <span class = " toggle-text more" >{ translations .more } </span >
91103 <span class = " toggle-text less" >{ translations .less } </span >
@@ -191,7 +203,7 @@ const {
191203 :where(header)::marker,
192204 :where(.header)::-webkit-details-marker {
193205 display: none;
194- content: "" ;
206+ content: '' ;
195207 }
196208
197209 :where(.header .title:hover),
@@ -232,7 +244,7 @@ const {
232244
233245 if (!hash) return;
234246
235- const id = hash.split("#" )[1];
247+ const id = hash.split('#' )[1];
236248
237249 if (!id) return;
238250 const element = document.getElementById(id);
@@ -243,10 +255,10 @@ const {
243255
244256 if (!dynamicOpening) return;
245257
246- const details = element.getElementsByTagName(" details" );
258+ const details = element.getElementsByTagName(' details' );
247259
248260 if (details.length === 1) {
249- details[0]?.setAttribute(" open", "" );
261+ details[0]?.setAttribute(' open', '' );
250262 }
251263 };
252264
0 commit comments