-
Notifications
You must be signed in to change notification settings - Fork 357
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
- Loading branch information
1 parent
e911735
commit 70a3cd5
Showing
46 changed files
with
321 additions
and
405 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
34 changes: 16 additions & 18 deletions
34
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,40 @@ | ||
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, EmptyStateIconProps } from './EmptyStateIcon'; | ||
|
||
export type EmptyStateHeadingLevel = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | '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>; | ||
/** Additional props passed to the icon element */ | ||
iconProps?: EmptyStateIconProps; | ||
/** The heading level to use, default is h1 */ | ||
headingLevel?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'; | ||
headingLevel?: EmptyStateHeadingLevel; | ||
} | ||
|
||
export const EmptyStateHeader: React.FunctionComponent<EmptyStateHeaderProps> = ({ | ||
children, | ||
className, | ||
titleClassName, | ||
titleText, | ||
headingLevel: HeadingLevel = 'h1', | ||
icon, | ||
icon: Icon, | ||
iconProps, | ||
...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} {...iconProps} />} | ||
<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.