@fpkit/acss 0.5.9 → 0.5.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/libs/components/buttons/button.css +1 -1
- package/libs/components/buttons/button.css.map +1 -1
- package/libs/components/buttons/button.min.css +2 -2
- package/libs/index.cjs.map +1 -1
- package/libs/index.css +1 -1
- package/libs/index.css.map +1 -1
- package/libs/index.d.cts +16 -22
- package/libs/index.d.ts +16 -22
- package/libs/index.js.map +1 -1
- package/package.json +6 -2
- package/src/components/README.mdx +1 -1
- package/src/components/alert/README.mdx +1 -1
- package/src/components/alert/alert.stories.tsx +2 -2
- package/src/components/alert/elements/README.mdx +1 -1
- package/src/components/alert/elements/dismiss-button.stories.tsx +2 -2
- package/src/components/badge/badge.mdx +1 -1
- package/src/components/badge/badge.stories.tsx +2 -2
- package/src/components/badge/badge.tsx +11 -19
- package/src/components/breadcrumbs/README.mdx +1 -1
- package/src/components/breadcrumbs/breadcrumb.stories.tsx +2 -2
- package/src/components/buttons/README.mdx +1 -1
- package/src/components/buttons/button.scss +11 -11
- package/src/components/buttons/button.stories.tsx +2 -2
- package/src/components/buttons/button.test.tsx +1 -1
- package/src/components/cards/README.md +80 -0
- package/src/components/cards/card.stories.tsx +2 -2
- package/src/components/details/README.mdx +1 -1
- package/src/components/details/details.stories.tsx +2 -2
- package/src/components/details/details.tsx +11 -18
- package/src/components/dialog/README.mdx +1 -1
- package/src/components/dialog/dialog-modal.stories.tsx +2 -2
- package/src/components/dialog/dialog-modal.tsx +1 -1
- package/src/components/dialog/dialog.stories.tsx +2 -2
- package/src/components/dialog/views/README.mdx +1 -1
- package/src/components/dialog/views/dialog-header.stories.tsx +2 -2
- package/src/components/form/form.stories.tsx +2 -2
- package/src/components/form/input.stories.tsx +2 -2
- package/src/components/form/select.stories.tsx +2 -2
- package/src/components/fp.test.tsx +52 -50
- package/src/components/heading/heading.stories.tsx +2 -2
- package/src/components/heading/heading.tsx +12 -24
- package/src/components/icons/icon.stories.tsx +1 -1
- package/src/components/images/figure.stories.tsx +2 -2
- package/src/components/images/img.stories.tsx +2 -2
- package/src/components/layout/footer.stories.tsx +10 -19
- package/src/components/layout/landmarks.stories.tsx +22 -24
- package/src/components/layout/main.stories.tsx +21 -25
- package/src/components/link/link.stories.tsx +2 -2
- package/src/components/list/list.stories.tsx +2 -2
- package/src/components/nav/nav.stories.tsx +2 -2
- package/src/components/popover/popover.stories.tsx +2 -2
- package/src/components/progress/progress.stories.tsx +1 -1
- package/src/components/tag/tag.stories.tsx +2 -2
- package/src/components/text/text.stories.tsx +2 -2
- package/src/components/text/text.tsx +50 -49
- package/src/components/text-to-speech/TextToSpeech.stories.tsx +1 -1
- package/src/decorators/instructions.tsx +2 -1
- package/src/patterns/page/page-header.stories.tsx +2 -2
- package/src/styles/buttons/button.css +11 -11
- package/src/styles/index.css +11 -11
- package/src/components/cards/README.mdx +0 -133
- package/src/components/text/README.mdx +0 -98
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
button {
|
|
2
|
-
--btn-xs: 0.
|
|
3
|
-
--btn-sm: 0.
|
|
4
|
-
--btn-md: 0.
|
|
2
|
+
--btn-xs: 0.7rem;
|
|
3
|
+
--btn-sm: 0.8rem;
|
|
4
|
+
--btn-md: 0.95rem;
|
|
5
5
|
--btn-lg: 1.3125rem;
|
|
6
6
|
--btn-pill: 100rem;
|
|
7
|
-
--btn-height:
|
|
7
|
+
--btn-height: 1.8rem;
|
|
8
8
|
--fs: 0.95rem;
|
|
9
9
|
--btn-fs: 0.9375rem;
|
|
10
10
|
--btn-bg: lightgray;
|
|
11
11
|
--btn-width: max-content;
|
|
12
|
-
--btn-calc-height: var(--btn-height, calc(
|
|
12
|
+
--btn-calc-height: var(--btn-height, calc(36rem / 16));
|
|
13
13
|
|
|
14
14
|
font-size: var(--btn-fs);
|
|
15
15
|
font-weight: var(--btn-fw, 500);
|
|
16
|
-
height: var(--btn-height, calc(
|
|
16
|
+
height: var(--btn-height, calc(24.8rem / 16));
|
|
17
17
|
max-height: var(--btn-calc-height);
|
|
18
|
-
min-height:
|
|
18
|
+
min-height: 0.8rem;
|
|
19
19
|
place-items: var(--btn-place, center);
|
|
20
20
|
padding-inline: var(--btn-px, calc(var(--btn-fs) + 1.1%));
|
|
21
21
|
padding-block: var(--btn-py, calc(var(--btn-fs) + 0.75%));
|
|
@@ -94,23 +94,23 @@ button {
|
|
|
94
94
|
&[data-btn~="xs"] {
|
|
95
95
|
padding-inline: var(--btn-xs);
|
|
96
96
|
--btn-fs: var(--btn-xs);
|
|
97
|
-
--btn-height:
|
|
97
|
+
--btn-height: 0.5rem;
|
|
98
98
|
text-transform: uppercase;
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
&[data-btn~="sm"] {
|
|
102
102
|
--btn-fs: var(--btn-sm);
|
|
103
|
-
--btn-height:
|
|
103
|
+
--btn-height: 0.8rem;
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
&[data-btn~="md"] {
|
|
107
107
|
--btn-fs: var(--btn-md);
|
|
108
|
-
--btn-height:
|
|
108
|
+
--btn-height: 1.3rem;
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
&[data-btn~="lg"] {
|
|
112
112
|
--btn-fs: var(--btn-lg);
|
|
113
|
-
--btn-height:
|
|
113
|
+
--btn-height: 1.8rem;
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
&[data-btn~="icon"] {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { StoryObj, Meta } from "@storybook/react";
|
|
2
|
-
import { within, userEvent, expect, fn } from "
|
|
1
|
+
import type { StoryObj, Meta } from "@storybook/react-vite";
|
|
2
|
+
import { within, userEvent, expect, fn } from "storybook/test";
|
|
3
3
|
|
|
4
4
|
import Button from "./button";
|
|
5
5
|
import "./button.scss";
|
|
@@ -3,7 +3,7 @@ import { render, screen } from "@testing-library/react";
|
|
|
3
3
|
import { Button } from "./button";
|
|
4
4
|
// import user from '@testing-library/user-event'
|
|
5
5
|
import jest from "jest-mock";
|
|
6
|
-
import { userEvent } from "
|
|
6
|
+
import { userEvent } from "storybook/test";
|
|
7
7
|
|
|
8
8
|
describe("Button", () => {
|
|
9
9
|
it("renders a button element with the correct label", () => {
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
|
|
2
|
+
# Card Component
|
|
3
|
+
|
|
4
|
+
The Card component is a versatile and reusable React component for creating card-like UI elements. It's part of the FPKit React component library.
|
|
5
|
+
|
|
6
|
+
## Usage
|
|
7
|
+
|
|
8
|
+
```tsx
|
|
9
|
+
import Card from 'libs/react/fpkit/src/components/cards/card';
|
|
10
|
+
|
|
11
|
+
<Card>
|
|
12
|
+
<Card.Title>Card Title</Card.Title>
|
|
13
|
+
<Card.Content>
|
|
14
|
+
This is the content of the card.
|
|
15
|
+
</Card.Content>
|
|
16
|
+
</Card>
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Components
|
|
20
|
+
|
|
21
|
+
### Card
|
|
22
|
+
|
|
23
|
+
The main container component for the card.
|
|
24
|
+
|
|
25
|
+
#### Props
|
|
26
|
+
|
|
27
|
+
- `elm?: 'div' | 'aside' | 'section' | 'article'` - HTML element to render as (default: 'div')
|
|
28
|
+
- `title?: React.ReactNode` - Card title
|
|
29
|
+
- `footer?: React.ReactNode` - Card footer
|
|
30
|
+
- `styles?: React.CSSProperties` - Inline styles
|
|
31
|
+
- `classes?: string` - Additional CSS classes
|
|
32
|
+
- `id?: string` - Unique ID for the card
|
|
33
|
+
|
|
34
|
+
All other props are passed through to the underlying UI component.
|
|
35
|
+
|
|
36
|
+
### Card.Title
|
|
37
|
+
|
|
38
|
+
A sub-component for rendering the card's title.
|
|
39
|
+
|
|
40
|
+
#### Props
|
|
41
|
+
|
|
42
|
+
- `as?: React.ElementType` - HTML element to render as (default: 'h3')
|
|
43
|
+
- `className?: string` - Additional CSS classes
|
|
44
|
+
- `styles?: React.CSSProperties` - Inline styles
|
|
45
|
+
|
|
46
|
+
### Card.Content
|
|
47
|
+
|
|
48
|
+
A sub-component for rendering the card's main content.
|
|
49
|
+
|
|
50
|
+
#### Props
|
|
51
|
+
|
|
52
|
+
- `className?: string` - Additional CSS classes
|
|
53
|
+
- `styles?: React.CSSProperties` - Inline styles
|
|
54
|
+
|
|
55
|
+
## Styling
|
|
56
|
+
|
|
57
|
+
The component uses CSS classes for styling:
|
|
58
|
+
|
|
59
|
+
- `.card-title` for the title
|
|
60
|
+
- `.card-content` for the content
|
|
61
|
+
|
|
62
|
+
You can override these classes or provide additional styling through the `className` and `styles` props.
|
|
63
|
+
|
|
64
|
+
## Accessibility
|
|
65
|
+
|
|
66
|
+
The Card component is designed with accessibility in mind:
|
|
67
|
+
|
|
68
|
+
- It uses semantic HTML elements (`div`, `aside`, `section`, or `article`) for the main container.
|
|
69
|
+
- The Title component defaults to using an `h3` element, which can be changed if needed.
|
|
70
|
+
- The Content component uses an `article` element for semantic structure.
|
|
71
|
+
|
|
72
|
+
## TypeScript
|
|
73
|
+
|
|
74
|
+
This component is written in TypeScript and provides type definitions for all props and sub-components.
|
|
75
|
+
|
|
76
|
+
## Contributing
|
|
77
|
+
|
|
78
|
+
When contributing to this component, please follow the established code style and conventions. Ensure all changes are well-tested and documented.
|
|
79
|
+
|
|
80
|
+
This README provides an overview of the Card component, its usage, available props, styling information, and accessibility considerations. It also mentions that the component is written in TypeScript and provides guidance for contributors.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { StoryObj, Meta } from "@storybook/react";
|
|
2
|
-
// import { within, userEvent, screen } from "
|
|
1
|
+
import { StoryObj, Meta } from "@storybook/react-vite";
|
|
2
|
+
// import { within, userEvent, screen } from "storybook/test";
|
|
3
3
|
|
|
4
4
|
import Card from "./card";
|
|
5
5
|
// import './card.scss'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { StoryObj, Meta } from "@storybook/react";
|
|
2
|
-
import { within, expect, userEvent } from "
|
|
1
|
+
import { StoryObj, Meta } from "@storybook/react-vite";
|
|
2
|
+
import { within, expect, userEvent } from "storybook/test";
|
|
3
3
|
|
|
4
4
|
import Details from "./details";
|
|
5
5
|
import Icons from "../icons/icon";
|
|
@@ -15,25 +15,18 @@ type DetailsProps = {
|
|
|
15
15
|
} & React.ComponentProps<"details"> &
|
|
16
16
|
Partial<React.ComponentProps<typeof UI>>;
|
|
17
17
|
|
|
18
|
-
/**
|
|
19
|
-
*
|
|
18
|
+
/**3
|
|
19
|
+
* Details component props interface.
|
|
20
20
|
*
|
|
21
|
-
* @param
|
|
22
|
-
* @param
|
|
23
|
-
* @param
|
|
24
|
-
* @param
|
|
25
|
-
* @param
|
|
26
|
-
* @param
|
|
27
|
-
* @param
|
|
28
|
-
* @param
|
|
29
|
-
* @param
|
|
30
|
-
* @param children - The content to be displayed inside the details element.
|
|
31
|
-
* @param ref - A ref to the details element.
|
|
32
|
-
* @param props - Additional props to be passed to the details element.
|
|
33
|
-
* @example
|
|
34
|
-
* <Details summary="Details" ariaLabel="Details">
|
|
35
|
-
* <p>Details content</p>
|
|
36
|
-
* </Details>
|
|
21
|
+
* @param {React.CSSProperties} [styles] - CSS styles object.
|
|
22
|
+
* @param {string} [classes] - Classnames string.
|
|
23
|
+
* @param {boolean} [open] - Whether the details is open.
|
|
24
|
+
* @param {(e: React.PointerEvent<HTMLDetailsElement>) => void} [onToggle] - onToggle callback.
|
|
25
|
+
* @param {(e: React.PointerEvent<HTMLDetailsElement>) => void} [onPointerDown] - onPointerDown callback.
|
|
26
|
+
* @param {ReactNode} children - The content inside the details.
|
|
27
|
+
* @param {string} [ariaLabel] - aria-label for accessibility.
|
|
28
|
+
* @param {React.Ref<any>} [ref] - Ref object.
|
|
29
|
+
* @param {Object} props - Other props.
|
|
37
30
|
*/
|
|
38
31
|
export const Details = ({
|
|
39
32
|
summary,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { StoryObj, Meta } from "@storybook/react";
|
|
2
|
-
import { within, expect, userEvent, waitFor } from "
|
|
1
|
+
import { StoryObj, Meta } from "@storybook/react-vite";
|
|
2
|
+
import { within, expect, userEvent, waitFor } from "storybook/test";
|
|
3
3
|
|
|
4
4
|
import DialogModal from "./dialog-modal";
|
|
5
5
|
import WithInstructions from "#/decorators/instructions";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { StoryObj, Meta, StoryFn } from "@storybook/react";
|
|
2
|
-
import { within, expect, userEvent } from "
|
|
1
|
+
import { StoryObj, Meta, StoryFn } from "@storybook/react-vite";
|
|
2
|
+
import { within, expect, userEvent } from "storybook/test";
|
|
3
3
|
|
|
4
4
|
import Dialog from "./dialog";
|
|
5
5
|
import React from "react";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { StoryObj, Meta } from "@storybook/react";
|
|
2
|
-
import { within, userEvent, expect } from "
|
|
1
|
+
import { StoryObj, Meta } from "@storybook/react-vite";
|
|
2
|
+
import { within, userEvent, expect } from "storybook/test";
|
|
3
3
|
|
|
4
4
|
import Input from "./inputs";
|
|
5
5
|
import "./form.scss";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { StoryObj, Meta } from "@storybook/react";
|
|
2
|
-
import { within, expect } from "
|
|
1
|
+
import { StoryObj, Meta } from "@storybook/react-vite";
|
|
2
|
+
import { within, expect } from "storybook/test";
|
|
3
3
|
|
|
4
4
|
import Select from "./select";
|
|
5
5
|
import React from "react";
|
|
@@ -1,56 +1,58 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { render, screen } from
|
|
3
|
-
import FP from
|
|
4
|
-
import jest from
|
|
5
|
-
import { userEvent } from
|
|
6
|
-
|
|
7
|
-
describe(
|
|
8
|
-
it(
|
|
9
|
-
const { container } = render(<FP />)
|
|
10
|
-
expect(container.firstChild).toMatchSnapshot()
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
it(
|
|
14
|
-
const { container } = render(<FP as="span">Span</FP>)
|
|
15
|
-
const span = container.querySelector(
|
|
16
|
-
expect(span).toBeInTheDocument()
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
it(
|
|
20
|
-
const { container } = render(<FP>Hello, world!</FP>)
|
|
21
|
-
expect(container.firstChild).toHaveTextContent(
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
it(
|
|
25
|
-
const style = { backgroundColor:
|
|
26
|
-
const { container } = render(<FP styles={style}>Hello, world!</FP>)
|
|
27
|
-
expect(container.firstChild).toHaveStyle(style)
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
it(
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render, screen } from "@testing-library/react";
|
|
3
|
+
import FP from "../components/fp";
|
|
4
|
+
import jest from "jest-mock";
|
|
5
|
+
import { userEvent } from "storybook/test";
|
|
6
|
+
|
|
7
|
+
describe("FP component", () => {
|
|
8
|
+
it("renders a div by default", () => {
|
|
9
|
+
const { container } = render(<FP />);
|
|
10
|
+
expect(container.firstChild).toMatchSnapshot();
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it("renders a span when specified", () => {
|
|
14
|
+
const { container } = render(<FP as="span">Span</FP>);
|
|
15
|
+
const span = container.querySelector("span");
|
|
16
|
+
expect(span).toBeInTheDocument();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it("renders children", () => {
|
|
20
|
+
const { container } = render(<FP>Hello, world!</FP>);
|
|
21
|
+
expect(container.firstChild).toHaveTextContent("Hello, world!");
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it("applies styles", () => {
|
|
25
|
+
const style = { backgroundColor: "red;" };
|
|
26
|
+
const { container } = render(<FP styles={style}>Hello, world!</FP>);
|
|
27
|
+
expect(container.firstChild).toHaveStyle(style);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("does not render styles when renderStyles is false", () => {
|
|
31
31
|
const { container } = render(
|
|
32
|
-
<FP renderStyles={false} styles={{ backgroundColor:
|
|
32
|
+
<FP renderStyles={false} styles={{ backgroundColor: "red" }}>
|
|
33
33
|
Hello, world!
|
|
34
|
-
</FP
|
|
35
|
-
)
|
|
36
|
-
expect(container.firstChild).not.toHaveStyle(
|
|
37
|
-
})
|
|
34
|
+
</FP>
|
|
35
|
+
);
|
|
36
|
+
expect(container.firstChild).not.toHaveStyle("background-color: red;");
|
|
37
|
+
});
|
|
38
38
|
|
|
39
|
-
it(
|
|
40
|
-
const handleClick = jest.fn()
|
|
39
|
+
it("passes through props", async () => {
|
|
40
|
+
const handleClick = jest.fn();
|
|
41
41
|
const { container } = render(
|
|
42
42
|
<FP as="button" onClick={handleClick}>
|
|
43
43
|
Hello, world!
|
|
44
|
-
</FP
|
|
45
|
-
)
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
44
|
+
</FP>
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
expect(container.firstChild).toBeInTheDocument();
|
|
48
|
+
|
|
49
|
+
await userEvent.click(screen.getByRole("button"));
|
|
50
|
+
expect(handleClick).toHaveBeenCalled();
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it("applies ref", () => {
|
|
54
|
+
const ref = React.createRef<HTMLDivElement>();
|
|
55
|
+
render(<FP ref={ref}>Hello, world!</FP>);
|
|
56
|
+
expect(ref.current).toBeTruthy();
|
|
57
|
+
});
|
|
58
|
+
});
|
|
@@ -1,27 +1,15 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import UI from
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import UI from '#components/ui'
|
|
3
|
+
import { type } from 'os'
|
|
3
4
|
|
|
4
5
|
export type TitleProps = {
|
|
5
|
-
children: React.ReactNode
|
|
6
|
-
type:
|
|
7
|
-
ui?: string
|
|
8
|
-
} & React.ComponentProps<typeof UI
|
|
6
|
+
children: React.ReactNode
|
|
7
|
+
type: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'
|
|
8
|
+
ui?: string
|
|
9
|
+
} & React.ComponentProps<typeof UI>
|
|
9
10
|
|
|
10
|
-
/**
|
|
11
|
-
* A flexible heading component that renders different heading levels.
|
|
12
|
-
*
|
|
13
|
-
* @component
|
|
14
|
-
* @param {'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'} [props.type='h3'] - The heading level to render
|
|
15
|
-
* @param {string} [props.id] - Optional ID attribute for the heading
|
|
16
|
-
* @param {React.CSSProperties} [props.styles] - Custom styles to apply to the heading
|
|
17
|
-
* @param {string} [props.ui] - Custom UI modifier to be added as a data attribute
|
|
18
|
-
* @param {ReactNode} props.children - The content to be rendered within the heading
|
|
19
|
-
* @param {Object} [props] - Additional props to be spread onto the heading element
|
|
20
|
-
*
|
|
21
|
-
* @returns {JSX.Element} A heading element of the specified type
|
|
22
|
-
*/
|
|
23
11
|
const Heading = ({
|
|
24
|
-
type =
|
|
12
|
+
type = 'h3',
|
|
25
13
|
id,
|
|
26
14
|
styles,
|
|
27
15
|
ui,
|
|
@@ -32,8 +20,8 @@ const Heading = ({
|
|
|
32
20
|
<UI as={type} id={id} styles={styles} data-ui={ui} {...props}>
|
|
33
21
|
{children}
|
|
34
22
|
</UI>
|
|
35
|
-
)
|
|
36
|
-
}
|
|
23
|
+
)
|
|
24
|
+
}
|
|
37
25
|
|
|
38
|
-
export default Heading
|
|
39
|
-
Heading.displayName =
|
|
26
|
+
export default Heading
|
|
27
|
+
Heading.displayName = 'Heading'
|
|
@@ -1,34 +1,25 @@
|
|
|
1
|
-
import { StoryObj, Meta } from
|
|
1
|
+
import { StoryObj, Meta } from "@storybook/react-vite";
|
|
2
2
|
/**
|
|
3
3
|
* Import testing library dependencies
|
|
4
4
|
*/
|
|
5
|
-
import { within, userEvent } from
|
|
5
|
+
// import { within, userEvent } from "storybook/test";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Import jest matchers
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
import { Footer } from './landmarks'
|
|
11
|
+
import { Footer } from "./landmarks";
|
|
13
12
|
|
|
14
13
|
const meta: Meta<typeof Footer> = {
|
|
15
|
-
title:
|
|
14
|
+
title: "FP.React Components/Layout/Landmarks",
|
|
16
15
|
component: Footer,
|
|
17
16
|
args: {
|
|
18
|
-
children:
|
|
19
|
-
|
|
20
|
-
'data-testid': 'main',
|
|
17
|
+
children: "Main Landmark",
|
|
18
|
+
"data-testid": "main",
|
|
21
19
|
},
|
|
22
|
-
} as Meta
|
|
23
|
-
|
|
24
|
-
const mainChildren = () => (
|
|
25
|
-
<>
|
|
26
|
-
<h2>Header Title</h2>
|
|
27
|
-
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Vero, unde?</p>
|
|
28
|
-
</>
|
|
29
|
-
)
|
|
20
|
+
} as Meta;
|
|
30
21
|
|
|
31
|
-
export default meta
|
|
32
|
-
type Story = StoryObj<typeof Footer
|
|
22
|
+
export default meta;
|
|
23
|
+
type Story = StoryObj<typeof Footer>;
|
|
33
24
|
|
|
34
|
-
export const BasicFooter: Story = {}
|
|
25
|
+
export const BasicFooter: Story = {};
|
|
@@ -1,54 +1,52 @@
|
|
|
1
|
-
import { StoryObj, Meta } from
|
|
1
|
+
import { StoryObj, Meta } from "@storybook/react-vite";
|
|
2
2
|
/**
|
|
3
3
|
* Import testing library dependencies
|
|
4
4
|
*/
|
|
5
|
-
import { within, expect } from
|
|
5
|
+
import { within, expect } from "storybook/test";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Import jest matchers
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
+
import { Header } from "./landmarks";
|
|
11
12
|
|
|
12
|
-
import
|
|
13
|
-
|
|
14
|
-
import Img from '#components/images/img'
|
|
13
|
+
import Img from "#components/images/img";
|
|
15
14
|
|
|
16
15
|
const meta: Meta<typeof Header> = {
|
|
17
|
-
title:
|
|
16
|
+
title: "FP.React Components/Layout/Landmarks",
|
|
18
17
|
component: Header,
|
|
19
18
|
args: {
|
|
20
|
-
children:
|
|
21
|
-
|
|
22
|
-
'data-testid': 'banner',
|
|
19
|
+
children: "Default Header",
|
|
20
|
+
"data-testid": "banner",
|
|
23
21
|
},
|
|
24
|
-
} as Meta
|
|
22
|
+
} as Meta;
|
|
25
23
|
|
|
26
24
|
const headerChildren = () => (
|
|
27
25
|
<>
|
|
28
26
|
<h2>Header Title</h2>
|
|
29
27
|
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Vero, unde?</p>
|
|
30
28
|
</>
|
|
31
|
-
)
|
|
29
|
+
);
|
|
32
30
|
|
|
33
|
-
export default meta
|
|
34
|
-
type Story = StoryObj<typeof Header
|
|
31
|
+
export default meta;
|
|
32
|
+
type Story = StoryObj<typeof Header>;
|
|
35
33
|
|
|
36
|
-
export const LandmarkDefault: Story = {}
|
|
34
|
+
export const LandmarkDefault: Story = {};
|
|
37
35
|
|
|
38
36
|
export const HeroHeader: Story = {
|
|
39
37
|
args: {
|
|
40
38
|
children: headerChildren(),
|
|
41
39
|
headerBackground: <Img src="https://picsum.photos/2000/1000" alt="" />,
|
|
42
|
-
styles: { color:
|
|
43
|
-
classNames:
|
|
44
|
-
|
|
40
|
+
styles: { color: "red" },
|
|
41
|
+
classNames: "header-class",
|
|
42
|
+
"data-styles": "blue",
|
|
45
43
|
},
|
|
46
44
|
play: async ({ canvasElement }) => {
|
|
47
|
-
const canvas = within(canvasElement)
|
|
48
|
-
const header = canvas.getByRole(
|
|
49
|
-
expect(header).toBeInTheDocument()
|
|
50
|
-
const title = canvas.getByRole(
|
|
51
|
-
expect(title).toBeInTheDocument()
|
|
52
|
-
expect(title).toHaveTextContent(/header title/i)
|
|
45
|
+
const canvas = within(canvasElement);
|
|
46
|
+
const header = canvas.getByRole("banner");
|
|
47
|
+
expect(header).toBeInTheDocument();
|
|
48
|
+
const title = canvas.getByRole("heading");
|
|
49
|
+
expect(title).toBeInTheDocument();
|
|
50
|
+
expect(title).toHaveTextContent(/header title/i);
|
|
53
51
|
},
|
|
54
|
-
} as Story
|
|
52
|
+
} as Story;
|