diff --git a/packages/react-core/src/demos/Wizard/WizardDemo.md b/packages/react-core/src/demos/Wizard/WizardDemo.md index 86dac8aacf0..9aac19d69f7 100644 --- a/packages/react-core/src/demos/Wizard/WizardDemo.md +++ b/packages/react-core/src/demos/Wizard/WizardDemo.md @@ -11,785 +11,30 @@ import BarsIcon from '@patternfly/react-icons/dist/js/icons/bars-icon'; ### In modal -```js isFullscreen -import React from 'react'; -import { - Card, - CardBody, - Gallery, - GalleryItem, - PageSection, - Modal, - ModalVariant, - Wizard, - WizardHeader, - WizardStep -} from '@patternfly/react-core'; -import { DashboardWrapper } from '@patternfly/react-core/src/demos/DashboardWrapper'; - -class WizardInModalDemo extends React.Component { - constructor(props) { - super(props); - } - - render() { - return ( - - - - - {Array.apply(0, Array(10)).map((x, i) => ( - - - This is a card - - - ))} - - - - - - } - height={400} - > - -

Step 1 content

-
- -

Configuration substep A

-
, - -

Configuration substep B

-
- ]} - /> - -

Step 3 content

-
- -

Review step content

-
-
-
-
- ); - } -} +```js file="../examples/Wizard/InModal.tsx" isFullscreen ``` ### In modal, with drawer -```js isFullscreen -import React from 'react'; -import { - Button, - Drawer, - DrawerActions, - DrawerCloseButton, - DrawerContent, - DrawerPanelContent, - DrawerHead, - Modal, - ModalVariant, - Wizard, - WizardHeader, - WizardStep -} from '@patternfly/react-core'; - -class WizardModalWithDrawerDemo extends React.Component { - constructor(props) { - super(props); - this.state = { - isDrawerExpanded: false - }; - - this.drawerRef = React.createRef(); - - this.onExpand = () => { - this.drawerRef.current && this.drawerRef.current.focus(); - }; - - this.onOpenClick = () => { - this.setState({ - isDrawerExpanded: true - }); - }; - - this.onCloseClick = () => { - this.setState({ - isDrawerExpanded: false - }); - }; - } - render() { - const { isDrawerExpanded } = this.state; - - const createStepContentWithDrawer = (stepName) => ( - - - - - Drawer content: {stepName} - - - - - - - } - > - {!isDrawerExpanded && ( - - )} -
{stepName} content
-
-
- ); - - return ( - - - } - height={400} - > - - {createStepContentWithDrawer('Information step')} - - - {createStepContentWithDrawer('Configuration substep A')} - , - - {createStepContentWithDrawer('Configuration substep B')} - - ]} - /> - - {createStepContentWithDrawer('Additional step')} - - - {createStepContentWithDrawer('Review step')} - - - - ); - } -} +```js file="../examples/Wizard/InModalWithDrawer.tsx" isFullscreen ``` ### In modal, with drawer and informational step -```js isFullscreen -import React from 'react'; -import { - Button, - Drawer, - DrawerActions, - DrawerCloseButton, - DrawerContent, - DrawerPanelContent, - DrawerHead, - Modal, - ModalVariant, - Text, - TextContent, - Wizard, - WizardHeader, - WizardStep -} from '@patternfly/react-core'; - -class WizardModalWithDrawerInfoStepDemo extends React.Component { - constructor(props) { - super(props); - this.state = { - isDrawerExpanded: false - }; - - this.drawerRef = React.createRef(); - - this.onExpand = () => { - this.drawerRef.current && this.drawerRef.current.focus(); - }; - - this.onOpenClick = () => { - this.setState({ - isDrawerExpanded: true - }); - }; - - this.onCloseClick = () => { - this.setState({ - isDrawerExpanded: false - }); - }; - } - render() { - const { isDrawerExpanded } = this.state; - - const createStepContentWithDrawer = (stepName) => ( - - - - - Drawer content: {stepName} - - - - - - - } - > - - {stepName} content -

- Wizard description goes here. If you need more assistance,{' '} - {' '} - in the side drawer.{' '} -

