-
Notifications
You must be signed in to change notification settings - Fork 376
feat(Compass): updated mainheader structure to be composable #12135
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
f59c79d
feat(Compass): updated mainheader structure to be composable
thatblindgeye c096aa5
Use new components instead of divs
thatblindgeye aad0234
Missed package version in rebase
thatblindgeye 33a23ee
Added tests for compassPanelProps
thatblindgeye File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 20 additions & 9 deletions
29
packages/react-core/src/components/Compass/CompassMainHeader.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
packages/react-core/src/components/Compass/CompassMainHeaderContent.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import styles from '@patternfly/react-styles/css/components/Compass/compass'; | ||
| import { css } from '@patternfly/react-styles'; | ||
|
|
||
| /** A wrapper component to be passed as custom content for the compass main header. This should also be wrapped | ||
| * in a compass panel component. | ||
| */ | ||
|
|
||
| export interface CompassMainHeaderContentProps extends React.HTMLProps<HTMLDivElement> { | ||
| /** Content of the main header content. */ | ||
| children: React.ReactNode; | ||
| /** Additional classes added to the main header content. */ | ||
| className?: string; | ||
| } | ||
|
|
||
| export const CompassMainHeaderContent: React.FunctionComponent<CompassMainHeaderContentProps> = ({ | ||
| children, | ||
| className, | ||
| ...props | ||
| }) => ( | ||
| <div className={css(styles.compassMainHeaderContent, className)} {...props}> | ||
| {children} | ||
| </div> | ||
| ); | ||
|
|
||
| CompassMainHeaderContent.displayName = 'CompassMainHeaderContent'; |
25 changes: 25 additions & 0 deletions
25
packages/react-core/src/components/Compass/CompassMainHeaderTitle.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import styles from '@patternfly/react-styles/css/components/Compass/compass'; | ||
| import { css } from '@patternfly/react-styles'; | ||
|
|
||
| /** A wrapper component for custom title content to be passed into a compass main header. This should also be wrapped | ||
| * by a compass main header content component. | ||
| */ | ||
|
|
||
| export interface CompassMainHeaderTitleProps extends React.HTMLProps<HTMLDivElement> { | ||
| /** Content of the main header title. */ | ||
| children: React.ReactNode; | ||
| /** Additional classes added to the main header title. */ | ||
| className?: string; | ||
| } | ||
|
|
||
| export const CompassMainHeaderTitle: React.FunctionComponent<CompassMainHeaderTitleProps> = ({ | ||
| children, | ||
| className, | ||
| ...props | ||
| }) => ( | ||
| <div className={css(`${styles.compass}__main-header-title`, className)} {...props}> | ||
| {children} | ||
| </div> | ||
| ); | ||
|
|
||
| CompassMainHeaderTitle.displayName = 'CompassMainHeaderTitle'; |
25 changes: 25 additions & 0 deletions
25
packages/react-core/src/components/Compass/CompassMainHeaderToolbar.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import styles from '@patternfly/react-styles/css/components/Compass/compass'; | ||
| import { css } from '@patternfly/react-styles'; | ||
|
|
||
| /** A wrapper component for custom toolbar content to be passed into a compass main header. This should also be wrapped | ||
| * by a compass main header content component. | ||
| */ | ||
|
|
||
| export interface CompassMainHeaderToolbarProps extends React.HTMLProps<HTMLDivElement> { | ||
| /** Content of the main header toolbar. */ | ||
| children: React.ReactNode; | ||
| /** Additional classes added to the main header toolbar. */ | ||
| className?: string; | ||
| } | ||
|
|
||
| export const CompassMainHeaderToolbar: React.FunctionComponent<CompassMainHeaderToolbarProps> = ({ | ||
| children, | ||
| className, | ||
| ...props | ||
| }) => ( | ||
| <div className={css(`${styles.compass}__main-header-toolbar`, className)} {...props}> | ||
| {children} | ||
| </div> | ||
| ); | ||
|
|
||
| CompassMainHeaderToolbar.displayName = 'CompassMainHeaderToolbar'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
packages/react-core/src/components/Compass/__tests__/CompassMainHeaderContent.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import { render, screen } from '@testing-library/react'; | ||
| import { CompassMainHeaderContent } from '../CompassMainHeaderContent'; | ||
| import styles from '@patternfly/react-styles/css/components/Compass/compass'; | ||
|
|
||
| test('Renders with children', () => { | ||
| render(<CompassMainHeaderContent>Custom content</CompassMainHeaderContent>); | ||
| expect(screen.getByText('Custom content')).toBeVisible(); | ||
| }); | ||
|
|
||
| test(`Renders with default ${styles.compass}__main-header-content class`, () => { | ||
| render(<CompassMainHeaderContent>Test</CompassMainHeaderContent>); | ||
| expect(screen.getByText('Test')).toHaveClass(`${styles.compass}__main-header-content`); | ||
| }); | ||
|
|
||
| test('Renders with custom class name when className prop is provided', () => { | ||
| render(<CompassMainHeaderContent className="custom-class">Test</CompassMainHeaderContent>); | ||
| expect(screen.getByText('Test')).toHaveClass('custom-class'); | ||
| }); | ||
|
|
||
| test('Renders with additional props spread to the component', () => { | ||
| render(<CompassMainHeaderContent id="custom-id">Test</CompassMainHeaderContent>); | ||
| expect(screen.getByText('Test')).toHaveAttribute('id', 'custom-id'); | ||
| }); | ||
|
|
||
| test('Matches the snapshot', () => { | ||
| const { asFragment } = render(<CompassMainHeaderContent>Content</CompassMainHeaderContent>); | ||
| expect(asFragment()).toMatchSnapshot(); | ||
| }); |
28 changes: 28 additions & 0 deletions
28
packages/react-core/src/components/Compass/__tests__/CompassMainHeaderTitle.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import { render, screen } from '@testing-library/react'; | ||
| import { CompassMainHeaderTitle } from '../CompassMainHeaderTitle'; | ||
| import styles from '@patternfly/react-styles/css/components/Compass/compass'; | ||
|
|
||
| test('Renders with children', () => { | ||
| render(<CompassMainHeaderTitle>Custom content</CompassMainHeaderTitle>); | ||
| expect(screen.getByText('Custom content')).toBeVisible(); | ||
| }); | ||
|
|
||
| test(`Renders with default ${styles.compass}__main-header-title class`, () => { | ||
| render(<CompassMainHeaderTitle>Test</CompassMainHeaderTitle>); | ||
| expect(screen.getByText('Test')).toHaveClass(`${styles.compass}__main-header-title`); | ||
| }); | ||
|
|
||
| test('Renders with custom class name when className prop is provided', () => { | ||
| render(<CompassMainHeaderTitle className="custom-class">Test</CompassMainHeaderTitle>); | ||
| expect(screen.getByText('Test')).toHaveClass('custom-class'); | ||
| }); | ||
|
|
||
| test('Renders with additional props spread to the component', () => { | ||
| render(<CompassMainHeaderTitle id="custom-id">Test</CompassMainHeaderTitle>); | ||
| expect(screen.getByText('Test')).toHaveAttribute('id', 'custom-id'); | ||
| }); | ||
|
|
||
| test('Matches the snapshot', () => { | ||
| const { asFragment } = render(<CompassMainHeaderTitle>Content</CompassMainHeaderTitle>); | ||
| expect(asFragment()).toMatchSnapshot(); | ||
| }); |
28 changes: 28 additions & 0 deletions
28
packages/react-core/src/components/Compass/__tests__/CompassMainHeaderToolbar.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import { render, screen } from '@testing-library/react'; | ||
| import { CompassMainHeaderToolbar } from '../CompassMainHeaderToolbar'; | ||
| import styles from '@patternfly/react-styles/css/components/Compass/compass'; | ||
|
|
||
| test('Renders with children', () => { | ||
| render(<CompassMainHeaderToolbar>Custom content</CompassMainHeaderToolbar>); | ||
| expect(screen.getByText('Custom content')).toBeVisible(); | ||
| }); | ||
|
|
||
| test(`Renders with default ${styles.compass}__main-header-toolbar class`, () => { | ||
| render(<CompassMainHeaderToolbar>Test</CompassMainHeaderToolbar>); | ||
| expect(screen.getByText('Test')).toHaveClass(`${styles.compass}__main-header-toolbar`); | ||
| }); | ||
|
|
||
| test('Renders with custom class name when className prop is provided', () => { | ||
| render(<CompassMainHeaderToolbar className="custom-class">Test</CompassMainHeaderToolbar>); | ||
| expect(screen.getByText('Test')).toHaveClass('custom-class'); | ||
| }); | ||
|
|
||
| test('Renders with additional props spread to the component', () => { | ||
| render(<CompassMainHeaderToolbar id="custom-id">Test</CompassMainHeaderToolbar>); | ||
| expect(screen.getByText('Test')).toHaveAttribute('id', 'custom-id'); | ||
| }); | ||
|
|
||
| test('Matches the snapshot', () => { | ||
| const { asFragment } = render(<CompassMainHeaderToolbar>Content</CompassMainHeaderToolbar>); | ||
| expect(asFragment()).toMatchSnapshot(); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
...ore/src/components/Compass/__tests__/__snapshots__/CompassMainHeaderContent.test.tsx.snap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| // Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
|
||
| exports[`Matches the snapshot 1`] = ` | ||
| <DocumentFragment> | ||
| <div | ||
| class="pf-v6-c-compass__main-header-content" | ||
| > | ||
| Content | ||
| </div> | ||
| </DocumentFragment> | ||
| `; |
11 changes: 11 additions & 0 deletions
11
...-core/src/components/Compass/__tests__/__snapshots__/CompassMainHeaderTitle.test.tsx.snap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| // Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
|
||
| exports[`Matches the snapshot 1`] = ` | ||
| <DocumentFragment> | ||
| <div | ||
| class="pf-v6-c-compass__main-header-title" | ||
| > | ||
| Content | ||
| </div> | ||
| </DocumentFragment> | ||
| `; |
11 changes: 11 additions & 0 deletions
11
...ore/src/components/Compass/__tests__/__snapshots__/CompassMainHeaderToolbar.test.tsx.snap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| // Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
|
||
| exports[`Matches the snapshot 1`] = ` | ||
| <DocumentFragment> | ||
| <div | ||
| class="pf-v6-c-compass__main-header-toolbar" | ||
| > | ||
| Content | ||
| </div> | ||
| </DocumentFragment> | ||
| `; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.