From 1e471e0e3fbf58f2fb9f3e82c625a500fef74ab1 Mon Sep 17 00:00:00 2001 From: Victoria League Date: Wed, 7 Aug 2024 10:52:55 -0400 Subject: [PATCH] [CL-271] Update styles for toggle (#10377) --- .../src/toggle-group/toggle-group.mdx | 31 ++++----- .../src/toggle-group/toggle-group.stories.ts | 28 ++++++++ .../src/toggle-group/toggle.component.html | 9 ++- .../src/toggle-group/toggle.component.ts | 67 ++++++++++++------- 4 files changed, 94 insertions(+), 41 deletions(-) diff --git a/libs/components/src/toggle-group/toggle-group.mdx b/libs/components/src/toggle-group/toggle-group.mdx index c5726555695..cd487934cec 100644 --- a/libs/components/src/toggle-group/toggle-group.mdx +++ b/libs/components/src/toggle-group/toggle-group.mdx @@ -1,4 +1,4 @@ -import { Meta, Story, Primary, Controls } from "@storybook/addon-docs"; +import { Meta, Story, Primary, Controls, Canvas } from "@storybook/addon-docs"; import * as stories from "./toggle-group.stories"; @@ -15,22 +15,23 @@ Toggle groups function as radio buttons and a radio group under the hood. A button in a toggle group can have a badge counter added to show the number of items existing within that filter. -For focus states, use `focus-visible`. +If the labels in a toggle group would overflow the width of the toggle group container, then the +labels will wrap to 2 lines and truncate with an ellipsis past that. The full label text is +accessible via the `title` prop (i.e. visible on hover). + + + + + + + + - ## Accessibility -- Follow contrast rules for the main button styles. -- Focus: - - Implement as a radio group with button styling and a context label (context label can be screen - reader only depending on use case). - - Since only 1 button can be selected at a time to filter the toggle group acts similarly to a - radio group. - - When moving focus to a button group, the focus should always move to the selected button. The - screen reader should then announce the button group: example “[context label], [button content] - selected, of [# of buttons]”), the number of buttons and the currently selected button. The user - may navigate the options then via left/right arrow keys. - -See WCAG for more: https://www.w3.org/WAI/ARIA/apg/patterns/radio/ +- Since only 1 button can be selected at a time, the toggle group acts similarly to a radio group. +- The user may navigate the options via left/right arrow keys. +- The screen reader will announce the button group: example “[context label], [button content] + selected, of [# of buttons]”), the number of buttons and the currently selected button. diff --git a/libs/components/src/toggle-group/toggle-group.stories.ts b/libs/components/src/toggle-group/toggle-group.stories.ts index 8fdd22efe3f..78f7d700b57 100644 --- a/libs/components/src/toggle-group/toggle-group.stories.ts +++ b/libs/components/src/toggle-group/toggle-group.stories.ts @@ -46,3 +46,31 @@ export const Default: Story = { selected: "all", }, }; + +export const LabelWrap: Story = { + render: (args) => ({ + props: args, + template: /* HTML */ ` + + + All of the best things 3 + + + Invited to a cool party + + + Accepted the invitation2 + + + Deactivated forever + + `, + }), + args: { + selected: "all", + }, +}; diff --git a/libs/components/src/toggle-group/toggle.component.html b/libs/components/src/toggle-group/toggle.component.html index 471ed5f0c03..4e12aee9064 100644 --- a/libs/components/src/toggle-group/toggle.component.html +++ b/libs/components/src/toggle-group/toggle.component.html @@ -6,6 +6,11 @@ [checked]="selected" (change)="onInputInteraction()" /> -