-
-
Notifications
You must be signed in to change notification settings - Fork 9.1k
/
field.tsx
40 lines (35 loc) · 846 Bytes
/
field.tsx
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
import type { ReactNode } from 'react';
import React from 'react';
import { styled } from '@storybook/theming';
const Wrapper = styled.label(({ theme }) => ({
display: 'flex',
borderBottom: `1px solid ${theme.appBorderColor}`,
margin: '0 15px',
padding: '8px 0',
'&:last-child': {
marginBottom: '3rem',
},
}));
const Label = styled.span(({ theme }) => ({
minWidth: 100,
fontWeight: theme.typography.weight.bold,
marginRight: 15,
display: 'flex',
justifyContent: 'flex-start',
alignItems: 'center',
lineHeight: '16px',
}));
export interface FieldProps {
children?: ReactNode;
label?: ReactNode;
}
export const Field = ({ label, children, ...props }: FieldProps) => (
<Wrapper {...props}>
{label ? (
<Label>
<span>{label}</span>
</Label>
) : null}
{children}
</Wrapper>
);