-
-
-
- ); - - return ( - - - } - height={400} - > - - {createStepContentWithDrawer('Information step')} - - - {createStepContentWithDrawer('Configuration substep A')} - , - - {createStepContentWithDrawer('Configuration substep B')} - - ]} - /> - - {createStepContentWithDrawer('Additional step')} - - - {createStepContentWithDrawer('Review step')} - - - - ); - } -} +```js file="../examples/Wizard/InModalWithDrawerInformationalStep.tsx" isFullscreen ``` ### In page -```js isFullscreen -import React from 'react'; -import { PageSection, PageSectionTypes, PageSectionVariants, Wizard, WizardStep } from '@patternfly/react-core'; -import { DashboardWrapper } from '@patternfly/react-core/src/demos/DashboardWrapper'; - -class WizardFullPage extends React.Component { - constructor(props) { - super(props); - } - render() { - return ( - - - - - -

Step 1 content

-
- -

Configuration substep A

-
, - -

Configuration substep B

-
- ]} - /> - -

Step 3 content

-
- -

Review step content

-
-
-
-
-
- ); - } -} +```js file="../examples/Wizard/InPage.tsx" isFullscreen ``` ### In page, with drawer -```js isFullscreen -import React from 'react'; -import { - Brand, - Breadcrumb, - BreadcrumbItem, - Button, - Drawer, - DrawerActions, - DrawerCloseButton, - DrawerContent, - DrawerPanelContent, - DrawerHead, - Nav, - NavItem, - NavList, - Page, - PageSection, - PageSectionTypes, - PageSectionVariants, - PageSidebar, - PageSidebarBody, - SkipToContent, - Text, - TextContent, - Masthead, - PageToggleButton, - MastheadToggle, - MastheadMain, - MastheadBrand, - Wizard, - WizardStep -} from '@patternfly/react-core'; -import pfLogo from '@patternfly/react-core/src/demos/assets/pf-logo.svg'; -import BarsIcon from '@patternfly/react-icons/dist/js/icons/bars-icon'; - -class WizardFullPageWithDrawerDemo extends React.Component { - constructor(props) { - super(props); - this.state = { - isDrawerExpanded: false, - activeItem: 0 - }; - - this.drawerRef = React.createRef(); - - this.onExpand = () => { - this.drawerRef.current && this.drawerRef.current.focus(); - }; - - this.onOpenClick = () => { - this.setState({ - isDrawerExpanded: true - }); - }; - - this.onCloseClick = () => { - this.setState({ - isDrawerExpanded: false - }); - }; - this.onNavSelect = (_event, result) => { - this.setState({ - activeItem: result.itemId - }); - }; - } - render() { - const { activeItem, isDrawerExpanded } = this.state; - const PageNav = ( - - ); - const Header = ( - - - - - - - - - - - - - ); - const Sidebar = ( - - {PageNav} - - ); - const pageId = 'main-content-page-layout-default-nav'; - const PageSkipToContent = Skip to content; - const PageBreadcrumb = ( - - Section home - Section title - Section title - - Section landing - - - ); - - const createStepContentWithDrawer = (stepName) => ( - - - - - Drawer content: {stepName} - - - - - - - } - > - {!isDrawerExpanded && ( - - )} -
{stepName} content
-
-
- ); - - return ( - - - - - Main title - A demo of a wizard in a page. - - - - - - {createStepContentWithDrawer('Information step')} - - - {createStepContentWithDrawer('Configuration substep A')} - , - - {createStepContentWithDrawer('Configuration substep B')} - - ]} - /> - - {createStepContentWithDrawer('Additional step')} - - - {createStepContentWithDrawer('Review step')} - - - - - - ); - } -} +```js file="../examples/Wizard/InPageWithDrawer.tsx" isFullscreen ``` ### In page, with drawer and informational step -```js isFullscreen -import React from 'react'; -import { - Brand, - Breadcrumb, - BreadcrumbItem, - Button, - Drawer, - DrawerActions, - DrawerCloseButton, - DrawerContent, - DrawerHead, - DrawerPanelContent, - Nav, - NavItem, - NavList, - Page, - PageSection, - PageSectionTypes, - PageSectionVariants, - PageSidebar, - PageSidebarBody, - SkipToContent, - Text, - TextContent, - Masthead, - PageToggleButton, - MastheadToggle, - MastheadMain, - MastheadBrand, - Wizard, - WizardStep -} from '@patternfly/react-core'; -import pfLogo from '@patternfly/react-core/src/demos/assets/pf-logo.svg'; -import BarsIcon from '@patternfly/react-icons/dist/js/icons/bars-icon'; - -class WizardFullPageWithDrawerInfoStepDemo extends React.Component { - constructor(props) { - super(props); - this.state = { - isDrawerExpanded: false, - activeItem: 0 - }; - - this.drawerRef = React.createRef(); - - this.onExpand = () => { - this.drawerRef.current && this.drawerRef.current.focus(); - }; - - this.onOpenClick = () => { - this.setState({ - isDrawerExpanded: true - }); - }; - - this.onCloseClick = () => { - this.setState({ - isDrawerExpanded: false - }); - }; - this.onNavSelect = (_event, result) => { - this.setState({ - activeItem: result.itemId - }); - }; - } - render() { - const { activeItem, isDrawerExpanded } = this.state; - const PageNav = ( - - ); - const Header = ( - - - - - - - - - - - - - ); - const Sidebar = ( - - {PageNav} - - ); - const pageId = 'main-content-page-layout-default-nav'; - const PageSkipToContent = Skip to content; - const PageBreadcrumb = ( - - Section home - Section title - Section title - - Section landing - - - ); - - const createStepContentWithDrawer = (stepName) => ( - - - - - Drawer content: {stepName} - - - - - - - } - > - - {stepName} content -

