aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/molecules/layout
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2022-04-08 19:41:40 +0200
committerArmand Philippot <git@armandphilippot.com>2022-04-08 19:41:40 +0200
commita5df28fad0dae266a857ae110c43b3cb8b23c996 (patch)
treea32ea390e90697dc51c3ccb9018de9da2ee4fac3 /src/components/molecules/layout
parent5c75a302c2203cb3ebf31233121026b4775662cf (diff)
refactor: use a consistent classname prop and avoid children prop
I was using the FunctionComponent type for some component that do not use children. So I change the type to VoidFunctionComponent to avoid mistakes. I also rename all the "classes" or "additionalClasses" props to "className" to keep consistency between each components.
Diffstat (limited to 'src/components/molecules/layout')
-rw-r--r--src/components/molecules/layout/branding.tsx10
-rw-r--r--src/components/molecules/layout/flipping-logo.stories.tsx23
-rw-r--r--src/components/molecules/layout/flipping-logo.tsx12
3 files changed, 29 insertions, 16 deletions
diff --git a/src/components/molecules/layout/branding.tsx b/src/components/molecules/layout/branding.tsx
index efb2e34..9f564bf 100644
--- a/src/components/molecules/layout/branding.tsx
+++ b/src/components/molecules/layout/branding.tsx
@@ -1,6 +1,6 @@
import Heading from '@components/atoms/headings/heading';
import Link from 'next/link';
-import { FC } from 'react';
+import { VFC } from 'react';
import { useIntl } from 'react-intl';
import styles from './branding.module.scss';
import FlippingLogo from './flipping-logo';
@@ -33,7 +33,7 @@ type BrandingProps = {
*
* Render the branding logo, title and optional baseline.
*/
-const Branding: FC<BrandingProps> = ({
+const Branding: VFC<BrandingProps> = ({
baseline,
isHome = false,
photo,
@@ -61,7 +61,7 @@ const Branding: FC<BrandingProps> = ({
return (
<div className={styles.wrapper}>
<FlippingLogo
- additionalClasses={styles.logo}
+ className={styles.logo}
altText={altText}
logoTitle={logoTitle}
photo={photo}
@@ -70,7 +70,7 @@ const Branding: FC<BrandingProps> = ({
isFake={!isHome}
level={1}
withMargin={false}
- additionalClasses={styles.title}
+ className={styles.title}
>
{withLink ? (
<Link href="/">
@@ -85,7 +85,7 @@ const Branding: FC<BrandingProps> = ({
isFake={true}
level={4}
withMargin={false}
- additionalClasses={styles.baseline}
+ className={styles.baseline}
>
{baseline}
</Heading>
diff --git a/src/components/molecules/layout/flipping-logo.stories.tsx b/src/components/molecules/layout/flipping-logo.stories.tsx
index 1508269..1ac8de8 100644
--- a/src/components/molecules/layout/flipping-logo.stories.tsx
+++ b/src/components/molecules/layout/flipping-logo.stories.tsx
@@ -5,11 +5,21 @@ export default {
title: 'Molecules/Layout',
component: FlippingLogoComponent,
argTypes: {
- additionalClasses: {
+ altText: {
+ control: {
+ type: 'text',
+ },
+ description: 'Photo alternative text.',
+ type: {
+ name: 'string',
+ required: true,
+ },
+ },
+ className: {
control: {
type: 'text',
},
- description: 'Adds additional classes to the logo wrapper.',
+ description: 'Set additional classnames to the logo wrapper.',
table: {
category: 'Options',
},
@@ -18,14 +28,17 @@ export default {
required: false,
},
},
- altText: {
+ logoTitle: {
control: {
type: 'text',
},
- description: 'Photo alternative text.',
+ description: 'An accessible name for the logo.',
+ table: {
+ category: 'Accessibility',
+ },
type: {
name: 'string',
- required: true,
+ required: false,
},
},
photo: {
diff --git a/src/components/molecules/layout/flipping-logo.tsx b/src/components/molecules/layout/flipping-logo.tsx
index 7bb7afc..6f7645f 100644
--- a/src/components/molecules/layout/flipping-logo.tsx
+++ b/src/components/molecules/layout/flipping-logo.tsx
@@ -1,13 +1,13 @@
import Logo from '@components/atoms/images/logo';
import Image from 'next/image';
-import { FC } from 'react';
+import { VFC } from 'react';
import styles from './flipping-logo.module.scss';
type FlippingLogoProps = {
/**
- * Adds additional classes to the logo wrapper.
+ * Set additional classnames to the logo wrapper.
*/
- additionalClasses?: string;
+ className?: string;
/**
* Photo alternative text.
*/
@@ -27,14 +27,14 @@ type FlippingLogoProps = {
*
* Render a logo and a photo with a flipping effect.
*/
-const FlippingLogo: FC<FlippingLogoProps> = ({
- additionalClasses,
+const FlippingLogo: VFC<FlippingLogoProps> = ({
+ className = '',
altText,
logoTitle,
photo,
}) => {
return (
- <div className={`${styles.logo} ${additionalClasses}`}>
+ <div className={`${styles.logo} ${className}`}>
<div className={styles.logo__front}>
<Image src={photo} alt={altText} layout="fill" objectFit="cover" />
</div>