From 39a4cae57c527d5a23bb4821219174c505a16ea3 Mon Sep 17 00:00:00 2001 From: valerio bartolini Date: Wed, 1 Jun 2022 07:30:32 +0200 Subject: [PATCH 1/2] refactor(Hint): Convert hint examples to typescript --- .../src/components/Hint/examples/Hint.md | 169 +----------------- .../Hint/examples/HintBasicWithTitle.tsx | 65 +++++++ .../Hint/examples/HintBasicWithoutTitle.tsx | 74 ++++++++ 3 files changed, 141 insertions(+), 167 deletions(-) create mode 100644 packages/react-core/src/components/Hint/examples/HintBasicWithTitle.tsx create mode 100644 packages/react-core/src/components/Hint/examples/HintBasicWithoutTitle.tsx diff --git a/packages/react-core/src/components/Hint/examples/Hint.md b/packages/react-core/src/components/Hint/examples/Hint.md index d09610a680e..b29df2aed1a 100644 --- a/packages/react-core/src/components/Hint/examples/Hint.md +++ b/packages/react-core/src/components/Hint/examples/Hint.md @@ -9,175 +9,10 @@ propComponents: ['Hint', 'HintTitle', 'HintBody', 'HintFooter'] ### Basic with title -```js -import React from 'react'; -import { - Hint, - HintTitle, - HintBody, - HintFooter, - Button, - Dropdown, - DropdownToggle, - DropdownItem, - DropdownSeparator, - DropdownPosition, - DropdownDirection, - KebabToggle -} from '@patternfly/react-core'; - -class BasicHint extends React.Component { - constructor(props) { - super(props); - this.state = { - isOpen: false - }; - this.onToggle = isOpen => { - this.setState({ - isOpen - }); - }; - this.onSelect = event => { - this.setState({ - isOpen: !this.state.isOpen - }); - }; - } - - render() { - const { isOpen } = this.state; - const dropdownItems = [ - Link, - - Action - , - - Disabled Link - , - - Disabled Action - , - , - Separated Link, - - Separated Action - - ]; - const actions = ( - } - isOpen={isOpen} - dropdownItems={dropdownItems} - position="right" - isPlain - /> - ); - return ( - - Do more with Find it Fix it capabilities - - Upgrade to Red Hat Smart Management to remediate all your systems across regions and geographies. - - - - - - ); - } -} +```ts file="HintBasicWithTitle.tsx" ``` ### Basic without title -```js -import React from 'react'; -import { - Hint, - HintBody, - HintFooter, - Button, - Dropdown, - DropdownToggle, - DropdownItem, - DropdownSeparator, - DropdownPosition, - DropdownDirection, - KebabToggle -} from '@patternfly/react-core'; - -class BasicHint extends React.Component { - constructor(props) { - super(props); - this.state = { - isOpen: false - }; - this.onToggle = isOpen => { - this.setState({ - isOpen - }); - }; - this.onSelect = event => { - this.setState({ - isOpen: !this.state.isOpen - }); - }; - } - - render() { - const { isOpen } = this.state; - const dropdownItems = [ - Link, - - Action - , - - Disabled Link - , - - Disabled Action - , - , - Separated Link, - - Separated Action - - ]; - const actions = ( - } - isOpen={isOpen} - dropdownItems={dropdownItems} - position="right" - isPlain - /> - ); - return ( - - - - Welcome to the new documentation experience. - - - -
- - - Upgrade to Red Hat Smart Management to remediate all your systems across regions and geographies. - - - - - -
- ); - } -} +```ts file="HintBasicWithoutTitle.tsx" ``` diff --git a/packages/react-core/src/components/Hint/examples/HintBasicWithTitle.tsx b/packages/react-core/src/components/Hint/examples/HintBasicWithTitle.tsx new file mode 100644 index 00000000000..636b4b84668 --- /dev/null +++ b/packages/react-core/src/components/Hint/examples/HintBasicWithTitle.tsx @@ -0,0 +1,65 @@ +import React from 'react'; +import { + Hint, + HintTitle, + HintBody, + HintFooter, + Button, + Dropdown, + DropdownItem, + DropdownSeparator, + KebabToggle +} from '@patternfly/react-core'; + +export const BasicHint: React.FunctionComponent = () => { + const [isOpen, setIsOpen] = React.useState(false); + + const onToggle = (isOpen: boolean) => { + setIsOpen(isOpen); + }; + + const onSelect = () => { + setIsOpen(!isOpen); + }; + + const dropdownItems = [ + Link, + + Action + , + + Disabled Link + , + + Disabled Action + , + , + Separated Link, + + Separated Action + + ]; + const actions = ( + } + isOpen={isOpen} + dropdownItems={dropdownItems} + position="right" + isPlain + /> + ); + return ( + + Do more with Find it Fix it capabilities + + Upgrade to Red Hat Smart Management to remediate all your systems across regions and geographies. + + + + + + ); +}; diff --git a/packages/react-core/src/components/Hint/examples/HintBasicWithoutTitle.tsx b/packages/react-core/src/components/Hint/examples/HintBasicWithoutTitle.tsx new file mode 100644 index 00000000000..8f8c984119c --- /dev/null +++ b/packages/react-core/src/components/Hint/examples/HintBasicWithoutTitle.tsx @@ -0,0 +1,74 @@ +import React from 'react'; +import { + Hint, + HintBody, + HintFooter, + Button, + Dropdown, + DropdownItem, + DropdownSeparator, + KebabToggle +} from '@patternfly/react-core'; + +export const BasicHint: React.FunctionComponent = () => { + const [isOpen, setIsOpen] = React.useState(false); + + const onToggle = (isOpen: boolean) => { + setIsOpen(isOpen); + }; + + const onSelect = () => { + setIsOpen(!isOpen); + }; + + const dropdownItems = [ + Link, + + Action + , + + Disabled Link + , + + Disabled Action + , + , + Separated Link, + + Separated Action + + ]; + const actions = ( + } + isOpen={isOpen} + dropdownItems={dropdownItems} + position="right" + isPlain + /> + ); + return ( + + + + Welcome to the new documentation experience. + + + +
+ + + Upgrade to Red Hat Smart Management to remediate all your systems across regions and geographies. + + + + + +
+ ); +}; From 6e0c2a971107df5abce8ab9b068fc014ac3595ad Mon Sep 17 00:00:00 2001 From: valerio bartolini Date: Wed, 1 Jun 2022 21:56:53 +0200 Subject: [PATCH 2/2] refactor(Hint): update PR comments --- .../src/components/Hint/examples/HintBasicWithTitle.tsx | 2 +- .../src/components/Hint/examples/HintBasicWithoutTitle.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/react-core/src/components/Hint/examples/HintBasicWithTitle.tsx b/packages/react-core/src/components/Hint/examples/HintBasicWithTitle.tsx index 636b4b84668..d84282ebd37 100644 --- a/packages/react-core/src/components/Hint/examples/HintBasicWithTitle.tsx +++ b/packages/react-core/src/components/Hint/examples/HintBasicWithTitle.tsx @@ -11,7 +11,7 @@ import { KebabToggle } from '@patternfly/react-core'; -export const BasicHint: React.FunctionComponent = () => { +export const HintBasicWithTitle: React.FunctionComponent = () => { const [isOpen, setIsOpen] = React.useState(false); const onToggle = (isOpen: boolean) => { diff --git a/packages/react-core/src/components/Hint/examples/HintBasicWithoutTitle.tsx b/packages/react-core/src/components/Hint/examples/HintBasicWithoutTitle.tsx index 8f8c984119c..ec7c1055cb3 100644 --- a/packages/react-core/src/components/Hint/examples/HintBasicWithoutTitle.tsx +++ b/packages/react-core/src/components/Hint/examples/HintBasicWithoutTitle.tsx @@ -10,7 +10,7 @@ import { KebabToggle } from '@patternfly/react-core'; -export const BasicHint: React.FunctionComponent = () => { +export const HintBasicWithoutTitle: React.FunctionComponent = () => { const [isOpen, setIsOpen] = React.useState(false); const onToggle = (isOpen: boolean) => {