From 237fa24293db28089930455acde48e9ed5140e43 Mon Sep 17 00:00:00 2001 From: Jeff Puzzo Date: Wed, 24 May 2023 15:53:07 -0400 Subject: [PATCH 1/2] chore(PrimaryDetail): Update demos with deprecated Select to use latest Select --- .../react-core/src/demos/PrimaryDetail.md | 1400 +---------------- .../PrimaryDetailContentPadding.tsx | 444 ++++++ .../PrimaryDetail/PrimaryDetailFullPage.tsx | 444 ++++++ .../PrimaryDetailInlineModifier.tsx | 444 ++++++ 4 files changed, 1339 insertions(+), 1393 deletions(-) create mode 100644 packages/react-core/src/demos/examples/PrimaryDetail/PrimaryDetailContentPadding.tsx create mode 100644 packages/react-core/src/demos/examples/PrimaryDetail/PrimaryDetailFullPage.tsx create mode 100644 packages/react-core/src/demos/examples/PrimaryDetail/PrimaryDetailInlineModifier.tsx diff --git a/packages/react-core/src/demos/PrimaryDetail.md b/packages/react-core/src/demos/PrimaryDetail.md index cbb98f188bc..32be47f1363 100644 --- a/packages/react-core/src/demos/PrimaryDetail.md +++ b/packages/react-core/src/demos/PrimaryDetail.md @@ -3,8 +3,6 @@ id: Primary-detail section: patterns --- -import { Select as SelectDeprecated, SelectOption as SelectOptionDeprecated, SelectVariant } from '@patternfly/react-core/deprecated'; -import DashboardWrapper from '@patternfly/react-core/src/demos/examples/DashboardWrapper'; import CodeBranchIcon from '@patternfly/react-icons/dist/esm/icons/code-branch-icon'; import TrashIcon from '@patternfly/react-icons/dist/esm/icons/trash-icon'; import CodeIcon from '@patternfly/react-icons/dist/esm/icons/code-icon'; @@ -26,943 +24,20 @@ import azureIcon from './Card/FuseConnector_Icons_AzureServices.png'; import restIcon from './Card/FuseConnector_Icons_REST.png'; import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-icon'; import { data } from '@patternfly/react-core/src/demos/Card/CardData.jsx'; +import DashboardWrapper from './examples/DashboardWrapper'; ## Demos ### Primary-detail full page -```js isFullscreen -import React from 'react'; -import { - Button, - ButtonVariant, - DataList, - DataListAction, - DataListCell, - DataListItem, - DataListItemCells, - DataListItemRow, - Toolbar, - ToolbarItem, - ToolbarContent, - ToolbarToggleGroup, - ToolbarGroup, - Divider, - Drawer, - DrawerActions, - DrawerCloseButton, - DrawerContent, - DrawerContentBody, - DrawerHead, - DrawerPanelBody, - DrawerPanelContent, - Flex, - FlexItem, - InputGroup, - InputGroupItem, - PageSection, - PageSectionVariants, - Progress, - Stack, - StackItem, - Text, - TextContent, - TextInput, - Title -} from '@patternfly/react-core'; -import { - Select as SelectDeprecated, - SelectOption as SelectOptionDeprecated, - SelectVariant -} from '@patternfly/react-core/deprecated'; -import DashboardWrapper from '@patternfly/react-core/src/demos/examples/DashboardWrapper'; -import CodeBranchIcon from '@patternfly/react-icons/dist/esm/icons/code-branch-icon'; -import CodeIcon from '@patternfly/react-icons/dist/esm/icons/code-icon'; -import CubeIcon from '@patternfly/react-icons/dist/esm/icons/cube-icon'; -import CheckCircleIcon from '@patternfly/react-icons/dist/esm/icons/check-circle-icon'; -import ExclamationTriangleIcon from '@patternfly/react-icons/dist/esm/icons/exclamation-triangle-icon'; -import FilterIcon from '@patternfly/react-icons/dist/esm/icons/filter-icon'; -import SearchIcon from '@patternfly/react-icons/dist/esm/icons/search-icon'; -import TimesCircleIcon from '@patternfly/react-icons/dist/esm/icons/times-circle-icon'; -import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-icon'; - -class PrimaryDetailFullPage extends React.Component { - constructor(props) { - super(props); - this.state = { - isDrawerExpanded: false, - drawerPanelBodyContent: '', - isDropdownOpen: false, - isKebabDropdownOpen: false, - activeItem: 0, - inputValue: '', - statusIsExpanded: false, - statusSelected: null, - riskIsExpanded: false, - riskSelected: null, - selectedDataListItemId: '' - }; - - this.statusOptions = [ - { value: 'Status', disabled: false, isPlaceholder: true }, - { value: 'New', disabled: false }, - { value: 'Pending', disabled: false }, - { value: 'Running', disabled: false }, - { value: 'Cancelled', disabled: false } - ]; - - this.riskOptions = [ - { value: 'Risk', disabled: false, isPlaceholder: true }, - { value: 'Low', disabled: false }, - { value: 'Medium', disabled: false }, - { value: 'High', disabled: false } - ]; - - this.onInputChange = (_event, newValue) => { - this.setState({ inputValue: newValue }); - }; - - this.onStatusToggle = (_event, isExpanded) => { - this.setState({ - statusIsExpanded: isExpanded - }); - }; - - this.onStatusSelect = (event, selection, isPlaceholder) => { - if (isPlaceholder) this.clearStatusSelection(); - this.setState({ - statusSelected: selection, - statusIsExpanded: false - }); - }; - - this.clearStatusSelection = () => { - this.setState({ - statusSelected: null, - statusIsExpanded: false - }); - }; - - this.onRiskToggle = (_event, isExpanded) => { - this.setState({ - riskIsExpanded: isExpanded - }); - }; - - this.onRiskSelect = (event, selection, isPlaceholder) => { - if (isPlaceholder) this.clearRiskSelection(); - this.setState({ - riskSelected: selection, - riskIsExpanded: false - }); - }; - - this.clearRiskSelection = () => { - this.setState({ - riskSelected: null, - riskIsExpanded: false - }); - }; - - this.onSelectDataListItem = (_event, id) => { - this.setState({ - selectedDataListItemId: id, - isDrawerExpanded: true, - drawerPanelBodyContent: id.charAt(id.length - 1) - }); - }; - - this.onCloseDrawerClick = () => { - this.setState({ - isDrawerExpanded: false, - selectedDataListItemId: '' - }); - }; - } - - render() { - const { - isDrawerExpanded, - drawerPanelBodyContent, - isDropdownOpen, - isKebabDropdownOpen, - activeItem, - inputValue, - statusIsExpanded, - statusSelected, - riskIsExpanded, - riskSelected, - selectedDataListItemId - } = this.state; - - const toggleGroupItems = ( - - - - - - - - - - - - - - - {this.statusOptions.map((option, index) => ( - - ))} - - - - - {this.riskOptions.map((option, index) => ( - - ))} - - - - - ); - - const ToolbarItems = ( - } breakpoint="xl"> - {toggleGroupItems} - - ); - - const panelContent = ( - - - - node-{drawerPanelBodyContent} - - - - - - - - -

- The content of the drawer really is up to you. It could have form fields, definition lists, text lists, - labels, charts, progress bars, etc. Spacing recommendation is 24px margins. You can put tabs in here, - and can also make the drawer scrollable. -

-
- - - - - - -
-
-
- ); - const drawerContent = ( - - - {ToolbarItems} - - - - - - - -

patternfly

- - Working repo for PatternFly 4 https://pf4.patternfly.org/ - -
- - - 10 - - - 4 - - - 5 - - Updated 2 days ago - -
- , - - - - - - - - - - - ]} - /> -
-
- - - - - -

