-
Notifications
You must be signed in to change notification settings - Fork 833
/
cell-shell.js
61 lines (54 loc) · 1.5 KB
/
cell-shell.js
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
/*
Copyright (c) 2018-2020 Uber Technologies, Inc.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
*/
// @flow
import * as React from 'react';
import {Checkbox} from '../checkbox/index.js';
import {useStyletron} from '../styles/index.js';
type PropsT = {|
children: React.Node,
isMeasured?: boolean,
isSelected?: boolean,
onSelect?: () => void,
|};
const CellShell = React.forwardRef<PropsT, HTMLDivElement>((props, ref) => {
const [css, theme] = useStyletron();
return (
<div
ref={ref}
className={css({
...theme.typography.font100,
boxSizing: 'border-box',
color: theme.colors.contentPrimary,
display: props.isMeasured ? 'inline-block' : null,
paddingTop: theme.sizing.scale300,
paddingLeft: theme.sizing.scale500,
paddingBottom: theme.sizing.scale300,
paddingRight: theme.sizing.scale500,
width: props.isMeasured ? null : '100%',
})}
>
<div
className={css({
display: 'flex',
alignItems: 'center',
})}
>
{Boolean(props.onSelect) && (
<Checkbox
onChange={props.onSelect}
checked={props.isSelected}
overrides={{
Checkmark: {style: {marginTop: null, marginBottom: null}},
}}
/>
)}
{props.children}
</div>
</div>
);
});
CellShell.displayName = 'CellShell';
export default CellShell;