- Wizard description goes here. If you need more assistance,{' '} - {' '} - in the side drawer.{' '} -

-
-
-
- ); - - return ( - - - - - Main title - A demo of a wizard in a page. - - - - - - {createStepContentWithDrawer('Information step')} - - - {createStepContentWithDrawer('Configuration substep A')} - , - - {createStepContentWithDrawer('Configuration substep B')} - - ]} - /> - - {createStepContentWithDrawer('Additional step')} - - - {createStepContentWithDrawer('Review step')} - - - - - - ); - } -} +```js file="../examples/Wizard/InPageWithDrawerInformationalStep.tsx" isFullscreen ``` diff --git a/packages/react-core/src/demos/examples/Wizard/InModal.tsx b/packages/react-core/src/demos/examples/Wizard/InModal.tsx new file mode 100644 index 00000000000..0a6a9b424f5 --- /dev/null +++ b/packages/react-core/src/demos/examples/Wizard/InModal.tsx @@ -0,0 +1,75 @@ +import React from 'react'; +import { + Card, + CardBody, + Gallery, + GalleryItem, + PageSection, + Modal, + ModalVariant, + Wizard, + WizardHeader, + WizardStep +} from '@patternfly/react-core'; +import { DashboardWrapper } from '@patternfly/react-core/src/demos/DashboardWrapper'; + +export const WizardInModalDemo: React.FunctionComponent = () => ( + <> + + + + {Array.from({ length: 10 }).map((_, i) => ( + + + This is a card + + + ))} + + + + + + } + height={400} + > + +

Step 1 content

+
+ +

Configuration substep A

+
, + +

Configuration substep B

+
+ ]} + /> + +

Step 3 content

+
+ +

Review step content