patternfly-elements

- PatternFly elements -
- - - 10 - - - 4 - - - 5 - - - 7 - - - 5 - - - 5 - - Updated 2 days ago - -
- , - - - - - - - - - - - ]} - /> -
-
- - - - - -

patternfly

- - Working repo for PatternFly 4 https://pf4.patternfly.org/ - -
- - - 10 - - - 4 - - - 5 - - Updated 2 days ago - -
- , - - - - - - - - - - - ]} - /> -
-
- - - - - -

patternfly-elements

- PatternFly elements -
- - - 10 - - - 4 - - - 5 - - - 7 - - - 5 - - - 5 - - Updated 2 days ago - -
- , - - - - - - - - - - - ]} - /> -
-
-
-
- ); - - return ( - - - - Main title - - Body text should be Overpass Regular at 16px. It should have leading of 24px because
- of it’s relative line height of 1.5. -
-
-
- - - - - {drawerContent} - - - -
- ); - } -} -``` - -### Primary-detail content padding - -```js isFullscreen -import React from 'react'; -import { - Button, - ButtonVariant, - DataList, - DataListAction, - DataListCell, - DataListItem, - DataListItemCells, - DataListItemRow, - Toolbar, - ToolbarItem, - ToolbarContent, - ToolbarToggleGroup, - ToolbarGroup, - Divider, - Drawer, - DrawerActions, - DrawerCloseButton, - DrawerContent, - DrawerContentBody, - DrawerHead, - DrawerPanelBody, - DrawerPanelContent, - Flex, - FlexItem, - InputGroup, - InputGroupItem, - PageSection, - PageSectionVariants, - Progress, - Stack, - StackItem, - Text, - TextContent, - TextInput, - Title -} from '@patternfly/react-core'; -import { - Select as SelectDeprecated, - SelectOption as SelectOptionDeprecated, - SelectVariant -} from '@patternfly/react-core/deprecated'; -import DashboardWrapper from '@patternfly/react-core/src/demos/examples/DashboardWrapper'; -import CodeBranchIcon from '@patternfly/react-icons/dist/esm/icons/code-branch-icon'; -import CodeIcon from '@patternfly/react-icons/dist/esm/icons/code-icon'; -import CubeIcon from '@patternfly/react-icons/dist/esm/icons/cube-icon'; -import CheckCircleIcon from '@patternfly/react-icons/dist/esm/icons/check-circle-icon'; -import ExclamationTriangleIcon from '@patternfly/react-icons/dist/esm/icons/exclamation-triangle-icon'; -import FilterIcon from '@patternfly/react-icons/dist/esm/icons/filter-icon'; -import SearchIcon from '@patternfly/react-icons/dist/esm/icons/search-icon'; -import TimesCircleIcon from '@patternfly/react-icons/dist/esm/icons/times-circle-icon'; - -class PrimaryDetailContentPadding extends React.Component { - constructor(props) { - super(props); - this.state = { - isDrawerExpanded: false, - drawerPanelBodyContent: '', - isDropdownOpen: false, - isKebabDropdownOpen: false, - activeItem: 0, - inputValue: '', - statusIsExpanded: false, - statusSelected: null, - riskIsExpanded: false, - riskSelected: null, - selectedDataListItemId: '' - }; - - this.statusOptions = [ - { value: 'Status', disabled: false, isPlaceholder: true }, - { value: 'New', disabled: false }, - { value: 'Pending', disabled: false }, - { value: 'Running', disabled: false }, - { value: 'Cancelled', disabled: false } - ]; - - this.riskOptions = [ - { value: 'Risk', disabled: false, isPlaceholder: true }, - { value: 'Low', disabled: false }, - { value: 'Medium', disabled: false }, - { value: 'High', disabled: false } - ]; - - this.onInputChange = (_event, newValue) => { - this.setState({ inputValue: newValue }); - }; - - this.onStatusToggle = (_event, isExpanded) => { - this.setState({ - statusIsExpanded: isExpanded - }); - }; - - this.onStatusSelect = (event, selection, isPlaceholder) => { - if (isPlaceholder) this.clearStatusSelection(); - this.setState({ - statusSelected: selection, - statusIsExpanded: false - }); - }; - - this.clearStatusSelection = () => { - this.setState({ - statusSelected: null, - statusIsExpanded: false - }); - }; - - this.onRiskToggle = (_event, isExpanded) => { - this.setState({ - riskIsExpanded: isExpanded - }); - }; - - this.onRiskSelect = (event, selection, isPlaceholder) => { - if (isPlaceholder) this.clearRiskSelection(); - this.setState({ - riskSelected: selection, - riskIsExpanded: false - }); - }; - - this.clearRiskSelection = () => { - this.setState({ - riskSelected: null, - riskIsExpanded: false - }); - }; - - this.onSelectDataListItem = (_event, id) => { - this.setState({ - selectedDataListItemId: id, - isDrawerExpanded: true, - drawerPanelBodyContent: id.charAt(id.length - 1) - }); - }; - - this.onCloseDrawerClick = () => { - this.setState({ - isDrawerExpanded: false, - selectedDataListItemId: '' - }); - }; - } - - render() { - const { - isDrawerExpanded, - drawerPanelBodyContent, - isDropdownOpen, - isKebabDropdownOpen, - activeItem, - inputValue, - statusIsExpanded, - statusSelected, - riskIsExpanded, - riskSelected, - selectedDataListItemId - } = this.state; - - const toggleGroupItems = ( - - - - - - - - - - - - - - - {this.statusOptions.map((option, index) => ( - - ))} - - - - - {this.riskOptions.map((option, index) => ( - - ))} - - - - - ); - - const ToolbarItems = ( - } breakpoint="xl"> - {toggleGroupItems} - - ); +```js file="./examples/PrimaryDetail/PrimaryDetailFullPage.tsx" isFullscreen - const panelContent = ( - - - - node-{drawerPanelBodyContent} - - - - - - - - -

- The content of the drawer really is up to you. It could have form fields, definition lists, text lists, - labels, charts, progress bars, etc. Spacing recommendation is 24px margins. You can put tabs in here, - and can also make the drawer scrollable. -

-
- - - - - - -
-
-
- ); +``` - const drawerContent = ( - - - {ToolbarItems} - - - - - - - -

patternfly

- - Working repo for PatternFly 4 https://pf4.patternfly.org/ - -
- - - 10 - - - 4 - - - 5 - - Updated 2 days ago - -
- , - - - - - - - - - - - ]} - /> -
-
- - - - - -

