From c4ea17361075a803c4473433cb349049f8037e99 Mon Sep 17 00:00:00 2001 From: johnnadeluy Date: Thu, 8 Aug 2024 13:33:07 +0200 Subject: [PATCH] Re-implement aria-label for Card component MIM-1936 --- src/components/Card/card.story.jsx | 94 ++++++++++-------------------- src/components/Card/index.jsx | 7 ++- 2 files changed, 36 insertions(+), 65 deletions(-) diff --git a/src/components/Card/card.story.jsx b/src/components/Card/card.story.jsx index 7c94d7b9..d14d36d0 100644 --- a/src/components/Card/card.story.jsx +++ b/src/components/Card/card.story.jsx @@ -48,10 +48,6 @@ export const DefaultWithIcon = () => ( ) -DefaultWithIcon.story = { - name: 'Default with icon', -} - export const Profiled = () => (
@@ -82,10 +78,6 @@ export const ProfiledWithIcon = () => (
) -ProfiledWithIcon.story = { - name: 'Profiled with icon', -} - export const ExternalWithIcon = () => (
@@ -101,10 +93,6 @@ export const ExternalWithIcon = () => (
) -ExternalWithIcon.story = { - name: 'External with icon', -} - export const WithImagesLeft = () => (
(
) -WithImagesLeft.story = { - name: 'With images left', -} - export const WithImagesTop = () => (
(
) -WithImagesTop.story = { - name: 'With images top', -} - -export const CardWithAriaLabelAndAriaDescribedBy = () => ( -
-
- } - href=' ' - subTitle='Artikkel / 11. mai 2019' - title='Dangerous Children' - ariaLabel='Tittel - Artikkel 11. mai 2019' - ariaDescribedBy='text' - > - Explain something about something with something clever. - +export const CardWithAriaLabel = () => { + const title = 'Dangerous Children' + const subTitle = 'Artikkel / 11. mai 2019' + return ( +
+
+ +
+
+ +
-
- } - profiled - external - hrefText='Gå til url' - ariaLabel='Gå til url' - ariaDescribedBy='text' - > - Explain something about something with something clever. - -
-
-) - -CardWithAriaLabelAndAriaDescribedBy.story = { - name: 'Card with ariaLabel and ariaDescribedBy', + ) } export const DefaultProfiledCardMedTittel = () => ( @@ -199,10 +177,6 @@ export const DefaultProfiledCardMedTittel = () => (
) -DefaultProfiledCardMedTittel.story = { - name: '**Default/Profiled Card med tittel', -} - export const DefaultProfiledCardWithoutTitleButWithHrefText = () => (
@@ -247,10 +221,6 @@ export const DefaultProfiledCardWithoutTitleButWithHrefText = () => (
) -DefaultProfiledCardWithoutTitleButWithHrefText.story = { - name: '**Default/Profiled Card without title, but with hrefText', -} - export const CardWithImages = () => (
@@ -297,7 +267,3 @@ export const CardWithImages = () => (
) - -CardWithImages.story = { - name: '**Card with images', -} diff --git a/src/components/Card/index.jsx b/src/components/Card/index.jsx index bffab576..5f75b217 100644 --- a/src/components/Card/index.jsx +++ b/src/components/Card/index.jsx @@ -3,6 +3,7 @@ import PropTypes from 'prop-types' import { ArrowRight, Download, ExternalLink } from 'react-feather' const Card = ({ + ariaLabel, children, className, external, @@ -18,7 +19,10 @@ const Card = ({ title, }) => (
-
+
{image &&
{image}
}