From 947830904239d51ec9e94971fed6346c1089911f Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Mon, 23 Jan 2023 19:01:28 +0100 Subject: chore: make Links and Images compliant with Next.js 13 --- .../atoms/buttons/button-link.stories.tsx | 3 +- src/components/atoms/buttons/button-link.tsx | 13 +- src/components/atoms/links/link.tsx | 13 +- src/components/atoms/links/nav-link.tsx | 8 +- .../molecules/buttons/back-to-top.test.tsx | 2 +- src/components/molecules/images/flipping-logo.tsx | 5 +- .../molecules/images/responsive-image.module.scss | 5 + .../molecules/images/responsive-image.tsx | 22 +- src/components/molecules/layout/branding.tsx | 4 +- src/components/molecules/layout/card.module.scss | 1 - src/components/molecules/layout/card.tsx | 19 +- src/components/organisms/layout/cards-list.tsx | 9 +- src/components/organisms/layout/comment.test.tsx | 2 +- src/components/organisms/layout/comment.tsx | 17 +- .../organisms/layout/overview.module.scss | 6 +- src/components/organisms/layout/overview.tsx | 8 +- src/content | 2 +- src/pages/cv.tsx | 48 ++- src/pages/index.tsx | 379 +++++++++++---------- src/pages/mentions-legales.tsx | 4 +- src/pages/projets/[slug].tsx | 16 +- src/pages/projets/index.tsx | 2 +- 22 files changed, 304 insertions(+), 284 deletions(-) (limited to 'src') diff --git a/src/components/atoms/buttons/button-link.stories.tsx b/src/components/atoms/buttons/button-link.stories.tsx index 22d13f6..ff0a67f 100644 --- a/src/components/atoms/buttons/button-link.stories.tsx +++ b/src/components/atoms/buttons/button-link.stories.tsx @@ -8,6 +8,7 @@ export default { title: 'Atoms/Buttons/ButtonLink', component: ButtonLink, args: { + external: false, shape: 'rectangle', }, argTypes: { @@ -79,7 +80,7 @@ export default { type: 'select', }, description: 'The link kind.', - options: ['primary', 'secondary'], + options: ['primary', 'secondary', 'tertiary'], table: { category: 'Options', defaultValue: { summary: 'secondary' }, diff --git a/src/components/atoms/buttons/button-link.tsx b/src/components/atoms/buttons/button-link.tsx index 989f737..7182d94 100644 --- a/src/components/atoms/buttons/button-link.tsx +++ b/src/components/atoms/buttons/button-link.tsx @@ -63,13 +63,12 @@ const ButtonLink: FC = ({ {children} ) : ( - - - {children} - + + {children} ); }; diff --git a/src/components/atoms/links/link.tsx b/src/components/atoms/links/link.tsx index c8ba273..8991f38 100644 --- a/src/components/atoms/links/link.tsx +++ b/src/components/atoms/links/link.tsx @@ -53,13 +53,12 @@ const Link: FC = ({ {children} ) : ( - - - {children} - + + {children} ); }; diff --git a/src/components/atoms/links/nav-link.tsx b/src/components/atoms/links/nav-link.tsx index 7c6fede..66ee570 100644 --- a/src/components/atoms/links/nav-link.tsx +++ b/src/components/atoms/links/nav-link.tsx @@ -24,11 +24,9 @@ export type NavLinkProps = { */ const NavLink: FC = ({ href, label, logo }) => { return ( - - - {logo} - {label} - + + {logo} + {label} ); }; diff --git a/src/components/molecules/buttons/back-to-top.test.tsx b/src/components/molecules/buttons/back-to-top.test.tsx index 6eb1e21..827c2a8 100644 --- a/src/components/molecules/buttons/back-to-top.test.tsx +++ b/src/components/molecules/buttons/back-to-top.test.tsx @@ -5,6 +5,6 @@ describe('BackToTop', () => { it('renders a BackToTop link', () => { render(); expect(screen.getByRole('link')).toHaveAccessibleName('Back to top'); - expect(screen.getByRole('link')).toHaveAttribute('href', '/#top'); + expect(screen.getByRole('link')).toHaveAttribute('href', '#top'); }); }); diff --git a/src/components/molecules/images/flipping-logo.tsx b/src/components/molecules/images/flipping-logo.tsx index 1099d53..0d59a55 100644 --- a/src/components/molecules/images/flipping-logo.tsx +++ b/src/components/molecules/images/flipping-logo.tsx @@ -40,8 +40,9 @@ const FlippingLogo: ForwardRefRenderFunction< {altText} diff --git a/src/components/molecules/images/responsive-image.module.scss b/src/components/molecules/images/responsive-image.module.scss index 8a1d51f..7f5fafd 100644 --- a/src/components/molecules/images/responsive-image.module.scss +++ b/src/components/molecules/images/responsive-image.module.scss @@ -37,6 +37,11 @@ } } +.img { + max-height: 100%; + object-fit: cover; +} + .link { display: flex; flex-flow: column; diff --git a/src/components/molecules/images/responsive-image.tsx b/src/components/molecules/images/responsive-image.tsx index 5373561..79e7db4 100644 --- a/src/components/molecules/images/responsive-image.tsx +++ b/src/components/molecules/images/responsive-image.tsx @@ -22,7 +22,7 @@ export type ResponsiveImageProps = Omit< /** * The image height. */ - height: number | string; + height: number | `${number}`; /** * A link target. */ @@ -30,7 +30,7 @@ export type ResponsiveImageProps = Omit< /** * The image width. */ - width: number | string; + width: number | `${number}`; /** * Wrap the image with borders. */ @@ -46,30 +46,27 @@ const ResponsiveImage: FC = ({ alt, caption, className = '', - layout, - objectFit, target, title, withBorders, ...props }) => { - const bordersModifier = withBorders - ? 'wrapper--has-borders' - : 'wrapper--no-borders'; - const linkModifier = target ? 'wrapper--has-link' : 'wrapper--no-link'; + const bordersModifier = withBorders ? styles['wrapper--has-borders'] : ''; + const linkModifier = target + ? styles['wrapper--has-link'] + : styles['wrapper--no-link']; return (
{target ? ( {alt} @@ -82,8 +79,7 @@ const ResponsiveImage: FC = ({ {alt} diff --git a/src/components/molecules/layout/branding.tsx b/src/components/molecules/layout/branding.tsx index 9a82a74..b351f12 100644 --- a/src/components/molecules/layout/branding.tsx +++ b/src/components/molecules/layout/branding.tsx @@ -94,8 +94,8 @@ const Branding: FC = ({ ref={titleRef} > {withLink ? ( - - {title} + + {title} ) : ( title diff --git a/src/components/molecules/layout/card.module.scss b/src/components/molecules/layout/card.module.scss index 6065642..42e9192 100644 --- a/src/components/molecules/layout/card.module.scss +++ b/src/components/molecules/layout/card.module.scss @@ -18,7 +18,6 @@ } .cover { - align-self: flex-start; place-content: center; height: fun.convert-px(150); margin: auto; diff --git a/src/components/molecules/layout/card.tsx b/src/components/molecules/layout/card.tsx index c48bc18..d03b8b7 100644 --- a/src/components/molecules/layout/card.tsx +++ b/src/components/molecules/layout/card.tsx @@ -2,9 +2,7 @@ import ButtonLink from '@components/atoms/buttons/button-link'; import Heading, { type HeadingLevel } from '@components/atoms/headings/heading'; import { type Image } from '@ts/types/app'; import { FC } from 'react'; -import ResponsiveImage, { - type ResponsiveImageProps, -} from '../images/responsive-image'; +import ResponsiveImage from '../images/responsive-image'; import styles from './card.module.scss'; import Meta, { type MetaData } from './meta'; @@ -17,10 +15,6 @@ export type CardProps = { * The card cover. */ cover?: Image; - /** - * The cover fit. Default: cover. - */ - coverFit?: ResponsiveImageProps['objectFit']; /** * The card id. */ @@ -55,7 +49,6 @@ export type CardProps = { const Card: FC = ({ className = '', cover, - coverFit = 'cover', id, meta, tagline, @@ -71,13 +64,7 @@ const Card: FC = ({ >
- {cover && ( - - )} + {cover && } = ({ {title}
-
{tagline}
+ {tagline &&
{tagline}
} {meta && (