patternfly-elements

- PatternFly elements -
- - - 10 - - - 4 - - - 5 - - - 7 - - - 5 - - - 5 - - Updated 2 days ago - -
- , - - - - - - - - - - - ]} - /> -
-
- - - - - -

patternfly

- - Working repo for PatternFly 4 https://pf4.patternfly.org/ - -
- - - 10 - - - 4 - - - 5 - - Updated 2 days ago - -
- , - - - - - - - - - - - ]} - /> -
-
- - - - - -

patternfly-elements

- PatternFly elements -
- - - 10 - - - 4 - - - 5 - - - 7 - - - 5 - - - 5 - - Updated 2 days ago - -
- , - - - - - - - - - - - ]} - /> -
-
-
-
- ); +### Primary-detail content padding + +```js file="./examples/PrimaryDetail/PrimaryDetailContentPadding.tsx" isFullscreen - return ( - - - - Main title - - Body text should be Overpass Regular at 16px. It should have leading of 24px because
- of it’s relative line height of 1.5. -
-
-
- - - - - {drawerContent} - - - -
- ); - } -} ``` ### Primary-detail card view @@ -1975,467 +1050,6 @@ class PrimaryDetailDataListInCard extends React.Component { ### Primary-detail inline modifier -```js isFullscreen -import React from 'react'; -import { - Button, - ButtonVariant, - DataList, - DataListAction, - DataListCell, - DataListItem, - DataListItemCells, - DataListItemRow, - Toolbar, - ToolbarItem, - ToolbarContent, - ToolbarToggleGroup, - ToolbarGroup, - Divider, - Drawer, - DrawerActions, - DrawerCloseButton, - DrawerContent, - DrawerContentBody, - DrawerHead, - DrawerPanelBody, - DrawerPanelContent, - Flex, - FlexItem, - InputGroup, - InputGroupItem, - PageSection, - PageSectionVariants, - Progress, - Stack, - StackItem, - Text, - TextContent, - TextInput, - Title -} from '@patternfly/react-core'; -import { - Select as SelectDeprecated, - SelectOption as SelectOptionDeprecated, - SelectVariant -} from '@patternfly/react-core/deprecated'; -import DashboardWrapper from '@patternfly/react-core/src/demos/examples/DashboardWrapper'; -import CodeBranchIcon from '@patternfly/react-icons/dist/esm/icons/code-branch-icon'; -import CodeIcon from '@patternfly/react-icons/dist/esm/icons/code-icon'; -import CubeIcon from '@patternfly/react-icons/dist/esm/icons/cube-icon'; -import CheckCircleIcon from '@patternfly/react-icons/dist/esm/icons/check-circle-icon'; -import ExclamationTriangleIcon from '@patternfly/react-icons/dist/esm/icons/exclamation-triangle-icon'; -import FilterIcon from '@patternfly/react-icons/dist/esm/icons/filter-icon'; -import SearchIcon from '@patternfly/react-icons/dist/esm/icons/search-icon'; -import TimesCircleIcon from '@patternfly/react-icons/dist/esm/icons/times-circle-icon'; - -class PrimaryDetailInlineModifier extends React.Component { - constructor(props) { - super(props); - this.state = { - isDrawerExpanded: false, - drawerPanelBodyContent: '', - isDropdownOpen: false, - isKebabDropdownOpen: false, - activeItem: 0, - inputValue: '', - statusIsExpanded: false, - statusSelected: null, - riskIsExpanded: false, - riskSelected: null, - selectedDataListItemId: '' - }; - - this.statusOptions = [ - { value: 'Status', disabled: false, isPlaceholder: true }, - { value: 'New', disabled: false }, - { value: 'Pending', disabled: false }, - { value: 'Running', disabled: false }, - { value: 'Cancelled', disabled: false } - ]; - - this.riskOptions = [ - { value: 'Risk', disabled: false, isPlaceholder: true }, - { value: 'Low', disabled: false }, - { value: 'Medium', disabled: false }, - { value: 'High', disabled: false } - ]; - - this.onInputChange = (_event, newValue) => { - this.setState({ inputValue: newValue }); - }; - - this.onStatusToggle = (_event, isExpanded) => { - this.setState({ - statusIsExpanded: isExpanded - }); - }; - - this.onStatusSelect = (event, selection, isPlaceholder) => { - if (isPlaceholder) this.clearStatusSelection(); - this.setState({ - statusSelected: selection, - statusIsExpanded: false - }); - }; - - this.clearStatusSelection = () => { - this.setState({ - statusSelected: null, - statusIsExpanded: false - }); - }; - - this.onRiskToggle = (_event, isExpanded) => { - this.setState({ - riskIsExpanded: isExpanded - }); - }; - - this.onRiskSelect = (event, selection, isPlaceholder) => { - if (isPlaceholder) this.clearRiskSelection(); - this.setState({ - riskSelected: selection, - riskIsExpanded: false - }); - }; - - this.clearRiskSelection = () => { - this.setState({ - riskSelected: null, - riskIsExpanded: false - }); - }; - - this.onSelectDataListItem = (_event, id) => { - this.setState({ - selectedDataListItemId: id, - isDrawerExpanded: true, - drawerPanelBodyContent: id.charAt(id.length - 1) - }); - }; - - this.onCloseDrawerClick = () => { - this.setState({ - isDrawerExpanded: false, - selectedDataListItemId: '' - }); - }; - } - - render() { - const { - isDrawerExpanded, - drawerPanelBodyContent, - isDropdownOpen, - isKebabDropdownOpen, - activeItem, - inputValue, - statusIsExpanded, - statusSelected, - riskIsExpanded, - riskSelected, - selectedDataListItemId - } = this.state; - - const toggleGroupItems = ( - - - - - - - - - - - - - - - {this.statusOptions.map((option, index) => ( - - ))} - - - - - {this.riskOptions.map((option, index) => ( - - ))} - - - - - ); - - const ToolbarItems = ( - } breakpoint="xl"> - {toggleGroupItems} - - ); - - const panelContent = ( - - - - node-{drawerPanelBodyContent} - - - - - - - - -

- The content of the drawer really is up to you. It could have form fields, definition lists, text lists, - labels, charts, progress bars, etc. Spacing recommendation is 24px margins. You can put tabs in here, - and can also make the drawer scrollable. -

-
- - - - - - -
-
-
- ); - const drawerContent = ( - - - {ToolbarItems} - - - - - - - -

patternfly

- - Working repo for PatternFly 4 https://pf4.patternfly.org/ - -
- - - 10 - - - 4 - - - 5 - - Updated 2 days ago - -
- , - - - - - - - - - - - ]} - /> -
-
- - - - - -

