File tree Expand file tree Collapse file tree 1 file changed +18
-3
lines changed
template/components/InteractiveDemo Expand file tree Collapse file tree 1 file changed +18
-3
lines changed Original file line number Diff line number Diff line change 2222 ( n ) => n instanceof HTMLElement
2323 ) ;
2424
25+ optionButtons . forEach ( ( btn ) => {
26+ if ( ! btn . hasAttribute ( "data-default-variant" ) ) {
27+ btn . setAttribute ( "data-default-variant" , btn . getAttribute ( "data-variant" ) || "filled" ) ;
28+ }
29+ } ) ;
30+
2531 const getMode = ( ) => root . getAttribute ( "data-mode" ) === "dark" ? "dark" : "light" ;
2632 const setMode = ( mode ) => root . setAttribute ( "data-mode" , mode ) ;
2733
5662
5763 optionButtons . forEach ( ( btn ) => {
5864 const id = btn . getAttribute ( "data-image-id" ) ;
59- if ( id === activeId ) btn . setAttribute ( "data-active" , "true" ) ;
60- else btn . removeAttribute ( "data-active" ) ;
65+ const isActive = id === activeId ;
66+
67+ if ( isActive ) {
68+ btn . setAttribute ( "data-active" , "true" ) ;
69+ btn . setAttribute ( "aria-pressed" , "true" ) ;
70+ const defaultVariant = btn . getAttribute ( "data-default-variant" ) || "filled" ;
71+ btn . setAttribute ( "data-variant" , defaultVariant ) ;
72+ } else {
73+ btn . removeAttribute ( "data-active" ) ;
74+ btn . setAttribute ( "aria-pressed" , "false" ) ;
75+ btn . setAttribute ( "data-variant" , "ghost" ) ;
76+ }
6177 } ) ;
6278
6379 cards . forEach ( ( card ) => {
96112 e . stopPropagation ( ) ;
97113
98114 const to = btn . getAttribute ( "data-image-toggle-to" ) ;
99-
100115 if ( isMode ( to ) ) {
101116 setMode ( to ) ;
102117 update ( ) ;
You can’t perform that action at this time.
0 commit comments