Skip to content

Commit 9777f2c

Browse files
authored
Merge pull request #5 from VAR-META-Tech/feat/update-typography
feat: missing variant issue
2 parents cac4be6 + b3ad2a2 commit 9777f2c

9 files changed

Lines changed: 103 additions & 21 deletions

File tree

apps/web/src/app/page.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
ModalAction,
99
ModalHeader,
1010
Select,
11+
Text,
1112
toast,
1213
type AutocompleteProps,
1314
} from '@var-meta/ui';
@@ -70,7 +71,7 @@ export default function Page() {
7071
return (
7172
<>
7273
<main className="gap-2xl flex min-h-screen flex-col items-center justify-center">
73-
<div className="font-serif text-4xl font-semibold md:text-6xl">VAR UI</div>
74+
<Text weight="bold">VAR UI</Text>
7475

7576
<HStack
7677
className="w-full"
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import React from 'react';
2+
import type { Meta, StoryFn } from '@storybook/react';
3+
import { Form, type CheckboxFieldProps } from '@var-meta/ui';
4+
5+
import { EnhancedView } from '@/components/View';
6+
7+
const sizes: CheckboxFieldProps['size'][] = ['sm', 'md'];
8+
const checkboxOptions: CheckboxFieldProps['checked'][] = ['indeterminate', true, false, undefined];
9+
const meta: Meta = {
10+
title: 'Components/Checkbox/CheckboxField',
11+
component: Form.Checkbox,
12+
argTypes: {
13+
size: {
14+
options: sizes,
15+
control: { type: 'select' },
16+
},
17+
checked: {
18+
options: checkboxOptions,
19+
control: { type: 'select' },
20+
},
21+
disabled: {
22+
control: { type: 'boolean' },
23+
},
24+
},
25+
args: {
26+
label: 'Please accept the conditions',
27+
},
28+
parameters: {
29+
docs: {
30+
page: null,
31+
},
32+
controls: { expanded: true },
33+
},
34+
};
35+
36+
export default meta;
37+
38+
const DefaultTemplate: StoryFn<CheckboxFieldProps> = (args) => {
39+
return (
40+
<EnhancedView prop="Default">
41+
<Form.Checkbox id="checkbox" {...args} />
42+
</EnhancedView>
43+
);
44+
};
45+
46+
export const Default: StoryFn<typeof Form.Checkbox> = DefaultTemplate.bind({});

apps/web/src/stories/checkbox.stories.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,7 @@ export default meta;
3636
const DefaultTemplate: StoryFn<CheckboxProps> = (args) => {
3737
return (
3838
<EnhancedView prop="Default">
39-
<label htmlFor="checkbox" className="flex items-center space-x-2">
40-
<Checkbox id="checkbox" {...args} />
41-
<span className="text-sm">Please accept the conditions</span>
42-
</label>
39+
<Checkbox id="checkbox" {...args} />
4340
</EnhancedView>
4441
);
4542
};
@@ -49,10 +46,7 @@ export const Default: StoryFn<typeof Checkbox> = DefaultTemplate.bind({});
4946
const CheckBoxIconTemplate: StoryFn<CheckboxProps> = (args) => {
5047
return (
5148
<View prop="Default">
52-
<label htmlFor="checkbox-icon" className="flex items-center space-x-2">
53-
<Checkbox id="checkbox-icon" icon={<Star01Icon />} {...args} />
54-
<span className="text-sm">Please check to see the icon</span>
55-
</label>
49+
<Checkbox id="checkbox-icon" icon={<Star01Icon />} {...args} />
5650
</View>
5751
);
5852
};

apps/web/src/stories/heading.stories.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,28 @@ import { Heading, type HeadingProps } from '@var-meta/ui';
44

55
import { EnhancedView } from '@/components/View';
66

7+
const aligns: HeadingProps['align'][] = ['center', 'center', 'justify', 'left'];
8+
const sizes: HeadingProps['size'][] = ['xxs', 'xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl', '4xl', '5xl'];
9+
const weights: HeadingProps['weight'][] = ['light', 'regular', 'medium', 'bold', 'semibold', 'extrabold', 'black'];
10+
711
const meta: Meta = {
812
title: 'Components/Typography/Heading',
913
component: Heading,
1014
tags: ['autodocs'],
11-
argTypes: {},
15+
argTypes: {
16+
align: {
17+
options: aligns,
18+
control: { type: 'select' },
19+
},
20+
size: {
21+
options: sizes,
22+
control: { type: 'select' },
23+
},
24+
weight: {
25+
options: weights,
26+
control: { type: 'select' },
27+
},
28+
},
1229
args: {},
1330
};
1431

apps/web/src/stories/text.stories.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,28 @@ import { Text, type TextProps } from '@var-meta/ui';
44

55
import { EnhancedView } from '@/components/View';
66

7+
const aligns: TextProps['align'][] = ['center', 'center', 'justify', 'left'];
8+
const sizes: TextProps['size'][] = ['xxs', 'xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl', '4xl', '5xl'];
9+
const weights: TextProps['weight'][] = ['light', 'regular', 'medium', 'bold', 'semibold', 'extrabold', 'black'];
10+
711
const meta: Meta = {
812
title: 'Components/Typography/Text',
913
component: Text,
1014
tags: ['autodocs'],
11-
argTypes: {},
15+
argTypes: {
16+
align: {
17+
options: aligns,
18+
control: { type: 'select' },
19+
},
20+
size: {
21+
options: sizes,
22+
control: { type: 'select' },
23+
},
24+
weight: {
25+
options: weights,
26+
control: { type: 'select' },
27+
},
28+
},
1229
args: {},
1330
};
1431

packages/ui/src/components/form/checkbox-field.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { forwardRef } from 'react';
22

33
import { Checkbox, type CheckboxProps } from '../checkbox';
44
import { HelperText } from '../helper-text';
5-
import { Label } from '../label';
5+
import { labelVariants } from '../label/label';
66

77
export interface CheckboxFieldProps extends CheckboxProps {
88
label?: string;
@@ -14,8 +14,10 @@ const CheckboxField = forwardRef<React.ElementRef<typeof Checkbox>, CheckboxFiel
1414
({ label, helperText, variant = 'default', ...props }, ref) => {
1515
return (
1616
<div>
17-
{label && <Label>{label}</Label>}
18-
<Checkbox ref={ref} {...props} />
17+
<label htmlFor="checkbox" className="flex items-center">
18+
<Checkbox ref={ref} {...props} />
19+
{label ? <span className={labelVariants({ spacer: 'none', className: 'ml-2' })}>{label}</span> : null}
20+
</label>
1921
{helperText && <HelperText variant={props.disabled ? 'disabled' : variant}>{helperText}</HelperText>}
2022
</div>
2123
);

packages/ui/src/components/label/label.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,29 @@ import { tv, type VariantProps } from 'tailwind-variants';
44
import { type ElementProps } from '../../types';
55

66
const labelVariants = tv({
7-
base: 'text-foreground-primary block font-medium mb-1',
7+
base: 'text-foreground-primary block font-medium',
88
variants: {
99
size: {
1010
default: 'text-base',
1111
sm: 'text-sm',
1212
xs: 'text-xs',
1313
},
14+
spacer: {
15+
default: 'mb-1',
16+
none: 'mb-0',
17+
},
1418
},
1519
defaultVariants: {
1620
size: 'default',
21+
spacer: 'default',
1722
},
1823
});
1924

2025
export interface LabelProps extends ElementProps<'label'>, VariantProps<typeof labelVariants> {}
2126

22-
const Label = React.forwardRef<HTMLLabelElement, LabelProps>(({ children, size, className, ...props }, ref) => {
27+
const Label = React.forwardRef<HTMLLabelElement, LabelProps>(({ children, spacer, size, className, ...props }, ref) => {
2328
return (
24-
<label className={labelVariants({ size, className })} ref={ref} {...props}>
29+
<label className={labelVariants({ spacer, size, className })} ref={ref} {...props}>
2530
{children}
2631
</label>
2732
);

packages/ui/src/components/typography/Heading.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ export interface HeadingProps extends React.HTMLAttributes<HTMLDivElement>, Vari
5252
}
5353

5454
const Heading = React.forwardRef<HTMLDivElement, HeadingProps>(
55-
({ className, align, asChild = false, children, ...props }, ref) => {
55+
({ className, align, weight, size, asChild = false, children, ...props }, ref) => {
5656
const Comp = asChild ? Slot : 'div';
5757
return (
58-
<Comp className={headingVariants({ align, className })} ref={ref} {...props}>
58+
<Comp className={headingVariants({ align, weight, size, className })} ref={ref} {...props}>
5959
{children}
6060
</Comp>
6161
);

packages/ui/src/components/typography/Text.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ export interface TextProps extends React.HTMLAttributes<HTMLDivElement>, Variant
4848
}
4949

5050
const Text = React.forwardRef<HTMLDivElement, TextProps>(
51-
({ className, align, asChild = false, children, ...props }, ref) => {
51+
({ className, align, size, weight, asChild = false, children, ...props }, ref) => {
5252
const Comp = asChild ? Slot : 'div';
5353
return (
54-
<Comp className={textVariants({ align, className })} ref={ref} {...props}>
54+
<Comp className={textVariants({ size, weight, align, className })} ref={ref} {...props}>
5555
{children}
5656
</Comp>
5757
);

0 commit comments

Comments
 (0)