patternfly-elements

- PatternFly elements -
- - - 10 - - - 4 - - - 5 - - - 7 - - - 5 - - - 5 - - Updated 2 days ago - -
- , - - - - - - - - - - - ]} - /> -
-
- - - - - -

patternfly

- - Working repo for PatternFly 4 https://pf4.patternfly.org/ - -
- - - 10 - - - 4 - - - 5 - - Updated 2 days ago - -
- , - - - - - - - - - - - ]} - /> -
-
- - - - - -

patternfly-elements

- PatternFly elements -
- - - 10 - - - 4 - - - 5 - - - 7 - - - 5 - - - 5 - - Updated 2 days ago - -
- , - - - - - - - - - - - ]} - /> -
-
-
-
- ); +```js file="./examples/PrimaryDetail/PrimaryDetailInlineModifier.tsx" isFullscreen - return ( - - - - Main title - - Body text should be Overpass Regular at 16px. It should have leading of 24px because
- of it’s relative line height of 1.5. -
-
-
- - - - - {drawerContent} - - - -
- ); - } -} ``` diff --git a/packages/react-core/src/demos/examples/PrimaryDetail/PrimaryDetailContentPadding.tsx b/packages/react-core/src/demos/examples/PrimaryDetail/PrimaryDetailContentPadding.tsx new file mode 100644 index 00000000000..4583a84b433 --- /dev/null +++ b/packages/react-core/src/demos/examples/PrimaryDetail/PrimaryDetailContentPadding.tsx @@ -0,0 +1,444 @@ +import React from 'react'; +import { + Button, + ButtonVariant, + DataList, + DataListAction, + DataListCell, + DataListItem, + DataListItemCells, + DataListItemRow, + Toolbar, + ToolbarItem, + ToolbarContent, + ToolbarToggleGroup, + ToolbarGroup, + Divider, + Drawer, + DrawerActions, + DrawerCloseButton, + DrawerContent, + DrawerContentBody, + DrawerHead, + DrawerPanelBody, + DrawerPanelContent, + Flex, + FlexItem, + InputGroup, + InputGroupItem, + PageSection, + PageSectionVariants, + Progress, + Stack, + StackItem, + Text, + TextContent, + TextInput, + Title, + Select, + SelectOption, + SelectOptionProps, + MenuToggle +} from '@patternfly/react-core'; +import DashboardWrapper from '@patternfly/react-core/src/demos/examples/DashboardWrapper'; +import CodeBranchIcon from '@patternfly/react-icons/dist/esm/icons/code-branch-icon'; +import CodeIcon from '@patternfly/react-icons/dist/esm/icons/code-icon'; +import CubeIcon from '@patternfly/react-icons/dist/esm/icons/cube-icon'; +import CheckCircleIcon from '@patternfly/react-icons/dist/esm/icons/check-circle-icon'; +import ExclamationTriangleIcon from '@patternfly/react-icons/dist/esm/icons/exclamation-triangle-icon'; +import FilterIcon from '@patternfly/react-icons/dist/esm/icons/filter-icon'; +import SearchIcon from '@patternfly/react-icons/dist/esm/icons/search-icon'; +import TimesCircleIcon from '@patternfly/react-icons/dist/esm/icons/times-circle-icon'; + +interface SelectOptionType extends Omit { + value: string; + label: string; +} + +const statusOptions: SelectOptionType[] = [ + { value: 'New', label: 'New' }, + { value: 'Pending', label: 'Pending' }, + { value: 'Running', label: 'Running' }, + { value: 'Cancelled', label: 'Cancelled' } +]; + +const riskOptions: SelectOptionType[] = [ + { value: 'Low', label: 'Low' }, + { value: 'Medium', label: 'Medium' }, + { value: 'High', label: 'High' } +]; + +export const PrimaryDetailContentPadding: React.FunctionComponent = () => { + const [isDrawerExpanded, setIsDrawerExpanded] = React.useState(false); + const [drawerPanelBodyContent, setDrawerPanelBodyContent] = React.useState(''); + const [inputValue, setInputValue] = React.useState(''); + const [statusIsOpen, setStatusIsOpen] = React.useState(false); + const [statusSelected, setStatusSelected] = React.useState('Status'); + const [riskIsOpen, setRiskIsOpen] = React.useState(false); + const [riskSelected, setRiskSelected] = React.useState('Risk'); + const [selectedDataListItemId, setSelectedDataListItemId] = React.useState(''); + + const onStatusSelect = (_event: React.MouseEvent | undefined, itemId: string | number | undefined) => { + setStatusSelected(itemId); + setStatusIsOpen(false); + }; + + const onRiskSelect = (_event: React.MouseEvent | undefined, itemId: string | number | undefined) => { + setRiskSelected(itemId); + setRiskIsOpen(false); + }; + + const onSelectDataListItem = ( + _event: React.MouseEvent | React.KeyboardEvent, + id: string + ) => { + setSelectedDataListItemId(id); + setIsDrawerExpanded(true); + setDrawerPanelBodyContent(id.charAt(id.length - 1)); + }; + + const onCloseDrawerClick = (_event: React.MouseEvent) => { + setIsDrawerExpanded(false); + setSelectedDataListItemId(''); + }; + + const toggleGroupItems = ( + + + + + , value: string) => setInputValue(value)} + value={inputValue} + /> + + + + + + + + + + + + + + + + ); + + const ToolbarItems = ( + } breakpoint="xl"> + {toggleGroupItems} + + ); + + const panelContent = ( + + + + node-{drawerPanelBodyContent} + + + + + + + + +

+ The content of the drawer really is up to you. It could have form fields, definition lists, text lists, + labels, charts, progress bars, etc. Spacing recommendation is 24px margins. You can put tabs in here, and + can also make the drawer scrollable. +

+
+ + + + + + +
+
+
+ ); + + const drawerContent = ( + + + {ToolbarItems} + + + + + + + +

patternfly

+ + Working repo for PatternFly 5 https://pf5.patternfly.org/ + +
+ + + 10 + + + 4 + + + 5 + + Updated 2 days ago + +
+ , + + + + + + + + + + + ]} + /> +
+
+ + + + + +

