File tree Expand file tree Collapse file tree 1 file changed +2
-7
lines changed
Expand file tree Collapse file tree 1 file changed +2
-7
lines changed Original file line number Diff line number Diff line change 11<script >
22 import IconChevron from ' $lib/icons/icon-chevron.svg?raw' ;
33 import { onMount } from ' svelte' ;
4- import { createEventDispatcher } from ' svelte' ;
54
65 export let id = (Math .random () * 10e15 ).toString (16 );
76 export let type = " checkbox" ; // or "radio"
109 export let foregroundColor = null ;
1110 export let backgroundColor = null ;
1211
13- const dispatch = createEventDispatcher ();
14-
1512 let contentEl, inputEl;
1613 onMount (() => {
1714 contentEl .style .display = inputEl .checked ? ' block' : ' none' ;
1815 });
1916
20- function toggleContent () {
17+ function toggleContent (event ) {
2118 if (inputEl .checked ) {
2219 contentEl .style .display = ' block' ;
2320 contentEl .style .maxHeight = ' 0px' ;
3027 contentEl .style .maxHeight = ' 0px' ;
3128 });
3229 }
33- // Dispatch click event so parent components can handle it (e.g., update URL hash)
34- dispatch (' click' );
3530 }
3631
3732 function onTransitionEnd () {
4944 --background-color: {backgroundColor ?? (style === 'light' ? 'white' : 'black')};
5045 "
5146>
52- <input {type } name ={id } {id } {checked } on:click ={toggleContent } bind:this ={inputEl } />
47+ <input {type } name ={id } {id } {checked } on:click ={toggleContent } on:click bind:this ={inputEl } />
5348 <label for ={id }>
5449 <slot name =" label" ></slot >
5550 <span class ="chevron" >{@html IconChevron }</span >
You can’t perform that action at this time.
0 commit comments