forked from riccardoperra/codeimage
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFieldLabel.tsx
More file actions
51 lines (46 loc) · 1.27 KB
/
FieldLabel.tsx
File metadata and controls
51 lines (46 loc) · 1.27 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
import clsx from 'clsx';
import {Component, FlowComponent, mergeProps, Show} from 'solid-js';
import {Dynamic} from 'solid-js/web';
import {omitProps} from 'solid-use';
import {Box} from '../Box';
import {Text, TextComponentProps, TextProps} from '../Text';
import * as styles from './FieldLabel.css';
type FieldLabelProps = TextProps<'label'> & {
icon?: Component;
};
export const FieldLabel: FlowComponent<FieldLabelProps> = props => {
return (
<Text
{...omitProps(props, ['class', 'children'])}
as={'label'}
weight={'semibold'}
class={clsx(styles.label, props.class)}
>
{props.children}
</Text>
);
};
export const FieldLabelHint: FlowComponent<FieldLabelProps> = props => {
const computedProps = mergeProps(
{
weight: 'semibold',
} as TextComponentProps,
props,
);
return (
<Box class={styles.labelHintWrapper}>
<Show when={computedProps.icon}>
<Box as={'span'} marginRight={'1'} display={'inlineFlex'}>
<Dynamic component={computedProps.icon} />
</Box>
</Show>
<Text
{...omitProps(computedProps, ['class', 'children'])}
as={'label'}
class={clsx(styles.labelHint, props.class)}
>
{props.children}
</Text>
</Box>
);
};