patternfly-elements

+ PatternFly elements +
+ + + 10 + + + 4 + + + 5 + + + 7 + + + 5 + + + 5 + + Updated 2 days ago + +
+ , + + + + + + + + + + + ]} + /> +
+
+ + + + + +

patternfly

+ + Working repo for PatternFly 5 https://pf5.patternfly.org/ + +
+ + + 10 + + + 4 + + + 5 + + Updated 2 days ago + +
+ , + + + + + + + + + + + ]} + /> +
+
+ + + + + +

patternfly-elements

+ PatternFly elements +
+ + + 10 + + + 4 + + + 5 + + + 7 + + + 5 + + + 5 + + Updated 2 days ago + +
+ , + + + + + + + + + + + ]} + /> +
+
+
+
+ ); + + return ( + + + + Main title + + Body text should be Overpass Regular at 16px. It should have leading of 24px because
+ of it's relative line height of 1.5. +
+
+
+ + + + + {drawerContent} + + + +
+ ); +}; diff --git a/packages/react-core/src/demos/examples/PrimaryDetail/PrimaryDetailFullPage.tsx b/packages/react-core/src/demos/examples/PrimaryDetail/PrimaryDetailFullPage.tsx new file mode 100644 index 00000000000..77705714bae --- /dev/null +++ b/packages/react-core/src/demos/examples/PrimaryDetail/PrimaryDetailFullPage.tsx @@ -0,0 +1,444 @@ +import React from 'react'; +import { + Button, + ButtonVariant, + DataList, + DataListAction, + DataListCell, + DataListItem, + DataListItemCells, + DataListItemRow, + Toolbar, + ToolbarItem, + ToolbarContent, + ToolbarToggleGroup, + ToolbarGroup, + Divider, + Drawer, + DrawerActions, + DrawerCloseButton, + DrawerContent, + DrawerContentBody, + DrawerHead, + DrawerPanelBody, + DrawerPanelContent, + Flex, + FlexItem, + InputGroup, + InputGroupItem, + PageSection, + PageSectionVariants, + Progress, + Stack, + StackItem, + Text, + TextContent, + TextInput, + Title, + Select, + SelectOption, + SelectOptionProps, + MenuToggle +} from '@patternfly/react-core'; +import DashboardWrapper from '@patternfly/react-core/src/demos/examples/DashboardWrapper'; +import CodeBranchIcon from '@patternfly/react-icons/dist/esm/icons/code-branch-icon'; +import CodeIcon from '@patternfly/react-icons/dist/esm/icons/code-icon'; +import CubeIcon from '@patternfly/react-icons/dist/esm/icons/cube-icon'; +import CheckCircleIcon from '@patternfly/react-icons/dist/esm/icons/check-circle-icon'; +import ExclamationTriangleIcon from '@patternfly/react-icons/dist/esm/icons/exclamation-triangle-icon'; +import FilterIcon from '@patternfly/react-icons/dist/esm/icons/filter-icon'; +import SearchIcon from '@patternfly/react-icons/dist/esm/icons/search-icon'; +import TimesCircleIcon from '@patternfly/react-icons/dist/esm/icons/times-circle-icon'; + +interface SelectOptionType extends Omit { + value: string; + label: string; +} + +const statusOptions: SelectOptionType[] = [ + { value: 'New', label: 'New' }, + { value: 'Pending', label: 'Pending' }, + { value: 'Running', label: 'Running' }, + { value: 'Cancelled', label: 'Cancelled' } +]; + +const riskOptions: SelectOptionType[] = [ + { value: 'Low', label: 'Low' }, + { value: 'Medium', label: 'Medium' }, + { value: 'High', label: 'High' } +]; + +export const PrimaryDetailFullPage: React.FunctionComponent = () => { + const [isDrawerExpanded, setIsDrawerExpanded] = React.useState(false); + const [drawerPanelBodyContent, setDrawerPanelBodyContent] = React.useState(''); + const [inputValue, setInputValue] = React.useState(''); + const [statusIsOpen, setStatusIsOpen] = React.useState(false); + const [statusSelected, setStatusSelected] = React.useState('Status'); + const [riskIsOpen, setRiskIsOpen] = React.useState(false); + const [riskSelected, setRiskSelected] = React.useState('Risk'); + const [selectedDataListItemId, setSelectedDataListItemId] = React.useState(''); + + const onStatusSelect = (_event: React.MouseEvent | undefined, itemId: string | number | undefined) => { + setStatusSelected(itemId); + setStatusIsOpen(false); + }; + + const onRiskSelect = (_event: React.MouseEvent | undefined, itemId: string | number | undefined) => { + setRiskSelected(itemId); + setRiskIsOpen(false); + }; + + const onSelectDataListItem = ( + _event: React.MouseEvent | React.KeyboardEvent, + id: string + ) => { + setSelectedDataListItemId(id); + setIsDrawerExpanded(true); + setDrawerPanelBodyContent(id.charAt(id.length - 1)); + }; + + const onCloseDrawerClick = (_event: React.MouseEvent) => { + setIsDrawerExpanded(false); + setSelectedDataListItemId(''); + }; + + const toggleGroupItems = ( + + + + + , value: string) => setInputValue(value)} + value={inputValue} + /> + + + + + + + + + + + + + + + + ); + + const ToolbarItems = ( + } breakpoint="xl"> + {toggleGroupItems} + + ); + + const panelContent = ( + + + + node-{drawerPanelBodyContent} + + + + + + + + +

+ The content of the drawer really is up to you. It could have form fields, definition lists, text lists, + labels, charts, progress bars, etc. Spacing recommendation is 24px margins. You can put tabs in here, and + can also make the drawer scrollable. +

+
+ + + + + + +
+
+
+ ); + + const drawerContent = ( + + + {ToolbarItems} + + + + + + + +

patternfly

+ + Working repo for PatternFly 5 https://pf5.patternfly.org/ + +
+ + + 10 + + + 4 + + + 5 + + Updated 2 days ago + +
+ , + + + + + + + + + + + ]} + /> +
+
+ + + + + +

