Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -247,3 +247,49 @@ export const WithCustomIcon: StoryComponentType = {
);
},
};

/**
* ActivityIconButton can be configured to be toggleable. This is useful for
* features like toggling a microphone on and off.
*
* Note that the `aria-pressed` attribute is used to indicate the toggle state
* of the button. This is important for accessibility, as it allows screen
* readers to announce the current state of the button to users.
*/
export const Toggleable: StoryComponentType = {
render: function Render() {
const [on, setOn] = React.useState(false);
return (
<View
style={{
gap: sizing.size_080,
flexDirection: "row",
placeItems: "center",
}}
>
<ActivityIconButton
icon={
on
? IconMappings.pencilSimpleBold
: IconMappings.pencilSimple
}
onClick={(e) => {
setOn(!on);
action("clicked")(e);
}}
kind="secondary"
label="Toggleable"
aria-pressed={on}
/>
<ActivityIconButton
icon={IconMappings.pencilSimple}
onClick={(e) => {
action("clicked")(e);
}}
kind="secondary"
label="Normal button"
/>
</View>
);
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,12 @@ const _generateStyles = (

[":is(:active) .chonky" as any]: chonkyPressed,

[":is([aria-pressed=true]) .chonky" as any]: {
...chonkyPressed,
paddingBlock: "1.6rem",
transform: "none",
},

// :focus-visible -> Provide focus styles for keyboard users only.
...focusStyles.focus,
},
Expand Down
Loading