diff --git a/src/components/atoms/OakFieldset/OakFieldset.stories.tsx b/src/components/atoms/OakFieldset/OakFieldset.stories.tsx new file mode 100644 index 00000000..f106a4d5 --- /dev/null +++ b/src/components/atoms/OakFieldset/OakFieldset.stories.tsx @@ -0,0 +1,65 @@ +import React from "react"; +import { StoryObj, Meta } from "@storybook/react"; + +import { OakFieldset } from "./OakFieldset"; + +import { colorArgTypes } from "@/storybook-helpers/colorStyleHelpers"; +import { sizeArgTypes } from "@/storybook-helpers/sizeStyleHelpers"; +import { spacingArgTypes } from "@/storybook-helpers/spacingStyleHelpers"; +import { typographyArgTypes } from "@/storybook-helpers/typographyStyleHelpers"; +import { borderArgTypes } from "@/storybook-helpers/borderStyleHelpers"; +import { positionArgTypes } from "@/storybook-helpers/positionStyleHelpers"; +import { OakBox } from "@/components/atoms/OakBox"; +import { OakLabel } from "@/components/atoms/OakLabel"; +import { OakHeading } from "@/components/atoms/OakHeading"; + +const meta: Meta = { + title: "Components/atoms/OakFieldset", + component: OakFieldset, + tags: ["autodocs"], + argTypes: { + ...colorArgTypes, + ...sizeArgTypes, + ...spacingArgTypes, + ...typographyArgTypes, + ...borderArgTypes, + ...positionArgTypes, + }, + parameters: { + controls: { + include: [ + ...Object.keys(typographyArgTypes), + "$overflow", + "$ba", + "$ph", + "$pv", + ...Object.keys(colorArgTypes), + ], + }, + }, +}; + +export default meta; + +type Story = StoryObj; + +export const Default: Story = { + render: (args) => ( + + + Legend + + + Input 1 + + + + Input 2 + + + + ), + args: { + $pa: "inner-padding-s", + }, +}; diff --git a/src/components/atoms/OakFieldset/OakFieldset.test.tsx b/src/components/atoms/OakFieldset/OakFieldset.test.tsx new file mode 100644 index 00000000..1adca529 --- /dev/null +++ b/src/components/atoms/OakFieldset/OakFieldset.test.tsx @@ -0,0 +1,19 @@ +import React from "react"; +import "@testing-library/jest-dom"; +import { create } from "react-test-renderer"; + +import { OakFieldset } from "./OakFieldset"; + +import renderWithTheme from "@/test-helpers/renderWithTheme"; + +describe("OakFieldset", () => { + it("renders", () => { + const { getByTestId } = renderWithTheme(); + expect(getByTestId("test")).toBeInTheDocument(); + }); + + it("matches snapshot", () => { + const tree = create().toJSON(); + expect(tree).toMatchSnapshot(); + }); +}); diff --git a/src/components/atoms/OakFieldset/OakFieldset.tsx b/src/components/atoms/OakFieldset/OakFieldset.tsx new file mode 100644 index 00000000..6217078f --- /dev/null +++ b/src/components/atoms/OakFieldset/OakFieldset.tsx @@ -0,0 +1,14 @@ +import styled from "styled-components"; + +import { OakBoxProps, oakBoxCss } from "@/components/atoms/OakBox"; +export type OakFieldsetProps = OakBoxProps; +/** + * OakFieldset renders a custom `fieldset` component, removes default styling of fieldset. + color, opacity, margin, padding, border and typography styles can be passed in also. + */ +export const OakFieldset = styled.fieldset` + border: 0; + margin: 0; + padding: 0; + ${oakBoxCss}; +`; diff --git a/src/components/atoms/OakFieldset/__snapshots__/OakFieldset.test.tsx.snap b/src/components/atoms/OakFieldset/__snapshots__/OakFieldset.test.tsx.snap new file mode 100644 index 00000000..75e364f8 --- /dev/null +++ b/src/components/atoms/OakFieldset/__snapshots__/OakFieldset.test.tsx.snap @@ -0,0 +1,14 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`OakFieldset matches snapshot 1`] = ` +.c0 { + border: 0; + margin: 0; + padding: 0; + font-family: --var(google-font),Lexend,sans-serif; +} + +
+`; diff --git a/src/components/atoms/OakFieldset/index.ts b/src/components/atoms/OakFieldset/index.ts new file mode 100644 index 00000000..9402719b --- /dev/null +++ b/src/components/atoms/OakFieldset/index.ts @@ -0,0 +1 @@ +export * from "./OakFieldset";