Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DSD-1646: Updating NewsletterSignUp, Radio, RadioGroup, and Searchbar to Chakra 2.8 theme API #1480

Merged
merged 9 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,907 changes: 1,871 additions & 36 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"@emotion/react": "11.11.1",
"@emotion/styled": "11.11.0",
"downshift": "6.1.7",
"esbuild": "^0.19.10",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had some esbuild issues as well. Can you try running this without esbuild? If we can remove this dependency, that'd be great, otherwise it's okay to keep.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's running fine without esbuild now so I removed it.. weird though

"framer-motion": "10.16.4",
"react-datepicker": "4.14.1",
"react-intersection-observer": "9.2.2",
Expand All @@ -70,8 +71,8 @@
},
"peerDependencies": {
"@chakra-ui/focus-lock": ">=2.1.0",
"@chakra-ui/system": ">=2.6.2",
"@chakra-ui/react": ">=2.8.1",
"@chakra-ui/system": ">=2.6.2",
"@emotion/react": ">=11.11.1",
"@emotion/styled": ">=11.11.0",
"framer-motion": ">=10.16.4",
Expand Down Expand Up @@ -123,9 +124,9 @@
"prettier": "2.4.1",
"prop-types": "15.8.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-autosuggest": "10.0.2",
"react-docgen-typescript-loader": "3.7.2",
"react-dom": "18.2.0",
"react-test-renderer": "18.2.0",
"remark-gfm": "3.0.1",
"sass": "1.60.0",
Expand Down
8 changes: 4 additions & 4 deletions src/components/NewsletterSignup/NewsletterSignup.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import { changelogData } from "./newsletterSignupChangelogData";

# NewsletterSignup

| Component Version | DS Version |
| ----------------- | ---------- |
| Added | `2.1.0` |
| Latest | `2.1.2` |
| Component Version | DS Version |
| ----------------- | ------------ |
| Added | `2.1.0` |
| Latest | `Prerelease` |

## Table of Contents

Expand Down
9 changes: 8 additions & 1 deletion src/components/NewsletterSignup/NewsletterSignup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
Stack,
useColorModeValue,
useMultiStyleConfig,
ChakraComponent,
VStack,
} from "@chakra-ui/react";
import React, { forwardRef } from "react";
Expand Down Expand Up @@ -70,7 +71,13 @@ const defaultDescriptionText =
* The NewsletterSignup component provides a way for patrons to register for an
* email-based newsletter distribution list.
*/
export const NewsletterSignup: React.FC<any> = chakra(
export const NewsletterSignup: ChakraComponent<
React.ForwardRefExoticComponent<
React.PropsWithChildren<NewsletterSignupProps> &
React.RefAttributes<HTMLDivElement>
>,
React.PropsWithChildren<NewsletterSignupProps>
> = chakra(
forwardRef<HTMLDivElement, NewsletterSignupProps>(
(
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@
import { ChangelogData } from "../../utils/ComponentChangelogTable";

export const changelogData: ChangelogData[] = [
{
date: "Prerelease",
version: "Prerelease",
type: "Update",
affects: ["Styles"],
notes: ["Chakra 2.8 update."],
},
{
date: "2023-11-09",
version: "2.1.2",
Expand Down
15 changes: 11 additions & 4 deletions src/components/Radio/Radio.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@ import { ArgTypes, Canvas, Description, Meta } from "@storybook/blocks";

import * as RadioStories from "./Radio.stories";
import Link from "../Link/Link";
import ComponentChangelogTable from "../../utils/ComponentChangelogTable";
import { changelogData } from "./radioChangelogData";

<Meta of={RadioStories} />

# Radio

| Component Version | DS Version |
| ----------------- | ---------- |
| Added | `0.22.0` |
| Latest | `2.0.0` |
| Component Version | DS Version |
| ----------------- | ------------ |
| Added | `0.22.0` |
| Latest | `Prerelease` |

## Table of Contents

Expand All @@ -20,6 +22,7 @@ import Link from "../Link/Link";
- {<Link href="#browser-states" target="_self">Browser States</Link>}
- {<Link href="#helper-and-error-text" target="_self">Helper and Error Text</Link>}
- {<Link href="#label-using-jsx-elements" target="_self">Label Using JSX Elements</Link>}
- {<Link href="#changelog" target="_self">Changelog</Link>}

## Overview

Expand Down Expand Up @@ -67,3 +70,7 @@ a layout to the label. View the `RadioGroup` documentation for this
usage.

<Canvas of={RadioStories.LabelUsingJSXElements} />

## Changelog

<ComponentChangelogTable changelogData={changelogData} />
21 changes: 6 additions & 15 deletions src/components/Radio/Radio.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Box, HStack, VStack } from "@chakra-ui/react";
import type { Meta, StoryObj } from "@storybook/react";
import { withDesign } from "storybook-addon-designs";
import { argsBooleanType } from "../../helpers/storybookUtils";

import Heading from "../Heading/Heading";
import Radio from "./Radio";
Expand All @@ -13,24 +14,14 @@ const meta: Meta<typeof Radio> = {
className: { control: false },
id: { control: false },
isChecked: { control: false },
isDisabled: {
table: { defaultValue: { summary: false } },
},
isInvalid: {
table: { defaultValue: { summary: false } },
},
isRequired: {
table: { defaultValue: { summary: false } },
},
isDisabled: argsBooleanType(),
isInvalid: argsBooleanType(),
isRequired: argsBooleanType(),
key: { table: { disable: true } },
onChange: { control: false },
ref: { table: { disable: true } },
showHelperInvalidText: {
table: { defaultValue: { summary: true } },
},
showLabel: {
table: { defaultValue: { summary: true } },
},
showHelperInvalidText: argsBooleanType(true),
showLabel: argsBooleanType(true),
},
};

Expand Down
8 changes: 7 additions & 1 deletion src/components/Radio/Radio.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
Box,
chakra,
ChakraComponent,
Radio as ChakraRadio,
useMultiStyleConfig,
useStyleConfig,
Expand Down Expand Up @@ -51,7 +52,12 @@ export interface RadioProps {
value?: string;
}

export const Radio: React.FC<any> = chakra(
export const Radio: ChakraComponent<
React.ForwardRefExoticComponent<
React.PropsWithChildren<RadioProps> & React.RefAttributes<HTMLInputElement>
>,
React.PropsWithChildren<RadioProps>
> = chakra(
forwardRef<HTMLInputElement, RadioProps>((props, ref?) => {
const {
className,
Expand Down
19 changes: 19 additions & 0 deletions src/components/Radio/radioChangelogData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/** This data is used to populate the ComponentChangelogTable component.
*
* date: string (when adding new entry during development, set value as "Prerelease")
* version: string (when adding new entry during development, set value as "Prerelease")
* type: "Bug Fix" | "New Feature" | "Update";
* affects: array["Accessibility" | "Documentation" | "Functionality" | "Styles"];
* notes: array (will render as a bulleted list, add one array element for each list element)
*/
import { ChangelogData } from "../../utils/ComponentChangelogTable";

export const changelogData: ChangelogData[] = [
{
date: "Prerelease",
version: "Prerelease",
type: "Update",
affects: ["Styles"],
notes: ["Chakra 2.8 update."],
},
];
7 changes: 7 additions & 0 deletions src/components/RadioGroup/RadioGroup.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { ArgTypes, Canvas, Description, Meta, Source } from "@storybook/blocks";

import * as RadioGroupStories from "./RadioGroup.stories";
import Link from "../Link/Link";
import ComponentChangelogTable from "../../utils/ComponentChangelogTable";
import { changelogData } from "./radioGroupChangelogData";

<Meta of={RadioGroupStories} />

Expand All @@ -21,6 +23,7 @@ import Link from "../Link/Link";
- {<Link href="#browser-states" target="_self">Browser States</Link>}
- {<Link href="#labels-using-jsx-elements" target="_self">Labels Using JSX Elements</Link>}
- {<Link href="#getting-radio-input-values" target="_self">Getting Radio Input Values</Link>}
- {<Link href="#changelog" target="_self">Changelog</Link>}

## Overview

Expand Down Expand Up @@ -200,3 +203,7 @@ export function RadioGroupUncontrolledExample() {
/>

<Canvas of={RadioGroupStories.UncontrolledExample} />

## Changelog

<ComponentChangelogTable changelogData={changelogData} />
29 changes: 8 additions & 21 deletions src/components/RadioGroup/RadioGroup.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Box, Flex, Spacer, VStack } from "@chakra-ui/react";
import type { Meta, StoryObj } from "@storybook/react";
import { createRef } from "react";
import { withDesign } from "storybook-addon-designs";
import { argsBooleanType } from "../../helpers/storybookUtils";

import Button from "../Button/Button";
import ButtonGroup from "../ButtonGroup/ButtonGroup";
Expand All @@ -19,33 +20,19 @@ const meta: Meta<typeof RadioGroup> = {
children: { table: { disable: true } },
className: { control: false },
id: { control: false },
isDisabled: {
table: { defaultValue: { summary: false } },
},
isFullWidth: {
table: { defaultValue: { summary: false } },
},
isInvalid: {
table: { defaultValue: { summary: false } },
},
isRequired: {
table: { defaultValue: { summary: false } },
},
isDisabled: argsBooleanType(),
isFullWidth: argsBooleanType(),
isInvalid: argsBooleanType(),
isRequired: argsBooleanType(),
layout: {
table: { defaultValue: { summary: "column" } },
},
key: { table: { disable: true } },
onChange: { control: false },
ref: { table: { disable: true } },
showHelperInvalidText: {
table: { defaultValue: { summary: true } },
},
showLabel: {
table: { defaultValue: { summary: true } },
},
showRequiredLabel: {
table: { defaultValue: { summary: true } },
},
showHelperInvalidText: argsBooleanType(true),
showLabel: argsBooleanType(true),
showRequiredLabel: argsBooleanType(true),
},
};

Expand Down
9 changes: 8 additions & 1 deletion src/components/RadioGroup/RadioGroup.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
chakra,
ChakraComponent,
RadioGroup as ChakraRadioGroup,
Stack,
useMultiStyleConfig,
Expand Down Expand Up @@ -61,7 +62,13 @@ const noop = () => {};
* for this form group element and is not needed for individual DS `Radio`
* components when `RadioGroup` is used.
*/
export const RadioGroup: React.FC<any> = chakra(
export const RadioGroup: ChakraComponent<
React.ForwardRefExoticComponent<
React.PropsWithChildren<RadioGroupProps> &
React.RefAttributes<HTMLDivElement>
>,
React.PropsWithChildren<RadioGroupProps>
> = chakra(
forwardRef<HTMLDivElement, React.PropsWithChildren<RadioGroupProps>>(
(props, ref?) => {
const {
Expand Down
19 changes: 19 additions & 0 deletions src/components/RadioGroup/radioGroupChangelogData.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/** This data is used to populate the ComponentChangelogTable component.
*
* date: string (when adding new entry during development, set value as "Prerelease")
* version: string (when adding new entry during development, set value as "Prerelease")
* type: "Bug Fix" | "New Feature" | "Update";
* affects: array["Accessibility" | "Documentation" | "Functionality" | "Styles"];
* notes: array (will render as a bulleted list, add one array element for each list element)
*/
import { ChangelogData } from "../../utils/ComponentChangelogTable";

export const changelogData: ChangelogData[] = [
{
date: "Prerelease",
version: "Prerelease",
type: "Update",
affects: ["Styles"],
notes: ["Chakra 2.8 update."],
},
];
7 changes: 7 additions & 0 deletions src/components/SearchBar/SearchBar.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { ArgTypes, Canvas, Description, Meta, Source } from "@storybook/blocks";
import ComponentChangelogTable from "../../utils/ComponentChangelogTable";
import { changelogData } from "./searchBarChangelogData";

import * as SearchBarStories from "./SearchBar.stories";
import Link from "../Link/Link";
Expand All @@ -22,6 +24,7 @@ import Link from "../Link/Link";
- {<Link href="#form-states" target="_self">Form States</Link>}
- {<Link href="#heading-and-description-text" target="_self">Heading and Description Text</Link>}
- {<Link href="#textinput-and-onsubmit-values" target="_self">TextInput and onSubmit Values</Link>}
- {<Link href="#changelog" target="_self">Changelog</Link>}

## Overview

Expand Down Expand Up @@ -351,3 +354,7 @@ export function SearchBarValueExample() {
/>

<Canvas of={SearchBarStories.SearchBarValueExample} />

## Changelog

<ComponentChangelogTable changelogData={changelogData} />
13 changes: 4 additions & 9 deletions src/components/SearchBar/SearchBar.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { Meta, StoryObj } from "@storybook/react";
import { useState } from "react";
import { withDesign } from "storybook-addon-designs";
import { argsBooleanType } from "../../helpers/storybookUtils";

import SearchBar from "./SearchBar";
import * as autoSuggestStories from "../Autosuggest/Autosuggest.stories-unresolved";
Expand All @@ -18,15 +19,9 @@ const meta: Meta<typeof SearchBar> = {
},
className: { control: false },
id: { control: false },
isDisabled: {
table: { defaultValue: { summary: false } },
},
isInvalid: {
table: { defaultValue: { summary: false } },
},
isRequired: {
table: { defaultValue: { summary: false } },
},
isDisabled: argsBooleanType(),
isInvalid: argsBooleanType(),
isRequired: argsBooleanType(),
method: { control: false },
onSubmit: { control: false },
selectProps: { control: false },
Expand Down
7 changes: 7 additions & 0 deletions src/components/SearchBar/searchBarChangelogData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@
import { ChangelogData } from "../../utils/ComponentChangelogTable";

export const changelogData: ChangelogData[] = [
{
date: "Prerelease",
version: "Prerelease",
type: "Update",
affects: ["Styles"],
notes: ["Chakra 2.8 update."],
},
{
date: "Prerelease",
version: "Prerelease",
Expand Down
7 changes: 7 additions & 0 deletions src/helpers/storybookUtils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* For usage in Storybook stories to set the default value of a boolean prop.
*/
export const argsBooleanType = (defaultValue = false) => ({
control: { type: "boolean" },
table: { defaultValue: { summary: defaultValue } },
});
Loading
Loading