Debian Codegraph @

node/@patternfly/react-core/src/components/Title/Title.tsx

raw
1 import { css } from '@patternfly/react-styles';
2 import styles from '@patternfly/react-styles/css/components/Title/title';
3 import { useOUIAProps, OUIAProps } from '../../helpers';
4
5 export enum TitleSizes {
6 md = 'md',
7 lg = 'lg',
8 xl = 'xl',
9 '2xl' = '2xl',
10 '3xl' = '3xl',
11 '4xl' = '4xl'
12 }
13
14 type Size = 'md' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl';
15
16 export interface TitleProps extends Omit<React.HTMLProps<HTMLHeadingElement>, 'size' | 'className'>, OUIAProps {
17 /** The size of the Title */
18 size?: Size;
19 /** Content rendered inside the Title */
20 children?: React.ReactNode;
21 /** Additional classes added to the Title */
22 className?: string;
23 /** The heading level to use */
24 headingLevel: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
25 /** Value to overwrite the randomly generated data-ouia-component-id.*/
26 ouiaId?: number | string;
27 /** Set the value of data-ouia-safe. Only set to true when the component is in a static state, i.e. no animations are occurring. At all other times, this value must be false. */
28 ouiaSafe?: boolean;
29 }
30
31 export const Title: React.FunctionComponent<TitleProps> = ({
32 className = '',
33 children = '',
34 headingLevel: HeadingLevel,
35 size,
36 ouiaId,
37 ouiaSafe = true,
38 ...props
39 }: TitleProps) => {
40 const ouiaProps = useOUIAProps(Title.displayName, ouiaId, ouiaSafe);
41 return (
42 <HeadingLevel
43 {...ouiaProps}
44 {...props}
45 className={css(styles.title, size ? styles.modifiers[size as Size] : styles.modifiers[HeadingLevel], className)}
46 >
47 {children}
48 </HeadingLevel>
49 );
50 };
51 Title.displayName = 'Title';