1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-25 00:07:47 +01:00

chore: use new ScreenReaderOnly component in config buttons (#7352)

This PR uses the new ScreenReaderOnly component in existing code,
replacing custom code with a shared component.
This commit is contained in:
Thomas Heartman 2024-06-12 11:04:47 +02:00 committed by GitHub
parent 2191de7713
commit 4c4d6e8aeb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 5 additions and 11 deletions

View File

@ -1,5 +1,4 @@
import { Popover, styled } from '@mui/material';
import { visuallyHiddenStyles } from './shared.styles';
export const StyledDropdown = styled('div')(({ theme }) => ({
padding: theme.spacing(2),
@ -15,11 +14,6 @@ export const StyledPopover = styled(Popover)(({ theme }) => ({
},
}));
export const HiddenDescription = styled('p')(() => ({
...visuallyHiddenStyles,
position: 'absolute',
}));
export const ButtonLabel = styled('span', {
shouldForwardProp: (prop) => prop !== 'labelWidth',
})<{ labelWidth?: string }>(({ labelWidth, theme }) => ({

View File

@ -4,11 +4,11 @@ import { Box, Button } from '@mui/material';
import {
StyledDropdown,
StyledPopover,
HiddenDescription,
ButtonLabel,
StyledTooltipContent,
} from './ConfigButton.styles';
import { TooltipResolver } from 'component/common/TooltipResolver/TooltipResolver';
import { ScreenReaderOnly } from 'component/common/ScreenReaderOnly/ScreenReaderOnly';
export type ConfigButtonProps = {
button: {
@ -95,9 +95,9 @@ export const ConfigButton: FC<PropsWithChildren<ConfigButtonProps>> = ({
horizontal: 'left',
}}
>
<HiddenDescription id={descriptionId}>
{description}
</HiddenDescription>
<ScreenReaderOnly>
<p id={descriptionId}>{description}</p>
</ScreenReaderOnly>
<StyledDropdown aria-describedby={descriptionId}>
{children}
</StyledDropdown>

View File

@ -1,6 +1,6 @@
import { TextField, styled } from '@mui/material';
export const visuallyHiddenStyles = {
const visuallyHiddenStyles = {
border: 0,
clip: 'rect(0 0 0 0)',
height: 'auto',