-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create a reusable Label component #9833
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
This PR introduces a new reusable Label typography component with size variants and implements it in the workflow diagram, improving design system consistency.
- New
packages/twenty-ui/src/display/typography/components/Label.tsx
component uses theme values for styling with 'default' (11px) and 'small' (9px) variants - Replaced custom styled div in
WorkflowDiagramBaseStepNode.tsx
with the new Label component for node type labels - Added comprehensive Storybook stories in
Label.stories.tsx
showcasing both variants with proper decorators - Consider adding text-transform and letter-spacing properties to match typical label styling patterns
4 file(s) reviewed, 4 comment(s)
Edit PR Review Bot Settings | Greptile
export const Default: Story = { | ||
decorators: [ComponentDecorator], | ||
args: { | ||
children: 'Label', | ||
}, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: ComponentDecorator is redundant here since it's already defined in the meta object's decorators
font-size: ${({ variant = 'default' }) => { | ||
switch (variant) { | ||
case 'default': | ||
return '11px'; | ||
case 'small': | ||
return '9px'; | ||
} | ||
}}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: Switch statement missing default case. Could cause undefined font-size if invalid variant is passed.
|
||
export type LabelVariant = 'default' | 'small'; | ||
|
||
const StyledLabel = styled.div<{ variant?: LabelVariant }>` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Consider using semantic HTML by extending 'label' or 'span' instead of 'div' for better accessibility
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: isn't greptile right about this ? Or I've also misunderstood emotion styled here too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The label is not strictly meant to be used as part of a form. The benefit of exporting the component as-is is that it's possible to change the rendered element with the as
prop.
font-weight: ${({ theme }) => theme.font.weight.semiBold}; | ||
`; | ||
|
||
export const Label = StyledLabel; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Component lacks TypeScript props interface definition for proper type checking of children and other potential props
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One comment but lgtm
font-weight: ${({ theme }) => theme.font.weight.semiBold}; | ||
`; | ||
|
||
export const Label = StyledLabel; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export const Label = StyledLabel; | |
export { StyledLabel as Label }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if there is a team choice on this topic, but I don't feel it provides more clarity. I changed it because I found another component that was exported similarly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool ! Will the Label
styled component retrospectively applied elsewhere on the app or is it the first use case ?
Left few non-blocking comments
{ | ||
name: 'Variant', | ||
values: ['default', 'small'] as LabelVariant[], | ||
props: (variant: LabelVariant) => ({ variant }), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remark: Unless I'm mistaken force cast is not mandatory here, might wanna use satisfies
instead if we wanna keep it tied to LabelVariant
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching this. My as LabelVariant[]
was pure bullshit.
|
||
export type LabelVariant = 'default' | 'small'; | ||
|
||
const StyledLabel = styled.div<{ variant?: LabelVariant }>` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: isn't greptile right about this ? Or I've also misunderstood emotion styled here too
@prastoin, this is a new component in the design system, as far as I understand. |
Can we define its color to Text/light? |
@Bonapara, I think this is what I did with |
Log
|
As seen with @Bonapara, I'm creating a Label component and use it in the workflows.