diff --git a/packages/css/index.css b/packages/css/index.css index 147487f86a..81a8086c2a 100644 --- a/packages/css/index.css +++ b/packages/css/index.css @@ -1,4 +1,5 @@ @charset "UTF-8"; @import url('./react-css-modules.css'); +@import url('./utils.css'); @import url('./alert.css'); diff --git a/packages/css/react-css-modules.css b/packages/css/react-css-modules.css index a741bea244..f90a612c9f 100644 --- a/packages/css/react-css-modules.css +++ b/packages/css/react-css-modules.css @@ -1,30 +1,3 @@ -@layer fds.utilities { - /** - * Visually hide an element, but leave it available for screen readers - */ - .fds-utility-visuallyHidden-1ed11112 { - border: 0; - clip: rect(0 0 0 0); - height: 1px; - overflow: hidden; - padding: 0; - position: absolute; - white-space: nowrap; - width: 1px; - } - - /** - * Apply a focus outline on an element when it is focused with keyboard - */ - .fds-utility-focusable-1ed11112:focus-visible { - --fds-focus-border-width: 3px; - - outline: var(--fds-focus-border-width) solid var(--fds-semantic-border-focus-outline); - outline-offset: var(--fds-focus-border-width); - box-shadow: 0 0 0 var(--fds-focus-border-width) var(--fds-semantic-border-focus-boxshadow); - } -} - @layer fds.button { .fds-button-button-8fa00f0f { --fc-button-padding: 0 var(--fds-spacing-4); diff --git a/packages/react/src/utilities/utility.module.css b/packages/css/utils.css similarity index 61% rename from packages/react/src/utilities/utility.module.css rename to packages/css/utils.css index 57f4925100..052347bd19 100644 --- a/packages/react/src/utilities/utility.module.css +++ b/packages/css/utils.css @@ -1,8 +1,8 @@ -@layer fds.utilities { +@layer fds.utils { /** * Visually hide an element, but leave it available for screen readers */ - .visuallyHidden { + .fds-sr-only { border: 0; clip: rect(0 0 0 0); height: 1px; @@ -16,11 +16,13 @@ /** * Apply a focus outline on an element when it is focused with keyboard */ - .focusable:focus-visible { + .fds-focus:focus-visible { --fds-focus-border-width: 3px; - outline: var(--fds-focus-border-width) solid var(--fds-semantic-border-focus-outline); + outline: var(--fds-focus-border-width) solid + var(--fds-semantic-border-focus-outline); outline-offset: var(--fds-focus-border-width); - box-shadow: 0 0 0 var(--fds-focus-border-width) var(--fds-semantic-border-focus-boxshadow); + box-shadow: 0 0 0 var(--fds-focus-border-width) + var(--fds-semantic-border-focus-boxshadow); } } diff --git a/packages/react/scripts/generate-css.ts b/packages/react/scripts/generate-css.ts index 6ddb60bee2..2db40ed3f9 100644 --- a/packages/react/scripts/generate-css.ts +++ b/packages/react/scripts/generate-css.ts @@ -13,7 +13,7 @@ fs.ensureDirSync(outputFolder); /** To exclude files when we start writing css manually */ const ignore = ['']; -const additional = ['utility.module.css']; +const additional = ['']; const findComponentName = (filePath: string) => { let fileName = filePath.split('/src/')[1]; diff --git a/packages/react/src/components/Accordion/AccordionHeader/AccordionHeader.tsx b/packages/react/src/components/Accordion/AccordionHeader/AccordionHeader.tsx index abd180e5c5..bf3f5d14b6 100644 --- a/packages/react/src/components/Accordion/AccordionHeader/AccordionHeader.tsx +++ b/packages/react/src/components/Accordion/AccordionHeader/AccordionHeader.tsx @@ -5,7 +5,6 @@ import { forwardRef, useContext } from 'react'; import { Paragraph, Heading } from '../..'; import classes from '../Accordion.module.css'; -import utilityClasses from '../../../utilities/utility.module.css'; import { AccordionItemContext } from '../AccordionItem'; export type AccordionHeaderProps = { @@ -45,7 +44,7 @@ export const AccordionHeader = forwardRef< > diff --git a/packages/react/src/components/SkipLink/SkipLink.tsx b/packages/react/src/components/SkipLink/SkipLink.tsx index fe78cc092a..dab851757e 100644 --- a/packages/react/src/components/SkipLink/SkipLink.tsx +++ b/packages/react/src/components/SkipLink/SkipLink.tsx @@ -1,7 +1,6 @@ import type { AnchorHTMLAttributes, ReactNode } from 'react'; import cl from 'clsx'; -import utilityClasses from './../../utilities/utility.module.css'; import classes from './SkipLink.module.css'; export type SkipLinkProps = { @@ -21,7 +20,7 @@ export const SkipLink = ({ return ( {children} diff --git a/packages/react/src/components/Table/TableHeaderCell.tsx b/packages/react/src/components/Table/TableHeaderCell.tsx index 767ce207a0..5928254e0d 100644 --- a/packages/react/src/components/Table/TableHeaderCell.tsx +++ b/packages/react/src/components/Table/TableHeaderCell.tsx @@ -7,8 +7,6 @@ import type { AriaAttributes } from 'react'; import * as React from 'react'; import cl from 'clsx'; -import utilityClasses from '../../utilities/utility.module.css'; - import classes from './Table.module.css'; const SORT_ICON = { @@ -63,7 +61,7 @@ export const TableHeaderCell = React.forwardRef< > {sortable && ( )} diff --git a/packages/react/src/components/form/Textarea/Textarea.tsx b/packages/react/src/components/form/Textarea/Textarea.tsx index 89bc001316..898abd6551 100644 --- a/packages/react/src/components/form/Textarea/Textarea.tsx +++ b/packages/react/src/components/form/Textarea/Textarea.tsx @@ -11,7 +11,6 @@ import { CharacterCounter } from '../CharacterCounter'; import { useTextarea } from './useTextarea'; import classes from './Textarea.module.css'; -import utilityClasses from './../../../utilities/utility.module.css'; export type TextareaProps = { /** Label */ @@ -92,10 +91,7 @@ export const Textarea = forwardRef( size={size} weight='medium' htmlFor={textareaProps.id} - className={cl( - classes.label, - hideLabel && utilityClasses.visuallyHidden, - )} + className={cl(classes.label, hideLabel && `fds-sr-only`)} > {readOnly && ( ( >
{description}
)}