From 19c5e21f9cfc74e0d894868457783c2098b2ea8e Mon Sep 17 00:00:00 2001 From: Jared Palmer Date: Fri, 15 Mar 2019 17:25:53 -0400 Subject: [PATCH] Update readme --- README.md | 160 ++++++++++++++++++++++++++++++++---------------------- 1 file changed, 96 insertions(+), 64 deletions(-) diff --git a/README.md b/README.md index 3d8afb9..f59f82b 100644 --- a/README.md +++ b/README.md @@ -7,20 +7,24 @@ An accessible [WAI-ARIA 1.1-compliant Radio Group](https://www.w3.org/TR/wai-ari + - [Installation](#installation) - [Usage](#usage) - [Usage with Formik v2](#usage-with-formik-v2) -- [Overriding Styles](#overriding-styles) - [API Reference](#api-reference) - [``](#radiogroup-) - [`labelledBy?: string`](#labelledby-string) - [`onChange: (value: any) => void`](#onchange-value-any--void) - [`children: React.ComponentType[]`](#children-reactcomponenttyperadioprops) - - [``](#radio) - [`value: any`](#value-any) + - [``](#radio) + - [`value: any`](#value-any-1) + - [`onFocus?: () => void`](#onfocus---void) + - [`onBlur?: () => void`](#onblur---void) + - [Overriding Styles](#overriding-styles) - [Accessibility Features](#accessibility-features) - [Keyboard Support](#keyboard-support) -- [Role, Property, State, and Tabindex Attributes](#role-property-state-and-tabindex--attributes) +- [Role, Property, State, and Tabindex Attributes](#role-property-state-and-tabindex--attributes) - [Authors](#authors) @@ -46,7 +50,11 @@ function App() { return ( <>

Color

- setValue(value)}> + setValue(value)} + > Blue Red Green @@ -104,7 +112,90 @@ function App() { } ``` -## Overriding Styles +## API Reference + +### `` + +This renders a `div` and will pass through all props to the DOM element. It's children must be `` components. + +#### `labelledBy?: string` + +This should match the `id` you used to label the radio group. + +```tsx +

Color

+ + {/* ... */} + +``` + +#### `onChange: (value: any) => void` + +A callback function that will be fired with the `value` of the newly selected item. + +```tsx +import * as React from 'react'; +import { RadioGroup, Radio } from '@palmerhq/radio-button'; +import '@palmerhq/radio-button/styles.css'; // use the default styles + +function App() { + const [value, setValue] = React.useState(); + + return ( + <> +

Color

+ setValue(value)} + > + Blue + Red + Green + + + ); +} +``` + +#### `children: React.ComponentType[]` + +**Required** + +The children of a `` can **ONLY** be `` components. In order to support compliant keyboard behavior, each sibling must know the value of the whole group and so `React.Children.map` is used internally. + +```tsx +

Color

+ + {/* ... */} + +``` + +#### `value: any` + +**Required** + +The current value of the radio group. This is shallowly compared to each `value` prop of the child `` components to determine which item is active. + +### `` + +This renders a `div` and will pass through all props to the DOM element. + +#### `value: any` + +**Required** + +The value of the radio button. This will be set / passed back to the `` when the item is selected. + +#### `onFocus?: () => void` + +Callback function for when the item is focused + +#### `onBlur?: () => void` + +Callback function for when the item is blurred + +### Overriding Styles These are the default styles. Copy and paste the following into your app to customize them. @@ -200,65 +291,6 @@ These are the default styles. Copy and paste the following into your app to cust } ``` -## API Reference - -### `` - -#### `labelledBy?: string` - -This should match the `id` you used to label the radio group. - -```tsx -

Color

- - {/* ... */} - -``` - -#### `onChange: (value: any) => void` - -A callback function that will be fired with the `value` of the newly selected item. - -```tsx -import * as React from 'react'; -import { RadioGroup, Radio } from '@palmerhq/radio-button'; -import '@palmerhq/radio-button/styles.css'; // use the default styles - -function App() { - const [value, setValue] = React.useState(); - - return ( - <> -

Color

- setValue(value)}> - Blue - Red - Green - - - ); -} -``` - -#### `children: React.ComponentType[]` - -**Required** - -The children of a `` can **ONLY** be `` components. In order to support compliant keyboard behavior, each sibling must know the value of the whole group and so `React.Children.map` is used internally. - -```tsx -

Color

- - {/* ... */} - -``` - -### `` - -#### `value: any` - -Each - ## Accessibility Features - Uses CSS attribute selectors for synchronizing `aria-checked` state with the visual state indicator.