+
+
+
+ +); diff --git a/packages/react-core/src/demos/examples/Wizard/InModalWithDrawer.tsx b/packages/react-core/src/demos/examples/Wizard/InModalWithDrawer.tsx new file mode 100644 index 00000000000..4b98dbb6ca5 --- /dev/null +++ b/packages/react-core/src/demos/examples/Wizard/InModalWithDrawer.tsx @@ -0,0 +1,115 @@ +import React from 'react'; +import { + Button, + Drawer, + DrawerContent, + DrawerPanelContent, + DrawerHead, + DrawerActions, + DrawerCloseButton, + Flex, + Modal, + ModalVariant, + Wizard, + WizardHeader, + WizardStep, + DrawerColorVariant +} from '@patternfly/react-core'; + +export const WizardModalWithDrawerDemo: React.FunctionComponent = () => { + const [isDrawerExpanded, setIsDrawerExpanded] = React.useState(false); + const drawerRef = React.useRef(null); + + const onExpand = () => { + if (drawerRef.current) { + drawerRef.current.focus(); + } + }; + + const onOpenClick = () => { + setIsDrawerExpanded(true); + }; + + const onCloseClick = () => { + setIsDrawerExpanded(false); + }; + + const createStepContentWithDrawer = (stepName: string) => ( + + + + + Drawer content: {stepName} + + + + + + + } + > + + {!isDrawerExpanded && ( + + )} +
{stepName} content
+
+
+
+ ); + + return ( + + + } + height={400} + > + + {createStepContentWithDrawer('Information step')} + + + {createStepContentWithDrawer('Configuration substep A')} + , + + {createStepContentWithDrawer('Configuration substep B')} + + ]} + /> + + {createStepContentWithDrawer('Additional step')} + + + {createStepContentWithDrawer('Review step')} + + + + ); +}; diff --git a/packages/react-core/src/demos/examples/Wizard/InModalWithDrawerInformationalStep.tsx b/packages/react-core/src/demos/examples/Wizard/InModalWithDrawerInformationalStep.tsx new file mode 100644 index 00000000000..ce0f2e3f2f7 --- /dev/null +++ b/packages/react-core/src/demos/examples/Wizard/InModalWithDrawerInformationalStep.tsx @@ -0,0 +1,122 @@ +import React from 'react'; +import { + Button, + Drawer, + DrawerActions, + DrawerCloseButton, + DrawerContent, + DrawerPanelContent, + DrawerHead, + Flex, + Modal, + ModalVariant, + Text, + TextContent, + TextVariants, + Wizard, + WizardHeader, + WizardStep, + DrawerColorVariant +} from '@patternfly/react-core'; + +export const WizardModalWithDrawerInfoStepDemo: React.FunctionComponent = () => { + const [isDrawerExpanded, setIsDrawerExpanded] = React.useState(false); + const drawerRef = React.useRef(null); + + const onExpand = () => { + if (drawerRef.current) { + drawerRef.current.focus(); + } + }; + + const onOpenClick = () => { + setIsDrawerExpanded(true); + }; + + const onCloseClick = () => { + setIsDrawerExpanded(false); + }; + + const createStepContentWithDrawer = (stepName: string) => ( + + + + + Drawer content: {stepName} + + + + + + + } + > + + + {stepName} content +

+ Wizard description goes here. If you need more assistance,{' '} + {' '} + in the side drawer.{' '} +

+
+
+
+
+ ); + + return ( + + + } + height={400} + > + + {createStepContentWithDrawer('Information step')} + + + {createStepContentWithDrawer('Configuration substep A')} + , + + {createStepContentWithDrawer('Configuration substep B')} + + ]} + /> + + {createStepContentWithDrawer('Additional step')} + + + {createStepContentWithDrawer('Review step')} + + + + ); +}; diff --git a/packages/react-core/src/demos/examples/Wizard/InPage.tsx b/packages/react-core/src/demos/examples/Wizard/InPage.tsx new file mode 100644 index 00000000000..d410b70f568 --- /dev/null +++ b/packages/react-core/src/demos/examples/Wizard/InPage.tsx @@ -0,0 +1,35 @@ +import React from 'react'; +import { PageSection, PageSectionTypes, PageSectionVariants, Wizard, WizardStep } from '@patternfly/react-core'; +import { DashboardWrapper } from '@patternfly/react-core/src/demos/DashboardWrapper'; + +export const WizardFullPage: React.FunctionComponent = () => ( + + + + + +

Step 1 content

+
+ +

Configuration substep A

+
, + +

Configuration substep B

+
+ ]} + /> + +

Step 3 content

+
+ +

Review step content

