Feat/BOOK-117 svg accessibility
* feat(BOOK-117): Added aria-label to Scandic Friends levels * feat(BOOK-117): Added aria-label to hotel logos * feat(BOOK-117): Added alt text to app download images * feat(BOOK-117): Added same logo component to footer as the one in the header * feat(BOOK-117): Added aria attributes to icons similar to how we handled MaterialIcon aria attributes Approved-by: Bianca Widstam Approved-by: Matilda Landström
This commit is contained in:
@@ -4,6 +4,7 @@ import { iconVariants } from '../variants'
|
||||
|
||||
import type { VariantProps } from 'class-variance-authority'
|
||||
import { HTMLAttributes } from 'react'
|
||||
import { getIconAriaProps } from '../utils'
|
||||
|
||||
export interface MaterialIconProps
|
||||
extends Pick<MaterialSymbolProps, 'size' | 'icon' | 'className' | 'style'>,
|
||||
@@ -20,22 +21,18 @@ export function MaterialIcon({
|
||||
...props
|
||||
}: MaterialIconProps) {
|
||||
const classNames = iconVariants({ className, color })
|
||||
const { role, 'aria-label': ariaLabel, 'aria-hidden': ariaHidden } = props
|
||||
|
||||
// Automatically decide whether to hide from assistive tech
|
||||
const computedAriaHidden =
|
||||
ariaHidden !== undefined ? ariaHidden : ariaLabel || role ? false : true
|
||||
const ariaProps = getIconAriaProps(props)
|
||||
|
||||
return (
|
||||
// The span is used to prevent the MaterialSymbol from being underlined when used inside a link or button
|
||||
<span>
|
||||
<MaterialSymbol
|
||||
{...props}
|
||||
className={classNames}
|
||||
data-testid="MaterialIcon"
|
||||
size={size}
|
||||
fill={isFilled}
|
||||
aria-hidden={computedAriaHidden}
|
||||
{...props}
|
||||
{...ariaProps}
|
||||
/>
|
||||
</span>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user