forked from patternfly/patternfly-react
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDivider.tsx
More file actions
61 lines (57 loc) · 2.14 KB
/
Divider.tsx
File metadata and controls
61 lines (57 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import { css } from '@patternfly/react-styles';
import styles from '@patternfly/react-styles/css/components/Divider/divider';
import { formatBreakpointMods } from '../../helpers/util';
export enum DividerVariant {
hr = 'hr',
li = 'li',
div = 'div'
}
export interface DividerProps extends React.HTMLProps<HTMLElement> {
/** Additional classes added to the divider */
className?: string;
/** The component type to use */
component?: 'hr' | 'li' | 'div';
/** Insets at various breakpoints. */
inset?: {
default?: 'insetNone' | 'insetXs' | 'insetSm' | 'insetMd' | 'insetLg' | 'insetXl' | 'inset2xl' | 'inset3xl';
sm?: 'insetNone' | 'insetXs' | 'insetSm' | 'insetMd' | 'insetLg' | 'insetXl' | 'inset2xl' | 'inset3xl';
md?: 'insetNone' | 'insetXs' | 'insetSm' | 'insetMd' | 'insetLg' | 'insetXl' | 'inset2xl' | 'inset3xl';
lg?: 'insetNone' | 'insetXs' | 'insetSm' | 'insetMd' | 'insetLg' | 'insetXl' | 'inset2xl' | 'inset3xl';
xl?: 'insetNone' | 'insetXs' | 'insetSm' | 'insetMd' | 'insetLg' | 'insetXl' | 'inset2xl' | 'inset3xl';
'2xl'?: 'insetNone' | 'insetXs' | 'insetSm' | 'insetMd' | 'insetLg' | 'insetXl' | 'inset2xl' | 'inset3xl';
};
/** Indicates how the divider will display at various breakpoints. Vertical divider must be in a flex layout. */
orientation?: {
default?: 'vertical' | 'horizontal';
sm?: 'vertical' | 'horizontal';
md?: 'vertical' | 'horizontal';
lg?: 'vertical' | 'horizontal';
xl?: 'vertical' | 'horizontal';
'2xl'?: 'vertical' | 'horizontal';
};
/** The ARIA role of the divider when the component property has a value other than "hr". */
role?: string;
}
export const Divider: React.FunctionComponent<DividerProps> = ({
className,
component = DividerVariant.hr,
inset,
orientation,
role = 'separator',
...props
}: DividerProps) => {
const Component: any = component;
return (
<Component
className={css(
styles.divider,
formatBreakpointMods(inset, styles),
formatBreakpointMods(orientation, styles),
className
)}
{...(component !== 'hr' && { role })}
{...props}
/>
);
};
Divider.displayName = 'Divider';