diff --git a/packages/react-core/src/components/LabelGroup/examples/LabelGroup.md b/packages/react-core/src/components/LabelGroup/examples/LabelGroup.md index ced45c111c7..788c751620a 100644 --- a/packages/react-core/src/components/LabelGroup/examples/LabelGroup.md +++ b/packages/react-core/src/components/LabelGroup/examples/LabelGroup.md @@ -13,196 +13,30 @@ import InfoCircleIcon from '@patternfly/react-icons/dist/esm/icons/info-circle-i ### Basic -```js -import React from 'react'; -import { Label, LabelGroup } from '@patternfly/react-core'; -import InfoCircleIcon from '@patternfly/react-icons/dist/esm/icons/info-circle-icon'; - - - - - -; +```ts file="LabelGroupBasic.tsx" ``` ### Overflow -```js -import React from 'react'; -import { Label, LabelGroup } from '@patternfly/react-core'; -import InfoCircleIcon from '@patternfly/react-icons/dist/esm/icons/info-circle-icon'; - - - - - - - - -; +```ts file="LabelGroupOverflow.tsx" ``` ### Category -```js -import React from 'react'; -import { Label, LabelGroup } from '@patternfly/react-core'; -import InfoCircleIcon from '@patternfly/react-icons/dist/esm/icons/info-circle-icon'; - - - - - -; +```ts file="LabelGroupCategory.tsx" ``` ### Category removable -```js -import React from 'react'; -import { Label, LabelGroup } from '@patternfly/react-core'; -import InfoCircleIcon from '@patternfly/react-icons/dist/esm/icons/info-circle-icon'; - -CategoryLabelGroupRemovable = () => { - const [labels, setLabels] = React.useState([ - ['Label 1', 'grey'], - ['Label 2', 'blue'], - ['Label 3', 'green'], - ['Label 4', 'orange'], - ['Label 5', 'red'] - ]); - const deleteCategory = () => setLabels([]); - - return ( - - {labels.map(([labelText, labelColor]) => ( - - ))} - - ); -}; +```ts file="LabelGroupCategoryRemovable.tsx" ``` ### Vertical category overflow removable -```js -import React from 'react'; -import { Label, LabelGroup } from '@patternfly/react-core'; -import InfoCircleIcon from '@patternfly/react-icons/dist/esm/icons/info-circle-icon'; - -VerticalCategoryLabelGroupOverflowRemovable = () => { - const [labels, setLabels] = React.useState([ - ['Label 1', 'grey'], - ['Label 2', 'blue'], - ['Label 3', 'green'], - ['Label 4', 'orange'], - ['Label 5', 'red'] - ]); - const deleteCategory = () => setLabels([]); - - return ( - - {labels.map(([labelText, labelColor]) => ( - - ))} - - ); -}; +```ts file="LabelGroupVerticalCategoryOverflowRemovable.tsx" ``` ### Editable labels -```js isBeta -import React from 'react'; -import { LabelGroup, Label, TextArea } from '@patternfly/react-core'; - -class EditableLabelGroup extends React.Component { - constructor(props) { - super(props); - this.state = { - label1: 'Editable label', - label2: 'Editable label 2', - label3: 'Editable label 3' - }; - this.onEditCancel = (prevText, label) => { - this.setState({ - [label]: prevText - }); - }; - this.onEditComplete = (newText, label) => { - this.setState({ - [label]: newText - }); - }; - } - - render() { - return ( - - - - - - - ); - } -} +```ts file="LabelGroupEditableLabels.tsx" isBeta ``` diff --git a/packages/react-core/src/components/LabelGroup/examples/LabelGroupBasic.tsx b/packages/react-core/src/components/LabelGroup/examples/LabelGroupBasic.tsx new file mode 100644 index 00000000000..8e0faf8e016 --- /dev/null +++ b/packages/react-core/src/components/LabelGroup/examples/LabelGroupBasic.tsx @@ -0,0 +1,15 @@ +import React from 'react'; +import { Label, LabelGroup } from '@patternfly/react-core'; +import InfoCircleIcon from '@patternfly/react-icons/dist/esm/icons/info-circle-icon'; + +export const LabelGroupBasic: React.FunctionComponent = () => ( + + + + + +); diff --git a/packages/react-core/src/components/LabelGroup/examples/LabelGroupCategory.tsx b/packages/react-core/src/components/LabelGroup/examples/LabelGroupCategory.tsx new file mode 100644 index 00000000000..205999b4a69 --- /dev/null +++ b/packages/react-core/src/components/LabelGroup/examples/LabelGroupCategory.tsx @@ -0,0 +1,15 @@ +import React from 'react'; +import { Label, LabelGroup } from '@patternfly/react-core'; +import InfoCircleIcon from '@patternfly/react-icons/dist/esm/icons/info-circle-icon'; + +export const LabelGroupCategory: React.FunctionComponent = () => ( + + + + + +); diff --git a/packages/react-core/src/components/LabelGroup/examples/LabelGroupCategoryRemovable.tsx b/packages/react-core/src/components/LabelGroup/examples/LabelGroupCategoryRemovable.tsx new file mode 100644 index 00000000000..31e12221da3 --- /dev/null +++ b/packages/react-core/src/components/LabelGroup/examples/LabelGroupCategoryRemovable.tsx @@ -0,0 +1,24 @@ +import React from 'react'; +import { Label, LabelGroup, LabelProps } from '@patternfly/react-core'; +import InfoCircleIcon from '@patternfly/react-icons/dist/esm/icons/info-circle-icon'; + +export const LabelGroupCategoryRemovable: React.FunctionComponent = () => { + const [labels, setLabels] = React.useState([ + ['Label 1', 'grey'], + ['Label 2', 'blue'], + ['Label 3', 'green'], + ['Label 4', 'orange'], + ['Label 5', 'red'] + ]); + const deleteCategory = () => setLabels([]); + + return ( + + {labels.map(([labelText, labelColor]) => ( + + ))} + + ); +}; diff --git a/packages/react-core/src/components/LabelGroup/examples/LabelGroupEditableLabels.tsx b/packages/react-core/src/components/LabelGroup/examples/LabelGroupEditableLabels.tsx new file mode 100644 index 00000000000..c9f59089869 --- /dev/null +++ b/packages/react-core/src/components/LabelGroup/examples/LabelGroupEditableLabels.tsx @@ -0,0 +1,53 @@ +import React from 'react'; +import { LabelGroup, Label } from '@patternfly/react-core'; + +export const LabelGroupEditableLabels: React.FunctionComponent = () => { + const [label1, setLabel1] = React.useState('Editable label'); + const [label2, setLabel2] = React.useState('Editable label 2'); + const [label3, setLabel3] = React.useState('Editable label 3'); + + return ( + + + + + + + ); +}; diff --git a/packages/react-core/src/components/LabelGroup/examples/LabelGroupOverflow.tsx b/packages/react-core/src/components/LabelGroup/examples/LabelGroupOverflow.tsx new file mode 100644 index 00000000000..dcfeeaf5b4d --- /dev/null +++ b/packages/react-core/src/components/LabelGroup/examples/LabelGroupOverflow.tsx @@ -0,0 +1,24 @@ +import React from 'react'; +import { Label, LabelGroup } from '@patternfly/react-core'; +import InfoCircleIcon from '@patternfly/react-icons/dist/esm/icons/info-circle-icon'; + +export const LabelGroupOverflow: React.FunctionComponent = () => ( + + + + + + + + +); diff --git a/packages/react-core/src/components/LabelGroup/examples/LabelGroupVerticalCategoryOverflowRemovable.tsx b/packages/react-core/src/components/LabelGroup/examples/LabelGroupVerticalCategoryOverflowRemovable.tsx new file mode 100644 index 00000000000..25f5cb33124 --- /dev/null +++ b/packages/react-core/src/components/LabelGroup/examples/LabelGroupVerticalCategoryOverflowRemovable.tsx @@ -0,0 +1,24 @@ +import React from 'react'; +import { Label, LabelGroup, LabelProps } from '@patternfly/react-core'; +import InfoCircleIcon from '@patternfly/react-icons/dist/esm/icons/info-circle-icon'; + +export const LabelGroupVerticalCategoryOverflowRemovable: React.FunctionComponent = () => { + const [labels, setLabels] = React.useState([ + ['Label 1', 'grey'], + ['Label 2', 'blue'], + ['Label 3', 'green'], + ['Label 4', 'orange'], + ['Label 5', 'red'] + ]); + const deleteCategory = () => setLabels([]); + + return ( + + {labels.map(([labelText, labelColor]) => ( + + ))} + + ); +};