forked from twentyhq/twenty
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a reusable Label component (twentyhq#9833)
As seen with @Bonapara, I'm creating a Label component and use it in the workflows.
- Loading branch information
Showing
4 changed files
with
66 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
packages/twenty-ui/src/display/typography/components/Label.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import styled from '@emotion/styled'; | ||
|
||
export type LabelVariant = 'default' | 'small'; | ||
|
||
const StyledLabel = styled.div<{ variant?: LabelVariant }>` | ||
color: ${({ theme }) => theme.font.color.light}; | ||
font-size: ${({ variant = 'default' }) => { | ||
switch (variant) { | ||
case 'default': | ||
return '11px'; | ||
case 'small': | ||
return '9px'; | ||
} | ||
}}; | ||
font-weight: ${({ theme }) => theme.font.weight.semiBold}; | ||
`; | ||
|
||
export { StyledLabel as Label }; |
42 changes: 42 additions & 0 deletions
42
packages/twenty-ui/src/display/typography/components/__stories__/Label.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { Meta, StoryObj } from '@storybook/react'; | ||
|
||
import { CatalogDecorator } from '@ui/testing/decorators/CatalogDecorator'; | ||
import { ComponentDecorator } from '@ui/testing/decorators/ComponentDecorator'; | ||
import { CatalogStory } from '@ui/testing/types/CatalogStory'; | ||
|
||
import { Label, LabelVariant } from '../Label'; | ||
|
||
const meta: Meta<typeof Label> = { | ||
title: 'UI/Display/Typography/Label', | ||
component: Label, | ||
decorators: [ComponentDecorator], | ||
}; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof Label>; | ||
|
||
export const Default: Story = { | ||
decorators: [ComponentDecorator], | ||
args: { | ||
children: 'Label', | ||
}, | ||
}; | ||
|
||
export const Catalog: CatalogStory<Story, typeof Label> = { | ||
decorators: [CatalogDecorator], | ||
args: { | ||
children: 'Label', | ||
}, | ||
parameters: { | ||
catalog: { | ||
dimensions: [ | ||
{ | ||
name: 'Variant', | ||
values: ['default', 'small'] satisfies LabelVariant[], | ||
props: (variant: LabelVariant) => ({ variant }), | ||
}, | ||
], | ||
}, | ||
}, | ||
}; |