-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(docs): add checkbox and radio button card code snippet (#1917)
- Loading branch information
Showing
4 changed files
with
65 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@swisspost/design-system-documentation': patch | ||
--- | ||
|
||
Added a code snippet for patching missing `:has` selector support in Firefox in the Checkbox- and Radiobutton-Card stories. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
packages/documentation/src/stories/components/choice-card/firefox-fallback.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
['focusin', 'focusout', 'input'].forEach(t => | ||
document.addEventListener(t, e => { | ||
if (!(e.target instanceof Element) || e.target.nodeName !== 'input') return; | ||
const parent = e.target.parentElement; | ||
if (!parent?.classList.contains('radio-button-card')) return; | ||
switch (e.type) { | ||
case 'focusin': | ||
parent.classList.add('focused'); | ||
break; | ||
case 'focusout': | ||
parent.classList.remove('focused'); | ||
break; | ||
case 'input': | ||
parent.classList.toggle('checked', (e.target as HTMLInputElement).checked); | ||
break; | ||
} | ||
}), | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters