Skip to content

Commit

Permalink
Radio done
Browse files Browse the repository at this point in the history
  • Loading branch information
7emansell committed Dec 19, 2023
1 parent 1091596 commit 1d066fe
Show file tree
Hide file tree
Showing 8 changed files with 2,025 additions and 150 deletions.
1,907 changes: 1,871 additions & 36 deletions package-lock.json

Large diffs are not rendered by default.

17 changes: 9 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,15 @@
"types-ramda": "0.29.4"
},
"dependencies": {
"@chakra-ui/focus-lock": "2.1.0",
"@chakra-ui/react": "2.8.1",
"@chakra-ui/system": "2.6.2",
"@chakra-ui/focus-lock": ">=2.1.0",
"@chakra-ui/react": ">=2.8.1",
"@chakra-ui/system": ">=2.6.2",
"@charlietango/use-native-lazy-loading": "1.10.0",
"@emotion/react": "11.11.1",
"@emotion/styled": "11.11.0",
"@emotion/react": ">=11.11.1",
"@emotion/styled": ">=11.11.0",
"downshift": "6.1.7",
"framer-motion": "10.16.4",
"esbuild": "^0.19.10",
"framer-motion": ">=10.16.4",
"react-datepicker": "4.14.1",
"react-intersection-observer": "9.2.2",
"system-font-css": "2.0.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
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<HTMLSelectElement>
>,
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/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

0 comments on commit 1d066fe

Please sign in to comment.