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
4 changes: 2 additions & 2 deletions code/addons/a11y/src/components/VisionSimulator.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const meta = preview.meta({
export default meta;

const openMenu: PlayFunction = async ({ canvas, userEvent }) => {
await userEvent.click(canvas.getByRole('button', { name: 'Vision simulator' }));
await userEvent.click(canvas.getByRole('button', { name: 'Vision filter' }));
};
Comment thread
ghengeveld marked this conversation as resolved.

export const Default = meta.story({
Expand All @@ -51,7 +51,7 @@ export const Selection = meta.story({
await context.userEvent.click(await screen.findByText('Blurred vision'));
await expect(managerContext.api.updateGlobals).toHaveBeenCalledWith({ vision: 'blurred' });
await expect(
context.canvas.getByRole('button', { name: 'Vision simulator Blurred vision' })
context.canvas.getByRole('button', { name: 'Vision filter Blurred vision' })
).toBeVisible();
},
});
8 changes: 6 additions & 2 deletions code/addons/a11y/src/components/VisionSimulator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ const ColorIcon = styled.span<{ $filter: string }>(
);

export const VisionSimulator = () => {
const [globals, updateGlobals] = useGlobals();
const [globals, updateGlobals, storyGlobals] = useGlobals();
const value = globals[VISION_GLOBAL_KEY];
const isLocked = storyGlobals[VISION_GLOBAL_KEY] !== undefined;

const options = Object.entries(filters).map(([key, { label, percentage }]) => ({
title: label,
Expand All @@ -52,7 +53,10 @@ export const VisionSimulator = () => {
resetLabel="Reset color filter"
onReset={() => updateGlobals({ [VISION_GLOBAL_KEY]: undefined })}
icon={<AccessibilityIcon />}
ariaLabel="Vision simulator"
disabled={isLocked}
ariaLabel={isLocked ? 'Vision filter set by story globals' : 'Vision filter'}
ariaDescription="Select a vision filter among predefined options, or reset to remove the filter."
tooltip={isLocked ? 'Vision filter set by story globals' : 'Change vision filter'}
Comment thread
ghengeveld marked this conversation as resolved.
defaultOptions={value}
options={options}
onSelect={(selected) => updateGlobals({ [VISION_GLOBAL_KEY]: selected })}
Expand Down
Loading