Skip to content

Commit

Permalink
chore(storefront): Fix wcag issues on front page (#1933)
Browse files Browse the repository at this point in the history
  • Loading branch information
Thunear authored May 13, 2024
1 parent e3534a8 commit b5cada6
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 11 deletions.
12 changes: 10 additions & 2 deletions apps/storefront/components/Blog/Card/BlogCard.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @next/next/no-img-element */
import { Card, Heading, Paragraph, Tag } from '@digdir/designsystemet-react';
import Link from 'next/link';
import cl from 'clsx';
Expand All @@ -14,6 +15,7 @@ type BlogCardProps = {
featured?: boolean;
tagText?: string;
tagColor?: 'first' | 'second' | 'third';
level?: 2 | 3;
} & Omit<React.HTMLAttributes<HTMLDivElement>, 'color'>;

export const BlogCard = ({
Expand All @@ -27,6 +29,7 @@ export const BlogCard = ({
className,
tagText,
tagColor,
level = 3,
...props
}: BlogCardProps) => {
return (
Expand All @@ -41,7 +44,7 @@ export const BlogCard = ({
<Card.Media className={classes.media}>
<img
src={image}
alt={title}
alt=''
className={classes.image}
/>
</Card.Media>
Expand All @@ -56,7 +59,12 @@ export const BlogCard = ({
{tagText}
</Tag>
)}
<Heading size={featured ? 'large' : 'small'}>{title}</Heading>
<Heading
level={level}
size={featured ? 'large' : 'small'}
>
{title}
</Heading>
</Card.Header>
<Card.Content>
<Paragraph size={featured ? 'large' : 'small'}>{desc}</Paragraph>
Expand Down
19 changes: 15 additions & 4 deletions apps/storefront/components/ImageBanner/ImageBanner.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @next/next/no-img-element */
import type React from 'react';
import { useEffect, useState, createElement } from 'react';
import cn from 'clsx';
Expand Down Expand Up @@ -69,14 +70,19 @@ const ImageBanner = ({
{videoSrc && (
<video
autoPlay
playsInline
muted
loop
className={classes.video}
>
<source
src={videoSrc}
src={videoSrc + '.webm'}
type='video/webm'
/>
<source
src={videoSrc + '.mp4'}
type='video/mp4'
></source>
/>
</video>
)}
{imgSrc && (
Expand Down Expand Up @@ -131,14 +137,19 @@ const ImageBanner = ({
{videoSrc && (
<video
autoPlay
playsInline
muted
loop
className={classes.video}
>
<source
src={videoSrc}
src={videoSrc + '.webm'}
type='video/webm'
/>
<source
src={videoSrc + '.mp4'}
type='video/mp4'
></source>
/>
</video>
)}
{imgSrc && (
Expand Down
10 changes: 9 additions & 1 deletion apps/storefront/components/NavigationCard/NavigationCard.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Link from 'next/link';
import cl from 'clsx';
import type * as React from 'react';
import { Heading } from '@digdir/designsystemet-react';

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

Expand All @@ -11,6 +12,7 @@ export interface NavigationCardProps {
backgroundColor?: 'white' | 'grey';
description?: string;
url?: string;
level?: 2 | 3;
}

const NavigationCard = ({
Expand All @@ -20,6 +22,7 @@ const NavigationCard = ({
backgroundColor = 'white',
description,
url = '/grunnleggende/design-tokens',
level = 3,
}: NavigationCardProps) => {
return (
<Link
Expand All @@ -28,7 +31,12 @@ const NavigationCard = ({
className={cl(classes.card, classes[backgroundColor])}
>
<div className={cl(classes.iconContainer, classes[color])}>{icon}</div>
<h3 className={classes.title}>{title}</h3>
<Heading
level={level}
className={classes.title}
>
{title}
</Heading>
<div className={classes.desc}>{description}</div>
</Link>
);
Expand Down
2 changes: 1 addition & 1 deletion apps/storefront/components/Section/Section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const Section = ({
<div className={classes.header}>
{title && (
<Heading
levle={2}
level={2}
size='medium'
>
{title}
Expand Down
4 changes: 4 additions & 0 deletions apps/storefront/layouts/FrontpageLayout/FrontpageLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @next/next/no-img-element */
import type React from 'react';
import { Heading } from '@digdir/designsystemet-react';
import { PaletteIcon, WrenchIcon, ComponentIcon } from '@navikt/aksel-icons';
Expand Down Expand Up @@ -85,6 +86,7 @@ const FrontpageLayout = ({ content }: FrontpageLayoutProps) => {
color='blue'
url='/grunnleggende/for-designere/kom-i-gang'
icon={<PaletteIcon fontSize={36} />}
level={2}
></NavigationCard>

<NavigationCard
Expand All @@ -93,6 +95,7 @@ const FrontpageLayout = ({ content }: FrontpageLayoutProps) => {
color='yellow'
url='/grunnleggende/for-utviklere/kom-i-gang'
icon={<WrenchIcon fontSize={36} />}
level={2}
></NavigationCard>

<NavigationCard
Expand All @@ -101,6 +104,7 @@ const FrontpageLayout = ({ content }: FrontpageLayoutProps) => {
color='red'
url='/komponenter'
icon={<ComponentIcon fontSize={34} />}
level={2}
></NavigationCard>
</div>
</Container>
Expand Down
5 changes: 4 additions & 1 deletion apps/storefront/pages/bloggen/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ export default ({ children }) => (
href='/bloggen/2024/fluid-typography'
image='/img/bloggen/fluid-front.png'
author='Designsystemet'
featured={false}
featured={true}
level={2}
/>

<BlogCard
Expand All @@ -48,6 +49,7 @@ export default ({ children }) => (
image='/img/bloggen/altinnstudio-16-9.png'
author='Altinn / David Øvrelid'
featured={false}
level={2}
/>

<BlogCard
Expand All @@ -58,6 +60,7 @@ export default ({ children }) => (
image='/img/bloggen/miro.png'
author='Digdir og Brønnøysundregistrene'
featured={false}
level={2}
/>

<style>
Expand Down
4 changes: 2 additions & 2 deletions apps/storefront/pages/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default ({ children }) => <FrontpageLayout content={children} />;
<ImageBanner
title='Tilgjengelige og fleksible komponenter'
description='Når vi lager de mest grunnleggende komponentene bare én gang, sikrer vi god kvalitet. Komponenten blir godt testet, og vi ivaretar kravene til tilgjengelighet. Komponentene er laget i Figma og i React. Du kan sette dem sammen på mange ulike måter og i forskjellige mønstre. '
videoSrc='/animations/Page.webm'
videoSrc='/animations/Page'
imgPosition='right'
headingLevel='h2'
imgWidth={1195}
Expand All @@ -43,7 +43,7 @@ export default ({ children }) => <FrontpageLayout content={children} />;
<ImageBanner
title='Bruk egne tema'
description='Designsystemet støtter ulike identiteter gjennom tema. På denne måten kan alle ta utgangspunkt i samme designsystem, men tilpasse til ulike avsenderidentiteter.'
videoSrc='/animations/Theme.webm'
videoSrc='/animations/Theme'
headingLevel='h2'
imgWidth={1195}
imgHeight={270}
Expand Down

0 comments on commit b5cada6

Please sign in to comment.