Skip to content

Commit beb57b2

Browse files
committed
feat(Label): size prop
1 parent 957779c commit beb57b2

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

.changeset/tasty-mangos-sin.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@cube-dev/ui-kit": patch
3+
---
4+
5+
Add `size` prop for Label with `small` and `medium` (default) values.

src/components/form/FieldWrapper/FieldWrapper.stories.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ const Template: StoryFn<CubeFieldWrapperProps> = (args) => (
3939

4040
export const Default = Template.bind({});
4141

42+
export const Small = Template.bind({});
43+
Small.args = {
44+
labelProps: { size: 'small' },
45+
};
46+
4247
export const WithTooltip = Template.bind({});
4348
WithTooltip.args = {
4449
tooltip: 'Long description',

src/components/form/Label.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ export const INLINE_LABEL_STYLES: Styles = {
5959

6060
export const LABEL_STYLES: Styles = {
6161
display: 'block',
62-
preset: 't3m',
62+
preset: {
63+
'': 't3m',
64+
'[data-size="small"]': 't4',
65+
},
6366
color: {
6467
'': '#dark',
6568
invalid: '#danger-text',
@@ -86,6 +89,7 @@ export interface CubeLabelProps extends BaseProps, ContainerStyleProps {
8689
htmlFor?: string;
8790
for?: string;
8891
validationState?: ValidationState;
92+
size?: 'medium' | 'small';
8993
}
9094

9195
function Label(props: CubeLabelProps, ref) {
@@ -102,6 +106,7 @@ function Label(props: CubeLabelProps, ref) {
102106
htmlFor,
103107
isDisabled,
104108
validationState,
109+
size = 'medium',
105110
for: labelFor,
106111
...otherProps
107112
} = props;
@@ -132,6 +137,7 @@ function Label(props: CubeLabelProps, ref) {
132137
ref={domRef}
133138
styles={styles}
134139
htmlFor={labelFor || htmlFor}
140+
data-size={size}
135141
mods={{
136142
side: labelPosition === 'side',
137143
disabled: isDisabled,

0 commit comments

Comments
 (0)