Skip to content
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

Merged
merged 3 commits into from
Jan 24, 2025
Merged

Create a reusable Label component #9833

merged 3 commits into from
Jan 24, 2025

Conversation

Devessier
Copy link
Contributor

As seen with @Bonapara, I'm creating a Label component and use it in the workflows.

Copy link
Contributor

@greptile-apps greptile-apps bot left a 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

Comment on lines +19 to +24
export const Default: Story = {
decorators: [ComponentDecorator],
args: {
children: 'Label',
},
};
Copy link
Contributor

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

Comment on lines +7 to +14
font-size: ${({ variant = 'default' }) => {
switch (variant) {
case 'default':
return '11px';
case 'small':
return '9px';
}
}};
Copy link
Contributor

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 }>`
Copy link
Contributor

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

Copy link
Contributor

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

Copy link
Contributor Author

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;
Copy link
Contributor

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

Copy link
Contributor

@martmull martmull left a 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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export const Label = StyledLabel;
export { StyledLabel as Label };

Copy link
Contributor Author

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.

Copy link
Contributor

@prastoin prastoin left a 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 }),
Copy link
Contributor

@prastoin prastoin Jan 24, 2025

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 ?

Copy link
Contributor Author

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 }>`
Copy link
Contributor

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

@Devessier
Copy link
Contributor Author

@prastoin, this is a new component in the design system, as far as I understand.

@Bonapara
Copy link
Member

Can we define its color to Text/light?

@Devessier
Copy link
Contributor Author

Can we define its color to Text/light?

@Bonapara, I think this is what I did with theme.font.color.light. I checked, and it gives the same colors on light and dark mode than Text/light on Figma. Did I miss something?

@charlesBochet charlesBochet merged commit 84c299f into main Jan 24, 2025
47 checks passed
@charlesBochet charlesBochet deleted the add-label-component branch January 24, 2025 18:25
Copy link

Fails
🚫

node failed.

Log

�[31mError: �[39m SyntaxError: Unexpected token C in JSON at position 0
    at JSON.parse (<anonymous>)
�[90m    at parseJSONFromBytes (node:internal/deps/undici/undici:5584:19)�[39m
�[90m    at successSteps (node:internal/deps/undici/undici:5555:27)�[39m
�[90m    at fullyReadBody (node:internal/deps/undici/undici:1665:9)�[39m
�[90m    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)�[39m
�[90m    at async specConsumeBody (node:internal/deps/undici/undici:5564:7)�[39m
danger-results://tmp/danger-results-1f83f898.json

Generated by 🚫 dangerJS against a932390

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants