From 30530e82cf0f30b480cb108abbc03f2fb7e64fea Mon Sep 17 00:00:00 2001 From: Gerwin Terpstra Date: Fri, 10 Jan 2025 15:08:48 +0100 Subject: [PATCH] FIx: card itself is no longer an anchor --- packages/components-css/src/card/_mixin.scss | 8 +++ packages/components-css/src/card/index.scss | 4 ++ packages/components-react/src/Card.tsx | 55 ++++++++------------ 3 files changed, 35 insertions(+), 32 deletions(-) diff --git a/packages/components-css/src/card/_mixin.scss b/packages/components-css/src/card/_mixin.scss index ad5d22af1..c5a4b4961 100644 --- a/packages/components-css/src/card/_mixin.scss +++ b/packages/components-css/src/card/_mixin.scss @@ -143,6 +143,14 @@ text-decoration: var(--rhc-card-as-link-link-text-decoration, underline); } +@mixin rhc-card__anchor { + a::after { + content: ""; + inset: 0; + position: absolute; + } +} + @mixin rhc-card__link--active { --utrecht-link-color: var(--rhc-card-as-link-link-active-color, #42145f); diff --git a/packages/components-css/src/card/index.scss b/packages/components-css/src/card/index.scss index 28bb04b2a..411a50ac2 100644 --- a/packages/components-css/src/card/index.scss +++ b/packages/components-css/src/card/index.scss @@ -71,6 +71,10 @@ @include mixin.rhc-card__link; } +.rhc-card__anchor { + @include mixin.rhc-card__anchor; +} + .rhc-card:active { @include mixin.rhc-card--active; } diff --git a/packages/components-react/src/Card.tsx b/packages/components-react/src/Card.tsx index 3b3b41677..6f4f48332 100644 --- a/packages/components-react/src/Card.tsx +++ b/packages/components-react/src/Card.tsx @@ -1,10 +1,11 @@ import clsx from 'clsx'; -import { AnchorHTMLAttributes, ForwardedRef, forwardRef, PropsWithChildren, ReactNode } from 'react'; +import { ForwardedRef, forwardRef, PropsWithChildren, ReactNode } from 'react'; import { Image } from './Image'; import { Link } from './Link'; -interface CardPropsBase extends AnchorHTMLAttributes { +interface CardPropsBase { href: string; + title?: string; className?: string; heading: ReactNode; } @@ -37,7 +38,7 @@ export interface HorizontalImageCardProps extends CardPropsBase { export const Card = forwardRef( ( props: PropsWithChildren, - ref: ForwardedRef, + ref: ForwardedRef, ) => { const { appearance, ...cardProps } = props; switch (appearance) { @@ -70,16 +71,10 @@ const DefaultCard = forwardRef( children, ...restProps }: PropsWithChildren, - ref: ForwardedRef, + ref: ForwardedRef, ) => { return ( - +
{{imageAlt}} @@ -91,12 +86,14 @@ const DefaultCard = forwardRef( {children}
); }, ); @@ -117,15 +114,12 @@ export const FullBleedCard = forwardRef( imageAlt, ...restProps }: PropsWithChildren, - ref: ForwardedRef, + ref: ForwardedRef, ) => ( - +
+ + + {{imageAlt}}
{heading}
@@ -133,7 +127,7 @@ export const FullBleedCard = forwardRef(
{metadata}
{children}
- +
), ); @@ -151,15 +145,12 @@ export const HorizontalImageCard = forwardRef( className, ...restProps }: PropsWithChildren, - ref: ForwardedRef, + ref: ForwardedRef, ) => ( - +
+ + +
{imageAlt}
@@ -167,7 +158,7 @@ export const HorizontalImageCard = forwardRef(
{heading}
{children}
- +
), );