| 1 |
import styles from '@patternfly/react-styles/css/layouts/Split/split'; |
| 2 |
import { css } from '@patternfly/react-styles'; |
| 3 |
|
| 4 |
export interface SplitProps extends React.HTMLProps<HTMLDivElement> { |
| 5 |
/** Adds space between children. */ |
| 6 |
hasGutter?: boolean; |
| 7 |
/** Allows children to wrap. */ |
| 8 |
isWrappable?: boolean; |
| 9 |
/** content rendered inside the split layout. */ |
| 10 |
children?: React.ReactNode; |
| 11 |
/** Additional classes added to the split layout. */ |
| 12 |
className?: string; |
| 13 |
/** Sets the base component to render. Defaults to div. */ |
| 14 |
component?: React.ReactNode; |
| 15 |
} |
| 16 |
|
| 17 |
export const Split: React.FunctionComponent<SplitProps> = ({ |
| 18 |
hasGutter = false, |
| 19 |
isWrappable = false, |
| 20 |
className = '', |
| 21 |
children = null, |
| 22 |
component = 'div', |
| 23 |
...props |
| 24 |
}: SplitProps) => { |
| 25 |
const Component = component as any; |
| 26 |
return ( |
| 27 |
<Component |
| 28 |
{...props} |
| 29 |
className={css( |
| 30 |
styles.split, |
| 31 |
hasGutter && styles.modifiers.gutter, |
| 32 |
isWrappable && styles.modifiers.wrap, |
| 33 |
className |
| 34 |
)} |
| 35 |
> |
| 36 |
{children} |
| 37 |
</Component> |
| 38 |
); |
| 39 |
}; |
| 40 |
Split.displayName = 'Split'; |