-
Notifications
You must be signed in to change notification settings - Fork 377
replace Toolbar with PageHeaderTools in page header #4223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
79f91ff
16598dc
f1d4a9b
2f73316
c3588b2
b567a41
bf70341
7c3f2e2
9d4e93d
6553c26
892a90d
aaba4f2
7c565a1
7984c11
a81b5d9
5b28664
728f631
de00b92
ee09981
2821962
90a90d1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import * as React from 'react'; | ||
| import styles from '@patternfly/react-styles/css/components/Page/page'; | ||
| import { css } from '@patternfly/react-styles'; | ||
|
|
||
| export interface PageHeaderToolsBreakpointMod { | ||
| /** The attribute to modify */ | ||
| modifier: 'hidden' | 'visible'; | ||
| /** The breakpoint at which to apply the modifier */ | ||
| breakpoint?: 'sm' | 'md' | 'lg' | 'xl' | '2xl'; | ||
| } | ||
|
|
||
| export interface PageHeaderToolsProps extends React.HTMLProps<HTMLDivElement> { | ||
| /** Content rendered in page header tools */ | ||
| children: React.ReactNode; | ||
| /** Additional classes added to the page header tools. */ | ||
| className?: string; | ||
| } | ||
|
|
||
| export const PageHeaderTools: React.FunctionComponent<PageHeaderToolsProps> = ({ | ||
| children, | ||
| className, | ||
| ...props | ||
| }: PageHeaderToolsProps) => ( | ||
| <div className={css(styles.pageHeaderTools, className)} {...props}> | ||
| {children} | ||
| </div> | ||
| ); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| import * as React from 'react'; | ||
| import styles from '@patternfly/react-styles/css/components/Page/page'; | ||
| import { css } from '@patternfly/react-styles'; | ||
| import { PageHeaderToolsBreakpointMod } from './PageHeaderTools'; | ||
| import { formatBreakpointMods } from '../../helpers/util'; | ||
|
|
||
| export interface PageHeaderToolsGroupProps extends React.HTMLProps<HTMLDivElement> { | ||
| /** Content rendered in the page header tools group */ | ||
| children: React.ReactNode; | ||
| /** Additional classes added to the page header tools group. */ | ||
| className?: string; | ||
| /** An array of breakpoint modifiers to control visibility, e.g. breakpointMods={[{ modifier: 'hidden' }, { modifier: 'visible', breakpoint: 'md' }]} */ | ||
| breakpointMods?: PageHeaderToolsBreakpointMod[]; | ||
| } | ||
|
|
||
| export const PageHeaderToolsGroup: React.FunctionComponent<PageHeaderToolsGroupProps> = ({ | ||
| children, | ||
| className, | ||
| breakpointMods, | ||
| ...props | ||
| }: PageHeaderToolsGroupProps) => ( | ||
| <div | ||
| className={css( | ||
| styles.pageHeaderToolsGroup, | ||
| breakpointMods && formatBreakpointMods(breakpointMods, styles), | ||
| className | ||
| )} | ||
| {...props} | ||
| > | ||
| {children} | ||
| </div> | ||
| ); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| import * as React from 'react'; | ||
| import styles from '@patternfly/react-styles/css/components/Page/page'; | ||
| import { css } from '@patternfly/react-styles'; | ||
| import { PageHeaderToolsBreakpointMod } from './PageHeaderTools'; | ||
| import { formatBreakpointMods } from '../../helpers/util'; | ||
|
|
||
| export interface PageHeaderToolsItemProps extends React.HTMLProps<HTMLDivElement> { | ||
| /** Content rendered in page header tools item. */ | ||
| children: React.ReactNode; | ||
| /** Additional classes added to the page header tools item. */ | ||
| className?: string; | ||
| /** An array of breakpoint modifiers to control visibility, e.g. breakpointMods={[{ modifier: 'hidden' }, { modifier: 'visible', breakpoint: 'md' }]} */ | ||
| breakpointMods?: PageHeaderToolsBreakpointMod[]; | ||
| /** True to make an icon button appear selected */ | ||
| isSelected?: boolean; | ||
| } | ||
|
|
||
| export const PageHeaderToolsItem: React.FunctionComponent<PageHeaderToolsItemProps> = ({ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm curious how this component works. I think it would be more consistent if we had a
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So the problem is, in HTML you can just add the because the selected modifier is not a prop we have available for Buttons, the class is defined in the context of page. Wrapping the |
||
| children, | ||
| className, | ||
| breakpointMods, | ||
| isSelected | ||
| }: PageHeaderToolsItemProps) => ( | ||
| <div | ||
| className={css( | ||
| styles.pageHeaderToolsItem, | ||
| isSelected && styles.modifiers.selected, | ||
| breakpointMods && formatBreakpointMods(breakpointMods, styles), | ||
| className | ||
| )} | ||
| > | ||
| {children} | ||
| </div> | ||
| ); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| /** | ||
| * This test was generated | ||
| */ | ||
| import * as React from 'react'; | ||
| import { shallow } from 'enzyme'; | ||
| import { PageHeaderTools } from '../../PageHeaderTools'; | ||
| // any missing imports can usually be resolved by adding them here | ||
| import {} from '../..'; | ||
|
|
||
| it('PageHeaderTools should match snapshot (auto-generated)', () => { | ||
| const view = shallow(<PageHeaderTools children={<div>ReactNode</div>} className={'string'} />); | ||
| expect(view).toMatchSnapshot(); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| /** | ||
| * This test was generated | ||
| */ | ||
| import * as React from 'react'; | ||
| import { shallow } from 'enzyme'; | ||
| import { PageHeaderToolsGroup } from '../../PageHeaderToolsGroup'; | ||
| // any missing imports can usually be resolved by adding them here | ||
| import {} from '../..'; | ||
|
|
||
| it('PageHeaderToolsGroup should match snapshot (auto-generated)', () => { | ||
| const view = shallow( | ||
| <PageHeaderToolsGroup children={<div>ReactNode</div>} className={'string'} breakpointMods={[]} /> | ||
| ); | ||
| expect(view).toMatchSnapshot(); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| /** | ||
| * This test was generated | ||
| */ | ||
| import * as React from 'react'; | ||
| import { shallow } from 'enzyme'; | ||
| import { PageHeaderToolsItem } from '../../PageHeaderToolsItem'; | ||
| // any missing imports can usually be resolved by adding them here | ||
| import {} from '../..'; | ||
|
|
||
| it('PageHeaderToolsItem should match snapshot (auto-generated)', () => { | ||
| const view = shallow( | ||
| <PageHeaderToolsItem children={<div>ReactNode</div>} className={'string'} breakpointMods={[]} isSelected={true} /> | ||
| ); | ||
| expect(view).toMatchSnapshot(); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| // Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
|
||
| exports[`PageHeaderTools should match snapshot (auto-generated) 1`] = ` | ||
| <div | ||
| className="pf-c-page__header-tools string" | ||
| > | ||
| <div> | ||
| ReactNode | ||
| </div> | ||
| </div> | ||
| `; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| // Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
|
||
| exports[`PageHeaderToolsGroup should match snapshot (auto-generated) 1`] = ` | ||
| <div | ||
| className="pf-c-page__header-tools-group string" | ||
| > | ||
| <div> | ||
| ReactNode | ||
| </div> | ||
| </div> | ||
| `; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| // Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
|
||
| exports[`PageHeaderToolsItem should match snapshot (auto-generated) 1`] = ` | ||
| <div | ||
| className="pf-c-page__header-tools-item pf-m-selected string" | ||
| > | ||
| <div> | ||
| ReactNode | ||
| </div> | ||
| </div> | ||
| `; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I opened an issue agains the page header.
formatBreakpointModsfunction does not work for the 2xl breakpoint.