aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/molecules/layout
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/molecules/layout')
-rw-r--r--src/components/molecules/layout/card.module.scss90
-rw-r--r--src/components/molecules/layout/card.stories.tsx208
-rw-r--r--src/components/molecules/layout/card.test.tsx69
-rw-r--r--src/components/molecules/layout/card.tsx88
-rw-r--r--src/components/molecules/layout/index.ts1
5 files changed, 0 insertions, 456 deletions
diff --git a/src/components/molecules/layout/card.module.scss b/src/components/molecules/layout/card.module.scss
deleted file mode 100644
index 14a5baf..0000000
--- a/src/components/molecules/layout/card.module.scss
+++ /dev/null
@@ -1,90 +0,0 @@
-@use "../../../styles/abstracts/functions" as fun;
-
-.footer {
- margin-top: auto;
-}
-
-.wrapper {
- --scale-up: 1.05;
- --scale-down: 0.95;
-
- display: flex;
- flex-flow: column wrap;
- max-width: var(--card-width, 40ch);
- padding: 0;
- text-align: center;
-
- .article {
- flex: 1;
- display: flex;
- flex-flow: column nowrap;
- justify-content: flex-start;
- }
-
- .cover {
- place-content: center;
- height: fun.convert-px(150);
- object-fit: scale-down;
- margin: auto;
- border-bottom: fun.convert-px(1) solid var(--color-border);
- }
-
- .title,
- .tagline,
- .footer {
- padding: 0 var(--spacing-md);
- }
-
- .title {
- width: fit-content;
- margin: var(--spacing-sm) auto;
- }
-
- h2.title {
- background: none;
- text-shadow: none;
- }
-
- .tagline {
- flex: 1;
- margin-bottom: var(--spacing-md);
- color: var(--color-fg);
- font-weight: 400;
- }
-
- .list {
- margin-bottom: var(--spacing-md);
- }
-
- .meta {
- &__item {
- flex-flow: row wrap;
- place-content: center;
- gap: var(--spacing-2xs);
- margin: auto;
- }
-
- &__label {
- flex: 0 0 100%;
- }
-
- &__value {
- padding: fun.convert-px(2) var(--spacing-xs);
- border: fun.convert-px(1) solid var(--color-primary-darker);
- color: var(--color-fg);
- font-weight: 400;
-
- &::before {
- display: none;
- }
- }
- }
-
- &:not(:disabled):focus {
- text-decoration: none;
-
- .title {
- text-decoration: underline solid var(--color-primary) 0.3ex;
- }
- }
-}
diff --git a/src/components/molecules/layout/card.stories.tsx b/src/components/molecules/layout/card.stories.tsx
deleted file mode 100644
index 070c978..0000000
--- a/src/components/molecules/layout/card.stories.tsx
+++ /dev/null
@@ -1,208 +0,0 @@
-import type { ComponentMeta, ComponentStory } from '@storybook/react';
-import type { MetaItemData } from '../meta-list';
-import { Card } from './card';
-
-/**
- * Card - Storybook Meta
- */
-export default {
- title: 'Molecules/Layout/Card',
- component: Card,
- argTypes: {
- className: {
- control: {
- type: 'text',
- },
- description: 'Set additional classnames to the card wrapper.',
- table: {
- category: 'Styles',
- },
- type: {
- name: 'string',
- required: false,
- },
- },
- cover: {
- description: 'The card cover data (src, dimensions, alternative text).',
- table: {
- category: 'Options',
- },
- type: {
- name: 'object',
- required: false,
- value: {},
- },
- },
- coverFit: {
- control: {
- type: 'select',
- },
- description: 'The cover fit.',
- options: ['contain', 'cover', 'fill', 'scale-down'],
- table: {
- category: 'Options',
- defaultValue: { summary: 'cover' },
- },
- type: {
- name: 'string',
- required: false,
- },
- },
- id: {
- control: {
- type: 'text',
- },
- description: 'The card id.',
- type: {
- name: 'string',
- required: true,
- },
- },
- meta: {
- description: 'The card metadata (a publication date for example).',
- table: {
- category: 'Options',
- },
- type: {
- name: 'object',
- required: false,
- value: {},
- },
- },
- tagline: {
- control: {
- type: 'text',
- },
- description: 'A few words about the card.',
- table: {
- category: 'Options',
- },
- type: {
- name: 'string',
- required: false,
- },
- },
- title: {
- control: {
- type: 'text',
- },
- description: 'The card title.',
- type: {
- name: 'string',
- required: true,
- },
- },
- titleLevel: {
- control: {
- type: 'number',
- min: 1,
- max: 6,
- },
- description: 'The title level.',
- type: {
- name: 'number',
- required: true,
- },
- },
- url: {
- control: {
- type: 'text',
- },
- description: 'The card target.',
- type: {
- name: 'string',
- required: true,
- },
- },
- },
-} as ComponentMeta<typeof Card>;
-
-const Template: ComponentStory<typeof Card> = (args) => <Card {...args} />;
-
-const cover = {
- alt: 'A picture',
- height: 480,
- src: 'https://picsum.photos/640/480',
- width: 640,
-};
-
-const id = 'nam';
-
-const meta = [
- { id: 'author', label: 'Author', value: 'Possimus' },
- {
- id: 'categories',
- label: 'Categories',
- value: [
- { id: 'autem', value: 'Autem' },
- { id: 'eos', value: 'Eos' },
- ],
- },
-] satisfies MetaItemData[];
-
-const tagline = 'Ut rerum incidunt';
-
-const title = 'Alias qui porro';
-
-const url = '/an-existing-url';
-
-/**
- * Card Stories - Default
- */
-export const Default = Template.bind({});
-Default.args = {
- id,
- title,
- titleLevel: 2,
- url,
-};
-
-/**
- * Card Stories - With cover
- */
-export const WithCover = Template.bind({});
-WithCover.args = {
- cover,
- id,
- title,
- titleLevel: 2,
- url,
-};
-
-/**
- * Card Stories - With meta
- */
-export const WithMeta = Template.bind({});
-WithMeta.args = {
- id,
- meta,
- title,
- titleLevel: 2,
- url,
-};
-
-/**
- * Card Stories - With tagline
- */
-export const WithTagline = Template.bind({});
-WithTagline.args = {
- id,
- tagline,
- title,
- titleLevel: 2,
- url,
-};
-
-/**
- * Card Stories - With all data
- */
-export const WithAll = Template.bind({});
-WithAll.args = {
- cover,
- id,
- meta,
- tagline,
- title,
- titleLevel: 2,
- url,
-};
diff --git a/src/components/molecules/layout/card.test.tsx b/src/components/molecules/layout/card.test.tsx
deleted file mode 100644
index b690d4c..0000000
--- a/src/components/molecules/layout/card.test.tsx
+++ /dev/null
@@ -1,69 +0,0 @@
-import { describe, expect, it } from '@jest/globals';
-import { render, screen as rtlScreen } from '../../../../tests/utils';
-import type { MetaItemData } from '../meta-list';
-import { Card } from './card';
-
-const cover = {
- alt: 'A picture',
- height: 480,
- src: 'https://picsum.photos/640/480',
- width: 640,
-};
-
-const id = 'nam';
-
-const meta = [
- { id: 'author', label: 'Author', value: 'Possimus' },
- {
- id: 'categories',
- label: 'Categories',
- value: [
- { id: 'autem', value: 'Autem' },
- { id: 'eos', value: 'Eos' },
- ],
- },
-] satisfies MetaItemData[];
-
-const tagline = 'Ut rerum incidunt';
-
-const title = 'Alias qui porro';
-
-const url = '/an-existing-url';
-
-describe('Card', () => {
- it('renders a title wrapped in h2 element', () => {
- render(<Card id={id} title={title} titleLevel={2} url={url} />);
- expect(
- rtlScreen.getByRole('heading', { level: 2, name: title })
- ).toBeInTheDocument();
- });
-
- it('renders a link to another page', () => {
- render(<Card id={id} title={title} titleLevel={2} url={url} />);
- expect(rtlScreen.getByRole('link')).toHaveAttribute('href', url);
- });
-
- it('renders a cover', () => {
- render(
- <Card id={id} title={title} titleLevel={2} url={url} cover={cover} />
- );
- expect(rtlScreen.getByRole('img', { name: cover.alt })).toBeInTheDocument();
- });
-
- it('renders a tagline', () => {
- render(
- <Card id={id} title={title} titleLevel={2} url={url} tagline={tagline} />
- );
- expect(rtlScreen.getByText(tagline)).toBeInTheDocument();
- });
-
- it('renders some meta', () => {
- render(<Card id={id} title={title} titleLevel={2} url={url} meta={meta} />);
-
- const metaLabels = meta.map((item) => item.label);
-
- for (const label of metaLabels) {
- expect(rtlScreen.getByText(label)).toBeInTheDocument();
- }
- });
-});
diff --git a/src/components/molecules/layout/card.tsx b/src/components/molecules/layout/card.tsx
deleted file mode 100644
index d90cba2..0000000
--- a/src/components/molecules/layout/card.tsx
+++ /dev/null
@@ -1,88 +0,0 @@
-import NextImage, { type ImageProps as NextImageProps } from 'next/image';
-import type { FC } from 'react';
-import { ButtonLink, Figure, Heading, type HeadingLevel } from '../../atoms';
-import { MetaList, type MetaItemData } from '../meta-list';
-import styles from './card.module.scss';
-
-export type CardProps = {
- /**
- * Set additional classnames to the card wrapper.
- */
- className?: string;
- /**
- * The card cover.
- */
- cover?: Pick<NextImageProps, 'alt' | 'src' | 'title' | 'width' | 'height'>;
- /**
- * The card id.
- */
- id: string;
- /**
- * The card meta.
- */
- meta?: MetaItemData[];
- /**
- * The card tagline.
- */
- tagline?: string;
- /**
- * The card title.
- */
- title: string;
- /**
- * The title level (hn).
- */
- titleLevel: HeadingLevel;
- /**
- * The card target.
- */
- url: string;
-};
-
-/**
- * Card component
- *
- * Render a link with minimal information about its content.
- */
-export const Card: FC<CardProps> = ({
- className = '',
- cover,
- id,
- meta,
- tagline,
- title,
- titleLevel,
- url,
-}) => {
- const cardClass = `${styles.wrapper} ${className}`;
- const headingId = `${id}-heading`;
-
- return (
- <ButtonLink aria-labelledby={headingId} className={cardClass} to={url}>
- <article className={styles.article}>
- <header className={styles.header}>
- {cover ? (
- <Figure>
- <NextImage {...cover} className={styles.cover} />
- </Figure>
- ) : null}
- <Heading className={styles.title} id={headingId} level={titleLevel}>
- {title}
- </Heading>
- </header>
- {tagline ? <div className={styles.tagline}>{tagline}</div> : null}
- {meta ? (
- <footer className={styles.footer}>
- <MetaList
- className={styles.list}
- hasBorderedValues={meta.length < 2}
- hasInlinedValues={meta.length < 2}
- isCentered
- items={meta}
- />
- </footer>
- ) : null}
- </article>
- </ButtonLink>
- );
-};
diff --git a/src/components/molecules/layout/index.ts b/src/components/molecules/layout/index.ts
index 80db10a..75cbe28 100644
--- a/src/components/molecules/layout/index.ts
+++ b/src/components/molecules/layout/index.ts
@@ -1,4 +1,3 @@
-export * from './card';
export * from './columns';
export * from './page-footer';
export * from './page-header';