Skip to content

Commit

Permalink
Merge pull request #1726 from NYPL/development
Browse files Browse the repository at this point in the history
Release v3.5.2
  • Loading branch information
bigfishdesign13 authored Jan 16, 2025
2 parents 984d4b1 + 35334d8 commit 6140923
Show file tree
Hide file tree
Showing 65 changed files with 1,837 additions and 422 deletions.
22 changes: 22 additions & 0 deletions .storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,28 @@ const parameters = {
"Chakra UI",
"Development Guide",
"Style Guide",
[
"*",
[
"Overview",
"Page composition",
"Page elements",
[
"Outline",
"Keyword search field",
"Filter bar",
"Active filters list",
"Total results heading",
"Sorting menu",
"Results list",
"Pagination menu",
],
"Applying & clearing filters",
"Accessibility",
"JS-disabled",
],
"*",
],
"Accessibility Guide",
"Components",
"Hooks",
Expand Down
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,22 @@ Currently, this repo is in Prerelease. When it is released, this project will ad

## Prerelease

## 3.5.2 (January 16, 2025)

### Adds

- Adds the `Filtering` subsection to the `Style Guide`.

### Updates

- Updates the `Form` component to remove the `aria-label`. The previous value of `"form"` was redundant and not required.
- Updates the `RadioGroup` component to replace the `fieldset` and `legend` wrappers with a div and span for the title. The main div wrapper around the `Radio` components already has a `role="radiogroup"` values which makes the `fieldset` redundant.
- Updates the `Pagination` component to apply new visual styles.

### Fixes

- Fixes the infinite loop in the `Image` component caused when there is no `fallbackSrc` prop value.

## 3.5.1 (December 19, 2024)

### Adds
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nypl/design-system-react-components",
"version": "3.5.1",
"version": "3.5.2",
"description": "NYPL Reservoir Design System React Components",
"repository": {
"type": "git",
Expand Down
8 changes: 0 additions & 8 deletions src/components/Card/__snapshots__/Card.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ exports[`Card Renders the UI snapshot correctly 1`] = `
alt="Alt text"
className="css-0"
id="img-id-regularCard"
onError={[Function]}
src="https://images.nypl.org/index.php?id=swope_243048&t=r"
/>
</div>
Expand Down Expand Up @@ -66,7 +65,6 @@ exports[`Card Renders the UI snapshot correctly 2`] = `
alt="Alt text"
className="css-0"
id="img-id-cardWithExtendedStyles"
onError={[Function]}
src="https://images.nypl.org/index.php?id=swope_243048&t=r"
/>
</div>
Expand Down Expand Up @@ -144,7 +142,6 @@ exports[`Card Renders the UI snapshot correctly 3`] = `
alt="Alt text"
className="css-0"
id="img-id-cardWithNoCTAs"
onError={[Function]}
src="https://images.nypl.org/index.php?id=swope_243048&t=r"
/>
</div>
Expand Down Expand Up @@ -191,7 +188,6 @@ exports[`Card Renders the UI snapshot correctly 4`] = `
alt="Alt text"
className="css-0"
id="img-id-cardWithNoContent"
onError={[Function]}
src="https://images.nypl.org/index.php?id=swope_243048&t=r"
/>
</div>
Expand Down Expand Up @@ -327,7 +323,6 @@ exports[`Card Renders the UI snapshot correctly 6`] = `
alt="Alt text"
className="css-0"
id="img-id-fullclick"
onError={[Function]}
src="https://images.nypl.org/index.php?id=swope_243048&t=r"
/>
</div>
Expand Down Expand Up @@ -383,7 +378,6 @@ exports[`Card Renders the UI snapshot correctly 7`] = `
alt="Alt text"
className="css-0"
id="img-id-cardWithRightActions"
onError={[Function]}
src="https://images.nypl.org/index.php?id=swope_243048&t=r"
/>
</div>
Expand Down Expand Up @@ -446,7 +440,6 @@ exports[`Card Renders the UI snapshot correctly 8`] = `
alt="Alt text"
className="css-0"
id="img-id-chakraProps"
onError={[Function]}
src="https://images.nypl.org/index.php?id=swope_243048&t=r"
/>
</div>
Expand Down Expand Up @@ -498,7 +491,6 @@ exports[`Card Renders the UI snapshot correctly 9`] = `
alt="Alt text"
className="css-0"
id="img-id-otherProps"
onError={[Function]}
src="https://images.nypl.org/index.php?id=swope_243048&t=r"
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ exports[`Renders the UI snapshot correctly 1`] = `
alt="Image example"
className="css-0"
id={null}
onError={[Function]}
src="https://images.nypl.org/index.php?id=swope_243048&t=r"
/>
</div>
Expand Down Expand Up @@ -82,7 +81,6 @@ exports[`Renders the UI snapshot correctly 2`] = `
alt="Image example"
className="css-0"
id={null}
onError={[Function]}
src="https://images.nypl.org/index.php?id=swope_243048&t=r"
/>
</div>
Expand Down Expand Up @@ -145,7 +143,6 @@ exports[`Renders the UI snapshot correctly 3`] = `
alt="Image example"
className="css-0"
id={null}
onError={[Function]}
src="https://images.nypl.org/index.php?id=swope_243048&t=r"
/>
</div>
Expand Down Expand Up @@ -208,7 +205,6 @@ exports[`Renders the UI snapshot correctly 4`] = `
alt="Image example"
className="css-0"
id={null}
onError={[Function]}
src="https://images.nypl.org/index.php?id=swope_243048&t=r"
/>
</div>
Expand Down Expand Up @@ -271,7 +267,6 @@ exports[`Renders the UI snapshot correctly 5`] = `
alt="Image example"
className="css-0"
id={null}
onError={[Function]}
src="https://images.nypl.org/index.php?id=swope_243048&t=r"
/>
</div>
Expand Down Expand Up @@ -334,7 +329,6 @@ exports[`Renders the UI snapshot correctly 6`] = `
alt="Image example"
className="css-0"
id={null}
onError={[Function]}
src="https://images.nypl.org/index.php?id=swope_243048&t=r"
/>
</div>
Expand Down
4 changes: 3 additions & 1 deletion src/components/Form/Form.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Link from "../Link/Link";
| Component Version | DS Version |
| ----------------- | ---------- |
| Added | `0.23.2` |
| Latest | `3.0.0` |
| Latest | `3.5.2` |

## Table of Contents

Expand Down Expand Up @@ -64,6 +64,8 @@ The `Form` component renders a standard `<form>` element and should be used to
wrap all form elements. A `Form` should have a `Button` component with a `type`
of `submit` to submit the form to a server through the `Form`'s `action` prop.

Note: An `aria-label` is not required. If one is needed, make sure it is descriptive.

Resources:

- [WebAIM Creating Accessible Forms](https://webaim.org/techniques/forms/)
Expand Down
113 changes: 59 additions & 54 deletions src/components/Form/Form.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,61 +26,24 @@ describe("Form Accessibility", () => {
});
});

describe("Form Snapshot", () => {
it("Renders the UI snapshot correctly", () => {
const tree = renderer
.create(
<Form id="snapshot-form">
<FormRow>
<FormField>Form Field 1</FormField>
<FormField>Form Field 2</FormField>
<FormField>Form Field 3</FormField>
</FormRow>
</Form>
)
.toJSON();
const withChakraProps = renderer
.create(
<Form id="chakra" p="20px" color="ui.error.primary">
<FormRow>
<FormField>Form Field 1</FormField>
<FormField>Form Field 2</FormField>
<FormField>Form Field 3</FormField>
</FormRow>
</Form>
)
.toJSON();
const withOtherProps = renderer
.create(
<Form id="props" data-testid="props">
<FormRow>
<FormField>Form Field 1</FormField>
<FormField>Form Field 2</FormField>
<FormField>Form Field 3</FormField>
</FormRow>
</Form>
)
.toJSON();

expect(tree).toMatchSnapshot();
expect(withChakraProps).toMatchSnapshot();
expect(withOtherProps).toMatchSnapshot();
});
});

describe("Form", () => {
it("Renders a <form> element", () => {
it("renders a <form> element", () => {
render(<Form id="form" />);
expect(screen.getByRole("form")).toBeInTheDocument();
expect(screen.getByTestId("ds-form")).toBeInTheDocument();
});

it("renders an aria-label attribute", () => {
render(<Form id="form" aria-label="form-test" />);
expect(screen.getByLabelText("form-test")).toBeInTheDocument();
});

it("Renders a <form> element with child FormRow element", () => {
it("renders a <form> element with child FormRow element", () => {
render(
<Form id="form">
<FormRow />
</Form>
);
const form = screen.getByRole("form");
const form = screen.getByTestId("ds-form");
const formRow = form.firstChild;
expect(form).toBeInTheDocument();
expect(formRow).toBeInTheDocument();
Expand All @@ -89,13 +52,13 @@ describe("Form", () => {
});
});

it("Renders a <form> element with child FormField element", () => {
it("renders a <form> element with child FormField element", () => {
render(
<Form id="form">
<FormField />
</Form>
);
const form = screen.getByRole("form");
const form = screen.getByTestId("ds-form");
const formField = form.firstChild;
expect(form).toBeInTheDocument();
expect(formField).toBeInTheDocument();
Expand All @@ -104,7 +67,7 @@ describe("Form", () => {
});
});

it("Renders a <form> element with FormRow, FormField and input elements properly nested", () => {
it("renders a <form> element with FormRow, FormField and input elements properly nested", () => {
render(
<Form id="form">
<FormRow>
Expand All @@ -114,7 +77,7 @@ describe("Form", () => {
</FormRow>
</Form>
);
const form = screen.getByRole("form");
const form = screen.getByTestId("ds-form");
const formRow = form.firstChild;
const formField = formRow?.firstChild;
const textInput = screen.getByRole("textbox");
Expand All @@ -130,9 +93,9 @@ describe("Form", () => {
expect(textInput).toBeInTheDocument();
});

it("Renders a <form> element with custom `action` and `method` attributes", () => {
it("renders a <form> element with custom `action` and `method` attributes", () => {
render(<Form id="form" action="/end/point" method="get" />);
const form = screen.getByRole("form");
const form = screen.getByTestId("ds-form");
expect(form).toBeInTheDocument();
expect(form).toHaveAttribute("action", "/end/point");
expect(form).toHaveAttribute("method", "get");
Expand Down Expand Up @@ -208,13 +171,13 @@ describe("Form", () => {
</FormRow>
</Form>
);
const form = screen.getByRole("form");
const form = screen.getByTestId("ds-form");
expect(onSubmit).toHaveBeenCalledTimes(0);
fireEvent.submit(form);
expect(onSubmit).toHaveBeenCalledTimes(1);
});

it("Logs a warning when there is no `id` passed", () => {
it("logs a warning when there is no `id` passed", () => {
const warn = jest.spyOn(console, "warn");
render(
// @ts-ignore: Typescript complains when a required prop is not passed, but
Expand Down Expand Up @@ -247,3 +210,45 @@ describe("Form", () => {
expect(container.querySelector("form")).toBe(ref.current);
});
});

describe("Form Snapshot", () => {
it("renders the UI snapshot correctly", () => {
const tree = renderer
.create(
<Form id="snapshot-form">
<FormRow>
<FormField>Form Field 1</FormField>
<FormField>Form Field 2</FormField>
<FormField>Form Field 3</FormField>
</FormRow>
</Form>
)
.toJSON();
const withChakraProps = renderer
.create(
<Form id="chakra" p="20px" color="ui.error.primary">
<FormRow>
<FormField>Form Field 1</FormField>
<FormField>Form Field 2</FormField>
<FormField>Form Field 3</FormField>
</FormRow>
</Form>
)
.toJSON();
const withOtherProps = renderer
.create(
<Form id="props" data-testid="props">
<FormRow>
<FormField>Form Field 1</FormField>
<FormField>Form Field 2</FormField>
<FormField>Form Field 3</FormField>
</FormRow>
</Form>
)
.toJSON();

expect(tree).toMatchSnapshot();
expect(withChakraProps).toMatchSnapshot();
expect(withOtherProps).toMatchSnapshot();
});
});
2 changes: 1 addition & 1 deletion src/components/Form/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ export const Form: ChakraComponent<
return (
<Box
as="form"
aria-label="form"
className={className}
data-testid="ds-form"
id={id}
onSubmit={onSubmit}
ref={ref}
Expand Down
Loading

0 comments on commit 6140923

Please sign in to comment.