Skip to content

Commit

Permalink
temavelger a11y updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Barsnes committed Jun 24, 2024
1 parent de10623 commit f314717
Show file tree
Hide file tree
Showing 11 changed files with 101 additions and 58 deletions.
6 changes: 3 additions & 3 deletions apps/storefront/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const Header = () => {
<div className={classes.container}>
<div>
<Link
className={classes.logoLink}
className={cl(classes.logoLink, 'ds-focus')}
href='/'
aria-label='Designsystem forside'
onClick={() => setOpen(false)}
Expand Down Expand Up @@ -107,7 +107,7 @@ const Header = () => {
<Link
href='https://github.com/digdir/designsystemet'
target='_blank'
className={cl(classes.linkIcon, classes.github)}
className={cl(classes.linkIcon, classes.github, 'ds-focus')}
title='Designsystemets GitHub-repositorium'
>
<GithubLogo />
Expand All @@ -117,7 +117,7 @@ const Header = () => {
<Link
href='https://www.figma.com/@designsystemet'
target='_blank'
className={cl(classes.linkIcon, classes.figma)}
className={cl(classes.linkIcon, classes.figma, 'ds-focus')}
title='Designsystemets Figma-prosjekt'
>
<FigmaLogo />
Expand Down
4 changes: 2 additions & 2 deletions apps/theme/components/Color/Color.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
font-weight: 400;
border: 1px solid #e4e4e4;
border-radius: 4px;
cursor: pointer;
}

.box:hover {
cursor: pointer;
.box:hover:not(:focus-visible) {
border-color: #fff;
outline: 2px solid #535353;
outline-offset: 1px;
Expand Down
2 changes: 1 addition & 1 deletion apps/theme/components/Color/Color.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const Color = ({
);
}}
style={{ backgroundColor: color.hex }}
className={cl(classes.box, featured && classes.featured)}
className={cl(classes.box, featured && classes.featured, 'ds-focus')}
></button>

{showColorMeta && (
Expand Down
6 changes: 3 additions & 3 deletions apps/theme/components/ColorModal/ColorModal.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Modal } from '@digdir/designsystemet-react';
import { Modal, Paragraph } from '@digdir/designsystemet-react';
import type { ColorInfo, ColorType } from '@digdir/designsystemet/color';
import { getCssVariable, hexToHSL } from '@digdir/designsystemet/color';

Expand All @@ -22,8 +22,8 @@ const Field = ({
}) => {
return (
<div className={classes.field}>
<div className={classes.label}>{label}</div>
<div className={classes.value}>{value}</div>
<Paragraph className={classes.label}>{label}</Paragraph>
<Paragraph className={classes.value}>{value}</Paragraph>
{copyBtn && <CopyBtn text={value} />}
</div>
);
Expand Down
8 changes: 6 additions & 2 deletions apps/theme/components/ColorPicker/ColorPicker.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@
height: 48px;
width: 150px;
padding-left: 12px;
transition: 0.04s all;
transition:
0.04s border,
0.04s outline;
border: 1px solid #c0c0c0;
background-color: transparent;
}

.container:hover {
.container:hover:not(:focus-visible) {
border: 1px solid #3d3d3d;
outline: 1px solid #3d3d3d;
}
Expand Down Expand Up @@ -82,6 +84,8 @@
align-items: center;
justify-content: center;
cursor: pointer;
padding: 0;
overflow: hidden;
}

.status svg {
Expand Down
11 changes: 6 additions & 5 deletions apps/theme/components/ColorPicker/ColorPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const ColorPicker = ({
disabled,
colorError,
}: ColorPickerProps) => {
const [color, setColor] = useState<string>('#0062BA');
const [color, setColor] = useState<string>('#FFF');
const [showModal, setShowModal] = useState(false);
const handleClick = () => {
setShowModal(!showModal);
Expand All @@ -50,9 +50,10 @@ export const ColorPicker = ({
variant={colorError === 'none' ? 'default' : 'warning'}
>
<Popover.Trigger asChild>
<div
<button
className={cl(
classes.status,
'ds-focus',
colorError == 'decorative' && classes.statusYellow,
colorError == 'interaction' && classes.statusOrange,
)}
Expand All @@ -66,7 +67,7 @@ export const ColorPicker = ({
{colorError == 'interaction' && (
<ExclamationmarkIcon title='Viktig informasjon om fargen' />
)}
</div>
</button>
</Popover.Trigger>
<Popover.Content style={{ width: '700px' }}>
<div>
Expand Down Expand Up @@ -106,7 +107,7 @@ export const ColorPicker = ({
{getStatus()}
</div>
<button
className={classes.container}
className={cl(classes.container, 'ds-focus')}
onClick={() => handleClick()}
>
<div
Expand All @@ -118,7 +119,7 @@ export const ColorPicker = ({
</div>
<div className={cl(classes.popup, showModal && classes.show)}>
<ChromePicker
onChange={({ hex }: { hex: string }) => {
onChangeComplete={({ hex }: { hex: string }) => {
setColor(hex);
onColorChanged && onColorChanged(hex as CssColor);
}}
Expand Down
8 changes: 5 additions & 3 deletions apps/theme/components/CopyBtn/CopyBtn.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FilesIcon } from '@navikt/aksel-icons';
import { useState } from 'react';
import { Tooltip } from '@digdir/designsystemet-react';
import { Button, Tooltip } from '@digdir/designsystemet-react';

import classes from './Copybtn.module.css';

Expand All @@ -16,16 +16,18 @@ export const CopyBtn = ({ text }: CopyBtnProps) => {
placement='top'
portal={false}
>
<button
<Button
className={classes.btn}
onClick={() => {
setPopupText('Kopiert!');
void navigator.clipboard.writeText(text);
}}
variant='secondary'
size='sm'
onMouseEnter={() => setPopupText('Kopier')}
>
<FilesIcon />
</button>
</Button>
</Tooltip>
);
};
23 changes: 13 additions & 10 deletions apps/theme/components/Header/Header.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,22 @@
height: 34px;
}

.links a {
text-decoration: none;
.item {
list-style: none;
margin-left: var(--ds-spacing-7);
}

.link {
color: inherit;
display: block;
margin-left: 32px;
border-bottom: 2px solid transparent;
padding-bottom: 10px;
font-size: 18px;
letter-spacing: 0.1px;
text-decoration: none;
border-bottom: 3px solid transparent;
padding-bottom: var(--ds-spacing-2);
transition: 0.1s border-color ease-out;
}

.links a:hover {
border-color: #d4d4d4;
.link:hover,
.link:focus-visible {
border-color: var(--ds-color-neutral-border-subtle);
}

.container {
Expand Down
64 changes: 43 additions & 21 deletions apps/theme/components/Header/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Link from 'next/link';
import { usePathname } from 'next/navigation';
import cl from 'clsx/lite';

import { Container } from '../Container/Container';

Expand All @@ -11,34 +12,55 @@ export const Header = () => {
<header className={classes.header}>
<Container className={classes.container}>
<div className={classes.logoContainer}>
<Link href='/'>
<Link
href='/'
className='ds-focus'
>
<img
src='img/logo.svg'
alt=''
/>
</Link>
<div className={classes.tag}>Beta</div>
</div>
<div className={classes.links}>
<Link
className={currentPath === '/' ? classes.active : ''}
href='/'
>
Fargevelger
</Link>
<Link
className={currentPath === '/testside' ? classes.active : ''}
href='/testside'
>
Testside
</Link>
<Link
className={currentPath === '/om-verktoyet' ? classes.active : ''}
href='/om-verktoyet'
>
Om verktøyet
</Link>
</div>
<ul className={classes.links}>
<li className={classes.item}>
<Link
className={cl(
currentPath === '/' ? classes.active : '',
classes.link,
'ds-focus',
)}
href='/'
>
Fargevelger
</Link>
</li>
<li className={classes.item}>
<Link
className={cl(
currentPath === '/testside' ? classes.active : '',
classes.link,
'ds-focus',
)}
href='/testside'
>
Testside
</Link>
</li>
<li className={classes.item}>
<Link
className={cl(
currentPath === '/om-verktoyet' ? classes.active : '',
classes.link,
'ds-focus',
)}
href='/om-verktoyet'
>
Om verktøyet
</Link>
</li>
</ul>
</Container>
</header>
);
Expand Down
16 changes: 8 additions & 8 deletions apps/theme/components/Previews/Previews.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@
border-radius: 500px;
border: none;
background-color: transparent;
color: var(--ds-color-accent-text-default);
}

.menuItem:hover {
cursor: pointer;
background-color: #e1ecff;
background-color: var(--ds-color-accent-4);
}

.menuItemActive {
background-color: #e1ecff;
background-color: var(--ds-color-accent-3);
}

.menuItemDisabled,
.menuItemDisabled:hover {
.menuItem[aria-disabled] {
cursor: not-allowed;
opacity: 0.6;
background-color: transparent !important;
Expand All @@ -53,15 +53,16 @@
padding: 9px 16px;
font-size: 15px;
border-radius: 500px;
color: var(--ds-color-accent-text-default);
}

.toggle:hover {
cursor: pointer;
background-color: #dae7ff;
background-color: var(--ds-color-accent-4);
}

.active {
background-color: #d8e6ff;
background-color: var(--ds-color-accent-3);
}

.toggle img {
Expand All @@ -72,12 +73,11 @@
--background: var(--neutral-2);
--foreground: var(--neutral-1);

border: 1px solid #ebebeb;
width: 100%;
border-radius: 12px;
display: flex;
gap: 32px;
box-shadow: 0 0 20px 2px #ebebeb;
box-shadow: var(--ds-shadow-md);
}

.preview[data-ds-color-mode='dark'],
Expand Down
Loading

0 comments on commit f314717

Please sign in to comment.