From 3a452dc3f62f24aa6386dc23f15b0fb5637c140a Mon Sep 17 00:00:00 2001 From: Eric Olkowski Date: Fri, 17 Jun 2022 16:11:58 -0400 Subject: [PATCH 1/3] chore(Navigation): convert examples to TypeScript --- .../src/components/Nav/examples/Nav.md | 105 +++--------------- .../components/Nav/examples/NavDefault.tsx | 29 +++++ .../components/Nav/examples/NavDrilldown.tsx | 35 +++--- .../components/Nav/examples/NavGrouped.tsx | 67 +++++++++++ 4 files changed, 132 insertions(+), 104 deletions(-) create mode 100644 packages/react-core/src/components/Nav/examples/NavDefault.tsx create mode 100644 packages/react-core/src/components/Nav/examples/NavGrouped.tsx diff --git a/packages/react-core/src/components/Nav/examples/Nav.md b/packages/react-core/src/components/Nav/examples/Nav.md index c00ac933d5c..c9df9d06279 100644 --- a/packages/react-core/src/components/Nav/examples/Nav.md +++ b/packages/react-core/src/components/Nav/examples/Nav.md @@ -12,98 +12,14 @@ import './nav.css'; ### Default -```js -import React from 'react'; -import { Nav, NavExpandable, NavItem, NavItemSeparator, NavList, NavGroup } from '@patternfly/react-core'; - -class NavDefaultList extends React.Component { - constructor(props) { - super(props); - this.state = { - activeItem: 0 - }; - this.onSelect = result => { - this.setState({ - activeItem: result.itemId - }); - }; - } - - render() { - const { activeItem } = this.state; - return ( - - ); - } -} +```ts file="./NavDefault.tsx" ``` ### Grouped -Note: to keep nav groups accessible an `aria-label` should be supplied if the `title` prop is not passed. - -```js -import React from 'react'; -import { Nav, NavExpandable, NavItem, NavItemSeparator, NavList, NavGroup } from '@patternfly/react-core'; - -class NavGroupedList extends React.Component { - constructor(props) { - super(props); - this.state = { - activeItem: 'grp-1_itm-1' - }; - this.onSelect = result => { - this.setState({ - activeItem: result.itemId - }); - }; - } +The following example shows two navigation groups, each with a `title` prop passed into the nav group component. To keep nav groups accessible an `aria-label` must be passed in if the `title` prop is not passed in. - render() { - const { activeItem } = this.state; - return ( - - ); - } -} +```ts file="./NavGrouped.tsx" ``` ### Expandable @@ -229,7 +145,13 @@ class NavExpandableTitlesList extends React.Component { return (