-
Notifications
You must be signed in to change notification settings - Fork 353
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(EmptyState): update EmptyState with updates for penta (#9947)
* feat(EmptyState): update EmptyState with updates for penta * chore(EmptyState): tighten down props and types * chore(EmptyState): update headingLevel type * chore(EmptyState): fix status example * chore(EmptyState): remove iconProps prop from EmptyStateHeader * fix(EmptyState): finish removing iconProps from EmptyStateHeader
- Loading branch information
1 parent
e6f0968
commit 07cbb82
Showing
45 changed files
with
312 additions
and
382 deletions.
There are no files selected for viewing
This file contains 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 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 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 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
38 changes: 20 additions & 18 deletions
38
packages/react-core/src/components/EmptyState/EmptyStateHeader.tsx
This file contains 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 |
---|---|---|
@@ -1,42 +1,44 @@ | ||
import * as React from 'react'; | ||
import { css } from '@patternfly/react-styles'; | ||
import styles from '@patternfly/react-styles/css/components/EmptyState/empty-state'; | ||
import { EmptyStateIconProps } from './EmptyStateIcon'; | ||
import { EmptyStateIcon } from './EmptyStateIcon'; | ||
|
||
export enum EmptyStateHeadingLevel { | ||
h1 = 'h1', | ||
h2 = 'h2', | ||
h3 = 'h3', | ||
h4 = 'h4', | ||
h5 = 'h5', | ||
h6 = 'h6' | ||
} | ||
|
||
export interface EmptyStateHeaderProps extends React.HTMLProps<HTMLDivElement> { | ||
/** Content rendered inside the empty state header, either in addition to or instead of the titleText prop */ | ||
children?: React.ReactNode; | ||
/** Additional classes added to the empty state header */ | ||
className?: string; | ||
/** Additional classes added to the title inside empty state header */ | ||
titleClassName?: string; | ||
/** Text of the title inside empty state header, will be wrapped in headingLevel */ | ||
titleText?: React.ReactNode; | ||
/** Empty state icon element to be rendered */ | ||
icon?: React.ReactElement<EmptyStateIconProps>; | ||
titleText: React.ReactNode; | ||
/** Empty state icon element to be rendered. Can also be a spinner component */ | ||
icon?: React.ComponentType<any>; | ||
/** The heading level to use, default is h1 */ | ||
headingLevel?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'; | ||
} | ||
|
||
export const EmptyStateHeader: React.FunctionComponent<EmptyStateHeaderProps> = ({ | ||
children, | ||
className, | ||
titleClassName, | ||
titleText, | ||
headingLevel: HeadingLevel = 'h1', | ||
icon, | ||
headingLevel: HeadingLevel = EmptyStateHeadingLevel.h1, | ||
icon: Icon, | ||
...props | ||
}: EmptyStateHeaderProps) => ( | ||
<div className={css(`${styles.emptyState}__header`, className)} {...props}> | ||
{icon} | ||
{(titleText || children) && ( | ||
<div className={css(`${styles.emptyState}__title`)}> | ||
{titleText && ( | ||
<HeadingLevel className={css(styles.emptyStateTitleText, titleClassName)}>{titleText}</HeadingLevel> | ||
)} | ||
{children} | ||
</div> | ||
)} | ||
{Icon && <EmptyStateIcon icon={Icon} />} | ||
<div className={css(`${styles.emptyState}__title`)}> | ||
<HeadingLevel className={css(styles.emptyStateTitleText, titleClassName)}>{titleText}</HeadingLevel> | ||
</div> | ||
</div> | ||
); | ||
|
||
EmptyStateHeader.displayName = 'EmptyStateHeader'; |
This file contains 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 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 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.