Skip to content
Merged
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
58 changes: 57 additions & 1 deletion src/components/Dropdown/Dropdown.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
TwoStateButton,
} from '../Button';
import { CheckBox } from '../CheckBox';
import { ConfigProvider } from '../ConfigProvider';
import { Dropdown } from './';
import { Icon, IconName } from '../Icon';
import { List } from '../List';
Expand Down Expand Up @@ -200,6 +201,54 @@ const Dropdown_Button_Story: ComponentStory<typeof Dropdown> = (args) => {
);
};

const Dropdown_Button_KeyboardFocus_Story: ComponentStory<typeof Dropdown> = (
args
) => {
const [visible1, setVisibility1] = useState(false);
const [visible2, setVisibility2] = useState(false);
return (
<ConfigProvider
focusVisibleOptions={{
focusVisible: true,
focusVisibleElement: document.documentElement,
}}
>
<Stack direction="horizontal" flexGap="xl">
<Dropdown
{...args}
onVisibleChange={(isVisible) => setVisibility1(isVisible)}
>
<Button
alignIcon={ButtonIconAlign.Right}
iconProps={{
path: IconName.mdiChevronDown,
rotate: visible1 ? 180 : 0,
}}
id="dropdown-trigger-1"
text={'First dropdown'}
variant={ButtonVariant.Default}
/>
</Dropdown>
<Dropdown
{...args}
onVisibleChange={(isVisible) => setVisibility2(isVisible)}
>
<Button
alignIcon={ButtonIconAlign.Right}
iconProps={{
path: IconName.mdiChevronDown,
rotate: visible2 ? 180 : 0,
}}
id="dropdown-trigger-2"
text={'Second dropdown'}
variant={ButtonVariant.Default}
/>
</Dropdown>
</Stack>
</ConfigProvider>
);
};

const Dropdown_IconButton_Story: ComponentStory<typeof Dropdown> = (args) => {
const [visible, setVisibility] = useState(false);
return (
Expand Down Expand Up @@ -428,6 +477,8 @@ const Dropdown_Advanced_Story: ComponentStory<typeof Dropdown> = (args) => {
};

export const Dropdown_Button = Dropdown_Button_Story.bind({});
export const Dropdown_Button_KeyboardFocus =
Dropdown_Button_KeyboardFocus_Story.bind({});
export const Dropdown_IconButton = Dropdown_IconButton_Story.bind({});
export const Dropdown_Div = Dropdown_Div_Story.bind({});
export const Dropdown_External = Dropdown_External_Story.bind({});
Expand All @@ -439,6 +490,7 @@ export const Dropdown_Additional_Item = Dropdown_Button_Story.bind({});
// See https://www.npmjs.com/package/babel-plugin-named-exports-order
export const __namedExportsOrder = [
'Dropdown_Button',
'Dropdown_Button_KeyboardFocus',
'Dropdown_IconButton',
'Dropdown_Div',
'Dropdown_External',
Expand All @@ -464,13 +516,17 @@ const dropdownArgs: Object = {
role: 'listbox',
'aria-label': 'Dropdown overlay',
},
toggleDropdownOnShiftTab: true,
};

Dropdown_Button.args = {
...dropdownArgs,
};

Dropdown_Button_KeyboardFocus.args = {
...dropdownArgs,
shouldCloseOnTab: true,
};

Dropdown_Div.args = {
...dropdownArgs,
};
Expand Down
Loading
Loading