Skip to content

Commit

Permalink
wip create component BorderedSection
Browse files Browse the repository at this point in the history
  • Loading branch information
celineung committed Nov 13, 2024
1 parent b396c50 commit d33c03e
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import type { ArgTypes, Meta, StoryObj } from "@storybook/react";
import React from "react";
import { BorderedSection, BorderedSectionProperties } from "./BorderedSection";

const Component = BorderedSection;
type Story = StoryObj<typeof Component>;
const argTypes: Partial<ArgTypes<BorderedSectionProperties>> | undefined = {};

const componentDescription = `
Affiche un élément section ayant une bordure et contenant un titre.
\`\`\`tsx
import { BorderedSection } from "react-design-system";
\`\`\`
`;

export default {
title: "BorderedSection",
component: Component,
argTypes,
parameters: {
docs: {
description: {
component: componentDescription,
},
},
},
} as Meta<typeof Component>;

export const Default: Story = {
args: {
title: "Titre de la section",
children: <></>,
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { fr } from "@codegouvfr/react-dsfr";
import React, { ReactNode } from "react";

export type BorderedSectionProperties = {
title: string;
children: ReactNode;
};

// Inspired by https://github.com/MinooTavakoli/crisp-react
export const BorderedSection = ({
title,
children,
}: BorderedSectionProperties) => {
return (
<section
className={fr.cx("fr-mb-2w", "fr-p-2w")}
style={{
border: "1px solid var(--grey-900-175)",
borderRadius: "5px",
}}
>
<h2
className={fr.cx("fr-mb-2w", "fr-pb-1w")}
style={{
color: "var(--text-title-blue-france)",
borderBottom: "1px solid var(--grey-900-175)",
}}
>
{title}
</h2>
{children}
</section>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./BorderedSection";

0 comments on commit d33c03e

Please sign in to comment.