-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ButtonToggle): implement new icon variant of toggle (#860)
* feat(buttontoggle): first implementation of the ButtonToggle component * test(buttontoggle): added tests * fix(buttontoggle): fix A11y errors * refactor(buttontoggle): fix styling bugs in CellBasic
- Loading branch information
1 parent
8820260
commit 3f532ad
Showing
26 changed files
with
390 additions
and
37 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
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
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
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
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
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
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
29 changes: 29 additions & 0 deletions
29
packages/components/src/core/ButtonToggle/__storybook__/constants.tsx
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,29 @@ | ||
import CustomSdsIcon from "src/common/storybook/customSdsIcon"; | ||
import CustomSvgIcon from "src/common/storybook/customSvgIcon"; | ||
|
||
export const BUTTON_TOGGLE_EXCLUDED_CONTROLS = [ | ||
"sdsSize", | ||
"icon", | ||
"sdsStage", | ||
"sdsType", | ||
]; | ||
|
||
export const BUTTON_TOGGLE_ICON_OPTIONS = [ | ||
"InfoCircle", | ||
"SlidersHorizontal", | ||
"Filter", | ||
"DotsHorizontal", | ||
"LinesHorizontal3", | ||
<CustomSdsIcon key="customSdsIcon" />, | ||
<CustomSvgIcon key="customIcon" />, | ||
]; | ||
|
||
export const BUTTON_TOGGLE_ICON_LABELS = [ | ||
"SDS Icon: InfoCircle (s/m/l)", | ||
"SDS Icon: SlidersHorizontal (m/l)", | ||
"SDS Icon: Filter (s)", | ||
"SDS Icon: DotsHorizontal (s/m/l)", | ||
"SDS Icon: LinesHorizontal3 (s/m/l)", | ||
"Custom SDS Icon (s/m/l)", | ||
"Custom SVG Icon (s/m/l)", | ||
]; |
76 changes: 76 additions & 0 deletions
76
packages/components/src/core/ButtonToggle/__storybook__/index.stories.tsx
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,76 @@ | ||
import { Args, Meta } from "@storybook/react"; | ||
import { BADGE } from "@geometricpanda/storybook-addon-badges"; | ||
import { ButtonToggle } from "./stories/default"; | ||
import { | ||
BUTTON_TOGGLE_EXCLUDED_CONTROLS, | ||
BUTTON_TOGGLE_ICON_LABELS, | ||
BUTTON_TOGGLE_ICON_OPTIONS, | ||
} from "./constants"; | ||
import { TestDemo } from "./stories/test"; | ||
|
||
export default { | ||
argTypes: { | ||
disabled: { | ||
control: { | ||
type: "boolean", | ||
}, | ||
}, | ||
icon: { | ||
control: { | ||
labels: BUTTON_TOGGLE_ICON_LABELS, | ||
type: "select", | ||
}, | ||
mapping: BUTTON_TOGGLE_ICON_OPTIONS, | ||
options: Object.keys(BUTTON_TOGGLE_ICON_OPTIONS), | ||
}, | ||
sdsSize: { | ||
control: { | ||
type: "select", | ||
}, | ||
options: ["small", "medium", "large"], | ||
}, | ||
sdsStage: { | ||
control: { | ||
type: "radio", | ||
}, | ||
options: ["on", "off"], | ||
}, | ||
sdsType: { | ||
control: { | ||
type: "radio", | ||
}, | ||
options: ["primary", "secondary"], | ||
}, | ||
}, | ||
component: ButtonToggle, | ||
parameters: { | ||
badges: [BADGE.BETA], | ||
}, | ||
title: "Components/Buttons/ButtonToggle", | ||
} as Meta; | ||
|
||
// Default | ||
|
||
export const Default = { | ||
args: { | ||
disabled: false, | ||
icon: "InfoCircle", | ||
sdsSize: "medium", | ||
sdsStage: "off", | ||
sdsType: "primary", | ||
}, | ||
}; | ||
|
||
// Test | ||
|
||
export const Test = { | ||
parameters: { | ||
controls: { | ||
exclude: BUTTON_TOGGLE_EXCLUDED_CONTROLS, | ||
}, | ||
snapshot: { | ||
skip: true, | ||
}, | ||
}, | ||
render: (args: Args) => <TestDemo icon="InfoCircle" {...args} />, | ||
}; |
8 changes: 8 additions & 0 deletions
8
packages/components/src/core/ButtonToggle/__storybook__/stories/default.tsx
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,8 @@ | ||
import { Args } from "@storybook/react"; | ||
import RawButtonToggle from "src/core/ButtonToggle"; | ||
|
||
export const ButtonToggle = (props: Args): JSX.Element => { | ||
const { icon } = props; | ||
|
||
return <RawButtonToggle aria-label="button-toggle" icon={icon} {...props} />; | ||
}; |
15 changes: 15 additions & 0 deletions
15
packages/components/src/core/ButtonToggle/__storybook__/stories/test.tsx
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,15 @@ | ||
import { Args } from "@storybook/react"; | ||
import ButtonToggle from "src/core/ButtonToggle"; | ||
|
||
export const TestDemo = (props: Args): JSX.Element => { | ||
const { icon } = props; | ||
|
||
return ( | ||
<ButtonToggle | ||
data-testid="button-toggle" | ||
aria-label="button-toggle" | ||
icon={icon} | ||
{...props} | ||
/> | ||
); | ||
}; |
13 changes: 13 additions & 0 deletions
13
packages/components/src/core/ButtonToggle/__tests__/ButtonToggle.namespace-test.tsx
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,13 @@ | ||
import { ButtonToggle, ButtonToggleProps } from "@czi-sds/components"; | ||
|
||
const ButtonToggleNameSpaceTest = (props: ButtonToggleProps) => { | ||
return ( | ||
<ButtonToggle | ||
sdsSize="medium" | ||
sdsType="primary" | ||
sdsStage="off" | ||
icon="InfoCircle" | ||
disabled={false} | ||
/> | ||
); | ||
}; |
30 changes: 30 additions & 0 deletions
30
packages/components/src/core/ButtonToggle/__tests__/__snapshots__/index.test.tsx.snap
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,30 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`<ButtonToggle /> Default story renders snapshot 1`] = ` | ||
<button | ||
aria-label="button-toggle" | ||
class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeMedium css-ul4hcs-MuiButtonBase-root-MuiIconButton-root" | ||
icon="InfoCircle" | ||
tabindex="0" | ||
type="button" | ||
> | ||
<div | ||
class="css-1ft6wgl" | ||
> | ||
<svg | ||
aria-hidden="true" | ||
class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-1q6hio5-MuiSvgIcon-root" | ||
data-file-name="IconInfoCircleLarge" | ||
data-testid="IconInfoCircleLarge" | ||
fillcontrast="white" | ||
focusable="false" | ||
height="24" | ||
viewBox="0 0 24 24" | ||
width="24" | ||
/> | ||
</div> | ||
<span | ||
class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root" | ||
/> | ||
</button> | ||
`; |
Oops, something went wrong.