+
+
+
+
+
+); diff --git a/packages/react-core/src/demos/examples/Wizard/InPageWithDrawer.tsx b/packages/react-core/src/demos/examples/Wizard/InPageWithDrawer.tsx new file mode 100644 index 00000000000..6fe3d7e1cd5 --- /dev/null +++ b/packages/react-core/src/demos/examples/Wizard/InPageWithDrawer.tsx @@ -0,0 +1,196 @@ +import React from 'react'; +import { + Brand, + Breadcrumb, + BreadcrumbItem, + Button, + Drawer, + DrawerActions, + DrawerCloseButton, + DrawerContent, + DrawerPanelContent, + DrawerHead, + Flex, + Nav, + NavItem, + NavList, + Page, + PageSection, + PageSectionTypes, + PageSectionVariants, + PageSidebar, + PageSidebarBody, + SkipToContent, + Text, + TextContent, + Masthead, + PageToggleButton, + MastheadToggle, + MastheadMain, + MastheadBrand, + Wizard, + WizardStep, + DrawerColorVariant +} from '@patternfly/react-core'; +import pfLogo from '@patternfly/react-core/src/demos/assets/pf-logo.svg'; +import BarsIcon from '@patternfly/react-icons/dist/js/icons/bars-icon'; + +export const WizardFullPageWithDrawerDemo: React.FunctionComponent = () => { + const [isDrawerExpanded, setIsDrawerExpanded] = React.useState(false); + const [activeItem, setActiveItem] = React.useState(0); + + const drawerRef = React.useRef(null); + + const onExpand = () => { + if (drawerRef.current) { + drawerRef.current.focus(); + } + }; + + const onOpenClick = () => { + setIsDrawerExpanded(true); + }; + + const onCloseClick = () => { + setIsDrawerExpanded(false); + }; + + const onNavSelect = (_event: React.FormEvent, result: { itemId: number | string }) => { + setActiveItem(result.itemId as number); + }; + + const PageNav = ( + + ); + + const Header = ( + + + + + + + + + + + + + ); + + const Sidebar = ( + + {PageNav} + + ); + + const pageId = 'main-content-page-layout-default-nav'; + const PageSkipToContent = Skip to content; + + const PageBreadcrumb = ( + + Section home + Section title + Section title + + Section landing + + + ); + + const createStepContentWithDrawer = (stepName: string) => ( + + + + + Drawer content: {stepName} + + + + + + + } + > + + {!isDrawerExpanded && ( + + )} +
{stepName} content
+
+
+
+ ); + + return ( + + + + + Main title + A demo of a wizard in a page. + + + + + + {createStepContentWithDrawer('Information step')} + + + {createStepContentWithDrawer('Configuration substep A')} + , + + {createStepContentWithDrawer('Configuration substep B')} + + ]} + /> + + {createStepContentWithDrawer('Additional step')} + + + {createStepContentWithDrawer('Review step')} + + + + + + ); +}; diff --git a/packages/react-core/src/demos/examples/Wizard/InPageWithDrawerInformationalStep.tsx b/packages/react-core/src/demos/examples/Wizard/InPageWithDrawerInformationalStep.tsx new file mode 100644 index 00000000000..1a641a40ebd --- /dev/null +++ b/packages/react-core/src/demos/examples/Wizard/InPageWithDrawerInformationalStep.tsx @@ -0,0 +1,201 @@ +import React from 'react'; +import { + Brand, + Breadcrumb, + BreadcrumbItem, + Button, + Drawer, + DrawerActions, + DrawerCloseButton, + DrawerColorVariant, + DrawerContent, + DrawerHead, + DrawerPanelContent, + Flex, + Nav, + NavItem, + NavList, + Page, + PageSection, + PageSectionTypes, + PageSectionVariants, + PageSidebar, + PageSidebarBody, + SkipToContent, + Text, + TextContent, + Masthead, + PageToggleButton, + MastheadToggle, + MastheadMain, + MastheadBrand, + Wizard, + WizardStep +} from '@patternfly/react-core'; +import pfLogo from '@patternfly/react-core/src/demos/assets/pf-logo.svg'; +import BarsIcon from '@patternfly/react-icons/dist/js/icons/bars-icon'; + +export const WizardFullPageWithDrawerInfoStepDemo: React.FunctionComponent = () => { + const [isDrawerExpanded, setIsDrawerExpanded] = React.useState(false); + const [activeItem, setActiveItem] = React.useState(0); + + const drawerRef = React.useRef(null); + + const onExpand = () => { + if (drawerRef.current) { + drawerRef.current.focus(); + } + }; + + const onOpenClick = () => { + setIsDrawerExpanded(true); + }; + + const onCloseClick = () => { + setIsDrawerExpanded(false); + }; + + const onNavSelect = (_event: any, result: any) => { + setActiveItem(result.itemId); + }; + + const PageNav = ( + + ); + + const Header = ( + + + + + + + + + + + + + ); + + const Sidebar = ( + + {PageNav} + + ); + + const pageId = 'main-content-page-layout-default-nav'; + + const PageSkipToContent = Skip to content; + + const PageBreadcrumb = ( + + Section home + Section title + Section title + + Section landing + + + ); + + const createStepContentWithDrawer = (stepName: string) => ( + + + + + Drawer content: {stepName} + + + + + + + } + > + + + {stepName} content +

+ Wizard description goes here. If you need more assistance,{' '} + {' '} + in the side drawer.{' '} +

+
+
+
+
+ ); + + return ( + + + + + Main title + A demo of a wizard in a page. + + + + + + {createStepContentWithDrawer('Information step')} + + + {createStepContentWithDrawer('Configuration substep A')} + , + + {createStepContentWithDrawer('Configuration substep B')} + + ]} + /> + + {createStepContentWithDrawer('Additional step')} + + + {createStepContentWithDrawer('Review step')} + + + + + + ); +};