From 596bfb9d8f458832ef669b323df379b39506a715 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Pet=C5=99=C3=ADk?= Date: Mon, 18 Jul 2022 15:40:23 +0200 Subject: [PATCH 1/2] chore(Radio): convert examples to TypeScript --- .../src/components/Radio/examples/Radio.md | 80 +++---------------- .../Radio/examples/RadioControlled.tsx | 21 +++++ .../Radio/examples/RadioDisabled.tsx | 15 ++++ .../Radio/examples/RadioLabelWraps.tsx | 6 ++ .../Radio/examples/RadioReversed.tsx | 6 ++ .../Radio/examples/RadioStandaloneInput.tsx | 6 ++ .../Radio/examples/RadioUncontrolled.tsx | 6 ++ .../Radio/examples/RadioWithBody.tsx | 6 ++ .../Radio/examples/RadioWithDescription.tsx | 11 +++ .../examples/RadioWithDescriptionAndBody.tsx | 12 +++ 10 files changed, 101 insertions(+), 68 deletions(-) create mode 100644 packages/react-core/src/components/Radio/examples/RadioControlled.tsx create mode 100644 packages/react-core/src/components/Radio/examples/RadioDisabled.tsx create mode 100644 packages/react-core/src/components/Radio/examples/RadioLabelWraps.tsx create mode 100644 packages/react-core/src/components/Radio/examples/RadioReversed.tsx create mode 100644 packages/react-core/src/components/Radio/examples/RadioStandaloneInput.tsx create mode 100644 packages/react-core/src/components/Radio/examples/RadioUncontrolled.tsx create mode 100644 packages/react-core/src/components/Radio/examples/RadioWithBody.tsx create mode 100644 packages/react-core/src/components/Radio/examples/RadioWithDescription.tsx create mode 100644 packages/react-core/src/components/Radio/examples/RadioWithDescriptionAndBody.tsx diff --git a/packages/react-core/src/components/Radio/examples/Radio.md b/packages/react-core/src/components/Radio/examples/Radio.md index 2fe14ab9c43..fe26623a9fa 100644 --- a/packages/react-core/src/components/Radio/examples/Radio.md +++ b/packages/react-core/src/components/Radio/examples/Radio.md @@ -7,104 +7,48 @@ ouia: true --- ## Examples + ### Controlled -```js -import React from 'react'; -import { Radio } from '@patternfly/react-core'; - -class ControlledRadio extends React.Component { - constructor(props) { - super(props); - this.state = { - check1: false, - }; - - this.handleChange = (_, event) => { - const { value } = event.currentTarget; - this.setState({ [value]: true }); - }; - } - - render() { - return ( - - - - ); - } -} + +```ts file="./RadioControlled.tsx" ``` ### Uncontrolled -```js -import React from 'react'; -import { Radio } from '@patternfly/react-core'; - +```ts file="./RadioUncontrolled.tsx" ``` ### Reversed -```js -import React from 'react'; -import { Radio } from '@patternfly/react-core'; - +```ts file="./RadioReversed.tsx" ``` ### Label wraps -```js -import React from 'react'; -import { Radio } from '@patternfly/react-core'; - +```ts file="./RadioLabelWraps.tsx" ``` ### Disabled -```js -import React from 'react'; -import { Radio } from '@patternfly/react-core'; - - - - - + +```ts file="./RadioDisabled.tsx" ``` ### With description -```js -import React from 'react'; -import { Radio } from '@patternfly/react-core'; - +```ts file="./RadioWithDescription.tsx" ``` ### With body -```js -import React from 'react'; -import { Radio } from '@patternfly/react-core'; - +```ts file="./RadioWithBody.tsx" ``` ### With description and body -```js -import React from 'react'; -import { Radio } from '@patternfly/react-core'; - +```ts file="./RadioWithDescriptionAndBody.tsx" ``` ### Standalone input -```js -import React from 'react'; -import { Radio } from '@patternfly/react-core'; - +```ts file="./RadioStandaloneInput.tsx" ``` diff --git a/packages/react-core/src/components/Radio/examples/RadioControlled.tsx b/packages/react-core/src/components/Radio/examples/RadioControlled.tsx new file mode 100644 index 00000000000..09f24181e71 --- /dev/null +++ b/packages/react-core/src/components/Radio/examples/RadioControlled.tsx @@ -0,0 +1,21 @@ +import React from 'react'; +import { Radio } from '@patternfly/react-core'; + +export const RadioControlled: React.FunctionComponent = () => { + const [check1, setCheck1] = React.useState(false); + + function handleChange(_: boolean) { + setCheck1(true); + } + return ( + + + + ); +}; diff --git a/packages/react-core/src/components/Radio/examples/RadioDisabled.tsx b/packages/react-core/src/components/Radio/examples/RadioDisabled.tsx new file mode 100644 index 00000000000..08183cb58b4 --- /dev/null +++ b/packages/react-core/src/components/Radio/examples/RadioDisabled.tsx @@ -0,0 +1,15 @@ +import React from 'react'; +import { Radio } from '@patternfly/react-core'; + +export const RadioDisabled: React.FunctionComponent = () => ( + + + + +); diff --git a/packages/react-core/src/components/Radio/examples/RadioLabelWraps.tsx b/packages/react-core/src/components/Radio/examples/RadioLabelWraps.tsx new file mode 100644 index 00000000000..c7888590b8f --- /dev/null +++ b/packages/react-core/src/components/Radio/examples/RadioLabelWraps.tsx @@ -0,0 +1,6 @@ +import React from 'react'; +import { Radio } from '@patternfly/react-core'; + +export const RadioLabelWraps: React.FunctionComponent = () => ( + +); diff --git a/packages/react-core/src/components/Radio/examples/RadioReversed.tsx b/packages/react-core/src/components/Radio/examples/RadioReversed.tsx new file mode 100644 index 00000000000..5c0951955da --- /dev/null +++ b/packages/react-core/src/components/Radio/examples/RadioReversed.tsx @@ -0,0 +1,6 @@ +import React from 'react'; +import { Radio } from '@patternfly/react-core'; + +export const RadioReversed: React.FunctionComponent = () => ( + +); diff --git a/packages/react-core/src/components/Radio/examples/RadioStandaloneInput.tsx b/packages/react-core/src/components/Radio/examples/RadioStandaloneInput.tsx new file mode 100644 index 00000000000..4f0aac7f8e1 --- /dev/null +++ b/packages/react-core/src/components/Radio/examples/RadioStandaloneInput.tsx @@ -0,0 +1,6 @@ +import React from 'react'; +import { Radio } from '@patternfly/react-core'; + +export const RadioStandaloneInput: React.FunctionComponent = () => ( + +); diff --git a/packages/react-core/src/components/Radio/examples/RadioUncontrolled.tsx b/packages/react-core/src/components/Radio/examples/RadioUncontrolled.tsx new file mode 100644 index 00000000000..da70f382536 --- /dev/null +++ b/packages/react-core/src/components/Radio/examples/RadioUncontrolled.tsx @@ -0,0 +1,6 @@ +import React from 'react'; +import { Radio } from '@patternfly/react-core'; + +export const RadioUncontrolled: React.FunctionComponent = () => ( + +); diff --git a/packages/react-core/src/components/Radio/examples/RadioWithBody.tsx b/packages/react-core/src/components/Radio/examples/RadioWithBody.tsx new file mode 100644 index 00000000000..804550d5ad0 --- /dev/null +++ b/packages/react-core/src/components/Radio/examples/RadioWithBody.tsx @@ -0,0 +1,6 @@ +import React from 'react'; +import { Radio } from '@patternfly/react-core'; + +export const RadioWithBody: React.FunctionComponent = () => ( + +); diff --git a/packages/react-core/src/components/Radio/examples/RadioWithDescription.tsx b/packages/react-core/src/components/Radio/examples/RadioWithDescription.tsx new file mode 100644 index 00000000000..2e92b7795b7 --- /dev/null +++ b/packages/react-core/src/components/Radio/examples/RadioWithDescription.tsx @@ -0,0 +1,11 @@ +import React from 'react'; +import { Radio } from '@patternfly/react-core'; + +export const RadioWithDescription: React.FunctionComponent = () => ( + +); diff --git a/packages/react-core/src/components/Radio/examples/RadioWithDescriptionAndBody.tsx b/packages/react-core/src/components/Radio/examples/RadioWithDescriptionAndBody.tsx new file mode 100644 index 00000000000..c50158c3968 --- /dev/null +++ b/packages/react-core/src/components/Radio/examples/RadioWithDescriptionAndBody.tsx @@ -0,0 +1,12 @@ +import React from 'react'; +import { Radio } from '@patternfly/react-core'; + +export const RadioWithDescriptionAndBody: React.FunctionComponent = () => ( + +); From eab294c36589dc8b927b100827d0cba3fcec7206 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Pet=C5=99=C3=ADk?= Date: Mon, 25 Jul 2022 16:34:51 +0200 Subject: [PATCH 2/2] chore(Radio): convert examples to TypeScript --- .../src/components/Radio/examples/RadioControlled.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/react-core/src/components/Radio/examples/RadioControlled.tsx b/packages/react-core/src/components/Radio/examples/RadioControlled.tsx index 09f24181e71..957da3eb7e0 100644 --- a/packages/react-core/src/components/Radio/examples/RadioControlled.tsx +++ b/packages/react-core/src/components/Radio/examples/RadioControlled.tsx @@ -4,9 +4,9 @@ import { Radio } from '@patternfly/react-core'; export const RadioControlled: React.FunctionComponent = () => { const [check1, setCheck1] = React.useState(false); - function handleChange(_: boolean) { + const handleChange = () => { setCheck1(true); - } + }; return (