patternfly-elements

+ PatternFly elements +
+ + + 10 + + + 4 + + + 5 + + + 7 + + + 5 + + + 5 + + Updated 2 days ago + +
+ , + + + + + + + + + + + ]} + /> +
+
+ + + + + +

patternfly

+ + Working repo for PatternFly 5 https://pf5.patternfly.org/ + +
+ + + 10 + + + 4 + + + 5 + + Updated 2 days ago + +
+ , + + + + + + + + + + + ]} + /> +
+
+ + + + + +

patternfly-elements

+ PatternFly elements +
+ + + 10 + + + 4 + + + 5 + + + 7 + + + 5 + + + 5 + + Updated 2 days ago + +
+ , + + + + + + + + + + + ]} + /> +
+
+
+
+ ); + + return ( + + + + Main title + + Body text should be Overpass Regular at 16px. It should have leading of 24px because
+ of it's relative line height of 1.5. +
+
+
+ + + + + {drawerContent} + + + +
+ ); +}; diff --git a/packages/react-core/src/demos/examples/PrimaryDetail/PrimaryDetailInlineModifier.tsx b/packages/react-core/src/demos/examples/PrimaryDetail/PrimaryDetailInlineModifier.tsx new file mode 100644 index 00000000000..2f024394899 --- /dev/null +++ b/packages/react-core/src/demos/examples/PrimaryDetail/PrimaryDetailInlineModifier.tsx @@ -0,0 +1,444 @@ +import React from 'react'; +import { + Button, + ButtonVariant, + DataList, + DataListAction, + DataListCell, + DataListItem, + DataListItemCells, + DataListItemRow, + Toolbar, + ToolbarItem, + ToolbarContent, + ToolbarToggleGroup, + ToolbarGroup, + Divider, + Drawer, + DrawerActions, + DrawerCloseButton, + DrawerContent, + DrawerContentBody, + DrawerHead, + DrawerPanelBody, + DrawerPanelContent, + Flex, + FlexItem, + InputGroup, + InputGroupItem, + PageSection, + PageSectionVariants, + Progress, + Stack, + StackItem, + Text, + TextContent, + TextInput, + Title, + Select, + SelectOption, + SelectOptionProps, + MenuToggle +} from '@patternfly/react-core'; +import DashboardWrapper from '@patternfly/react-core/src/demos/examples/DashboardWrapper'; +import CodeBranchIcon from '@patternfly/react-icons/dist/esm/icons/code-branch-icon'; +import CodeIcon from '@patternfly/react-icons/dist/esm/icons/code-icon'; +import CubeIcon from '@patternfly/react-icons/dist/esm/icons/cube-icon'; +import CheckCircleIcon from '@patternfly/react-icons/dist/esm/icons/check-circle-icon'; +import ExclamationTriangleIcon from '@patternfly/react-icons/dist/esm/icons/exclamation-triangle-icon'; +import FilterIcon from '@patternfly/react-icons/dist/esm/icons/filter-icon'; +import SearchIcon from '@patternfly/react-icons/dist/esm/icons/search-icon'; +import TimesCircleIcon from '@patternfly/react-icons/dist/esm/icons/times-circle-icon'; + +interface SelectOptionType extends Omit { + value: string; + label: string; +} + +const statusOptions: SelectOptionType[] = [ + { value: 'New', label: 'New' }, + { value: 'Pending', label: 'Pending' }, + { value: 'Running', label: 'Running' }, + { value: 'Cancelled', label: 'Cancelled' } +]; + +const riskOptions: SelectOptionType[] = [ + { value: 'Low', label: 'Low' }, + { value: 'Medium', label: 'Medium' }, + { value: 'High', label: 'High' } +]; + +export const PrimaryDetailInlineModifier: React.FunctionComponent = () => { + const [isDrawerExpanded, setIsDrawerExpanded] = React.useState(false); + const [drawerPanelBodyContent, setDrawerPanelBodyContent] = React.useState(''); + const [inputValue, setInputValue] = React.useState(''); + const [statusIsOpen, setStatusIsOpen] = React.useState(false); + const [statusSelected, setStatusSelected] = React.useState('Status'); + const [riskIsOpen, setRiskIsOpen] = React.useState(false); + const [riskSelected, setRiskSelected] = React.useState('Risk'); + const [selectedDataListItemId, setSelectedDataListItemId] = React.useState(''); + + const onStatusSelect = (_event: React.MouseEvent | undefined, itemId: string | number | undefined) => { + setStatusSelected(itemId); + setStatusIsOpen(false); + }; + + const onRiskSelect = (_event: React.MouseEvent | undefined, itemId: string | number | undefined) => { + setRiskSelected(itemId); + setRiskIsOpen(false); + }; + + const onSelectDataListItem = ( + _event: React.MouseEvent | React.KeyboardEvent, + id: string + ) => { + setSelectedDataListItemId(id); + setIsDrawerExpanded(true); + setDrawerPanelBodyContent(id.charAt(id.length - 1)); + }; + + const onCloseDrawerClick = (_event: React.MouseEvent) => { + setIsDrawerExpanded(false); + setSelectedDataListItemId(''); + }; + + const toggleGroupItems = ( + + + + + , value: string) => setInputValue(value)} + value={inputValue} + /> + + + + + + + + + + + + + + + + ); + + const ToolbarItems = ( + } breakpoint="xl"> + {toggleGroupItems} + + ); + + const panelContent = ( + + + + node-{drawerPanelBodyContent} + + + + + + + + +

+ The content of the drawer really is up to you. It could have form fields, definition lists, text lists, + labels, charts, progress bars, etc. Spacing recommendation is 24px margins. You can put tabs in here, and + can also make the drawer scrollable. +

+
+ + + + + + +
+
+
+ ); + + const drawerContent = ( + + + {ToolbarItems} + + + + + + + +

patternfly

+ + Working repo for PatternFly 5 https://pf5.patternfly.org/ + +
+ + + 10 + + + 4 + + + 5 + + Updated 2 days ago + +
+ , + + + + + + + + + + + ]} + /> +
+
+ + + + + +

