-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRow.tsx
More file actions
62 lines (55 loc) · 1.44 KB
/
Row.tsx
File metadata and controls
62 lines (55 loc) · 1.44 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
62
import clsx from 'clsx';
import React, { type CSSProperties, type HTMLAttributes, type PropsWithChildren } from 'react';
import './styles.css';
export interface RowProps extends HTMLAttributes<HTMLDivElement> {
align?: CSSProperties['alignItems'];
columnGap?: CSSProperties['columnGap'];
rowGap?: CSSProperties['rowGap'];
gap?: CSSProperties['columnGap'];
justify?: CSSProperties['justifyContent'];
fullHeight?: boolean;
reverseOnSmallScreen?: boolean;
}
export const Row = ({
align,
children,
className,
columnGap,
fullHeight,
gap,
justify,
reverseOnSmallScreen,
rowGap,
style,
...rest
}: PropsWithChildren<RowProps>) => {
const classes = clsx(
'clippy-row',
{
'clippy-row--full-height': fullHeight,
'clippy-row--reverse-small': reverseOnSmallScreen,
},
className,
);
const rowStyle: CSSProperties = {
alignItems: align,
display: 'flex',
flexWrap: 'wrap',
justifyContent: justify,
...style,
};
const effectiveColumnGap = columnGap ?? gap;
if (effectiveColumnGap) {
(rowStyle as CSSProperties & { '--clippy-row-column-gap'?: CSSProperties['columnGap'] })[
'--clippy-row-column-gap'
] = effectiveColumnGap;
}
if (rowGap) {
(rowStyle as CSSProperties & { '--clippy-row-row-gap'?: CSSProperties['rowGap'] })['--clippy-row-row-gap'] = rowGap;
}
return (
<div className={classes} style={rowStyle} {...rest}>
{children}
</div>
);
};