patternfly-elements

+ PatternFly elements +
+ + + 10 + + + 4 + + + 5 + + + 7 + + + 5 + + + 5 + + Updated 2 days ago + +
+ , + + + + + + + + + + + ]} + /> +
+
+ + + + + +

patternfly

+ + Working repo for PatternFly 5 https://pf5.patternfly.org/ + +
+ + + 10 + + + 4 + + + 5 + + Updated 2 days ago + +
+ , + + + + + + + + + + + ]} + /> +
+
+ + + + + +

patternfly-elements

+ PatternFly elements +
+ + + 10 + + + 4 + + + 5 + + + 7 + + + 5 + + + 5 + + Updated 2 days ago + +
+ , + + + + + + + + + + + ]} + /> +
+
+
+
+ ); + + return ( + + + + Main title + + Body text should be Overpass Regular at 16px. It should have leading of 24px because
+ of it's relative line height of 1.5. +
+
+
+ + + + + {drawerContent} + + + +
+ ); +}; From 936aa99e9c195f93f53b20aec268f374808554b4 Mon Sep 17 00:00:00 2001 From: Jeff Puzzo Date: Thu, 25 May 2023 17:03:46 -0400 Subject: [PATCH 2/2] update demos with Select itemId -> value prop name change --- .../PrimaryDetail/PrimaryDetailContentPadding.tsx | 15 +++++++-------- .../PrimaryDetail/PrimaryDetailFullPage.tsx | 15 +++++++-------- .../PrimaryDetail/PrimaryDetailInlineModifier.tsx | 15 +++++++-------- 3 files changed, 21 insertions(+), 24 deletions(-) diff --git a/packages/react-core/src/demos/examples/PrimaryDetail/PrimaryDetailContentPadding.tsx b/packages/react-core/src/demos/examples/PrimaryDetail/PrimaryDetailContentPadding.tsx index 4583a84b433..2c958292df8 100644 --- a/packages/react-core/src/demos/examples/PrimaryDetail/PrimaryDetailContentPadding.tsx +++ b/packages/react-core/src/demos/examples/PrimaryDetail/PrimaryDetailContentPadding.tsx @@ -50,8 +50,7 @@ import FilterIcon from '@patternfly/react-icons/dist/esm/icons/filter-icon'; import SearchIcon from '@patternfly/react-icons/dist/esm/icons/search-icon'; import TimesCircleIcon from '@patternfly/react-icons/dist/esm/icons/times-circle-icon'; -interface SelectOptionType extends Omit { - value: string; +interface SelectOptionType extends Omit { label: string; } @@ -78,13 +77,13 @@ export const PrimaryDetailContentPadding: React.FunctionComponent = () => { const [riskSelected, setRiskSelected] = React.useState('Risk'); const [selectedDataListItemId, setSelectedDataListItemId] = React.useState(''); - const onStatusSelect = (_event: React.MouseEvent | undefined, itemId: string | number | undefined) => { - setStatusSelected(itemId); + const onStatusSelect = (_event: React.MouseEvent | undefined, value: string | number | undefined) => { + setStatusSelected(value); setStatusIsOpen(false); }; - const onRiskSelect = (_event: React.MouseEvent | undefined, itemId: string | number | undefined) => { - setRiskSelected(itemId); + const onRiskSelect = (_event: React.MouseEvent | undefined, value: string | number | undefined) => { + setRiskSelected(value); setRiskIsOpen(false); }; @@ -142,7 +141,7 @@ export const PrimaryDetailContentPadding: React.FunctionComponent = () => { onSelect={onStatusSelect} > {statusOptions.map(({ label, value }) => ( - + {label} ))} @@ -166,7 +165,7 @@ export const PrimaryDetailContentPadding: React.FunctionComponent = () => { onSelect={onRiskSelect} > {riskOptions.map(({ label, value }) => ( - + {label} ))} diff --git a/packages/react-core/src/demos/examples/PrimaryDetail/PrimaryDetailFullPage.tsx b/packages/react-core/src/demos/examples/PrimaryDetail/PrimaryDetailFullPage.tsx index 77705714bae..0a441fb8ea6 100644 --- a/packages/react-core/src/demos/examples/PrimaryDetail/PrimaryDetailFullPage.tsx +++ b/packages/react-core/src/demos/examples/PrimaryDetail/PrimaryDetailFullPage.tsx @@ -50,8 +50,7 @@ import FilterIcon from '@patternfly/react-icons/dist/esm/icons/filter-icon'; import SearchIcon from '@patternfly/react-icons/dist/esm/icons/search-icon'; import TimesCircleIcon from '@patternfly/react-icons/dist/esm/icons/times-circle-icon'; -interface SelectOptionType extends Omit { - value: string; +interface SelectOptionType extends Omit { label: string; } @@ -78,13 +77,13 @@ export const PrimaryDetailFullPage: React.FunctionComponent = () => { const [riskSelected, setRiskSelected] = React.useState('Risk'); const [selectedDataListItemId, setSelectedDataListItemId] = React.useState(''); - const onStatusSelect = (_event: React.MouseEvent | undefined, itemId: string | number | undefined) => { - setStatusSelected(itemId); + const onStatusSelect = (_event: React.MouseEvent | undefined, value: string | number | undefined) => { + setStatusSelected(value); setStatusIsOpen(false); }; - const onRiskSelect = (_event: React.MouseEvent | undefined, itemId: string | number | undefined) => { - setRiskSelected(itemId); + const onRiskSelect = (_event: React.MouseEvent | undefined, value: string | number | undefined) => { + setRiskSelected(value); setRiskIsOpen(false); }; @@ -142,7 +141,7 @@ export const PrimaryDetailFullPage: React.FunctionComponent = () => { onSelect={onStatusSelect} > {statusOptions.map(({ label, value }) => ( - + {label} ))} @@ -166,7 +165,7 @@ export const PrimaryDetailFullPage: React.FunctionComponent = () => { onSelect={onRiskSelect} > {riskOptions.map(({ label, value }) => ( - + {label} ))} diff --git a/packages/react-core/src/demos/examples/PrimaryDetail/PrimaryDetailInlineModifier.tsx b/packages/react-core/src/demos/examples/PrimaryDetail/PrimaryDetailInlineModifier.tsx index 2f024394899..485172283c0 100644 --- a/packages/react-core/src/demos/examples/PrimaryDetail/PrimaryDetailInlineModifier.tsx +++ b/packages/react-core/src/demos/examples/PrimaryDetail/PrimaryDetailInlineModifier.tsx @@ -50,8 +50,7 @@ import FilterIcon from '@patternfly/react-icons/dist/esm/icons/filter-icon'; import SearchIcon from '@patternfly/react-icons/dist/esm/icons/search-icon'; import TimesCircleIcon from '@patternfly/react-icons/dist/esm/icons/times-circle-icon'; -interface SelectOptionType extends Omit { - value: string; +interface SelectOptionType extends Omit { label: string; } @@ -78,13 +77,13 @@ export const PrimaryDetailInlineModifier: React.FunctionComponent = () => { const [riskSelected, setRiskSelected] = React.useState('Risk'); const [selectedDataListItemId, setSelectedDataListItemId] = React.useState(''); - const onStatusSelect = (_event: React.MouseEvent | undefined, itemId: string | number | undefined) => { - setStatusSelected(itemId); + const onStatusSelect = (_event: React.MouseEvent | undefined, value: string | number | undefined) => { + setStatusSelected(value); setStatusIsOpen(false); }; - const onRiskSelect = (_event: React.MouseEvent | undefined, itemId: string | number | undefined) => { - setRiskSelected(itemId); + const onRiskSelect = (_event: React.MouseEvent | undefined, value: string | number | undefined) => { + setRiskSelected(value); setRiskIsOpen(false); }; @@ -142,7 +141,7 @@ export const PrimaryDetailInlineModifier: React.FunctionComponent = () => { onSelect={onStatusSelect} > {statusOptions.map(({ label, value }) => ( - + {label} ))} @@ -166,7 +165,7 @@ export const PrimaryDetailInlineModifier: React.FunctionComponent = () => { onSelect={onRiskSelect} > {riskOptions.map(({ label, value }) => ( - + {label} ))}