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

fix: icon button sizes & update button docs #1738

Merged
merged 5 commits into from
Jun 11, 2024
Merged

Conversation

joshuaellis
Copy link
Member

@joshuaellis joshuaellis commented Jun 10, 2024

What does it do?

  • refactor LinkButton to just be a wrapper of Button (less bugs)
  • refactor IconButton to be more powerful & correct it's sizes
  • update documentation for all "Buttons"

Related issue(s)/PR(s)

@joshuaellis joshuaellis added pr: fix This PR is fixing a bug source: design-system relates to design-system package labels Jun 10, 2024
@joshuaellis joshuaellis self-assigned this Jun 10, 2024
Copy link

vercel bot commented Jun 10, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
design_system_v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 11, 2024 9:20am
design-system ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 11, 2024 9:20am
design-system-website ❌ Failed (Inspect) Jun 11, 2024 9:20am

Copy link

changeset-bot bot commented Jun 10, 2024

🦋 Changeset detected

Latest commit: f623e78

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@strapi/design-system Patch
@strapi/icons Patch
@strapi/ui-primitives Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

github-actions bot commented Jun 10, 2024

Size Change: -782 B (-0.27%)

Total Size: 288 kB

Filename Size Change
packages/design-system/dist/index.js 94.8 kB -369 B (-0.39%)
packages/design-system/dist/index.mjs 93.7 kB -413 B (-0.44%)
ℹ️ View Unchanged
Filename Size
packages/icons/dist/index.js 21.9 kB
packages/icons/dist/index.mjs 21.6 kB
packages/icons/dist/symbols-index.js 11.8 kB
packages/icons/dist/symbols-index.mjs 11.6 kB
packages/primitives/dist/index.js 16.8 kB
packages/primitives/dist/index.mjs 16.3 kB

compressed-size-action

Copy link
Contributor

@remidej remidej left a comment

Choose a reason for hiding this comment

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

This design system of ours is getting pretty cool 🔥

Side note, I wish I had access to the Vercel org to see the preview

docs/stories/04-components/IconButton.mdx Outdated Show resolved Hide resolved
docs/stories/04-components/LinkButton.mdx Outdated Show resolved Hide resolved
docs/stories/04-components/LinkButton.mdx Outdated Show resolved Hide resolved
docs/stories/04-components/TextButton.mdx Outdated Show resolved Hide resolved
Co-authored-by: Rémi de Juvigny <8087692+remidej@users.noreply.github.com>
@joshuaellis
Copy link
Member Author

Side note, I wish I had access to the Vercel org to see the preview

did you click visit preview? i've tweaked some settings and using incognito i can still see the preview, so might work now?

@remidej
Copy link
Contributor

remidej commented Jun 11, 2024

did you click visit preview? i've tweaked some settings and using incognito i can still see the preview, so might work now?

My bad, I was following the link from the CI checks, but the direct link in the comment works perfectly

Copy link
Contributor

@remidej remidej left a comment

Choose a reason for hiding this comment

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

nice!

startIcon?: React.ReactNode;
variant?: ButtonVariant;
};
type LinkButtonProps<C extends React.ElementType = typeof BaseLink> = ButtonProps<C>;
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is not clear,

why this is not type LinkButtonProps<C extends React.ElementType = "button"> = ButtonProps<C>;

how this LinkButton wrapped exactly? even this syntax is confusing for me, <Button<typeof BaseLink>. If you could please elaborate or discuss on call.

Copy link
Member Author

Choose a reason for hiding this comment

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

Because the tag component used in the Button component below is BaseLink. In our polymorphic components, the C generic denotes the element which corresponds directly to the tag prop.

The <Button<typeof BaseLink> is because all components are just functions, and the Button component is a generic function that takes it's element type. So in this scenario because we're working with two layers of polymoprhism we add the component as the generic that our props correspond too to avoid type errors.

Copy link
Collaborator

Choose a reason for hiding this comment

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

ohk, I will check how this polymorphism works here, thanks

Copy link
Member Author

Choose a reason for hiding this comment

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

we can go through it on thursday if it's still not clear 😄

@joshuaellis joshuaellis merged commit 8a87483 into releases/2.0.0 Jun 11, 2024
11 of 12 checks passed
@joshuaellis joshuaellis deleted the chore/buttons branch June 11, 2024 10:52
Comment on lines +139 to +163
<Flex gap={2}>
{BUTTON_VARIANTS.map((variant) => (
<IconButton key={variant} {...args} variant={variant}>
<Icon />
</IconButton>
))}
</Flex>
);
},
name: 'all variants',
} satisfies Story;

export const Group = {
render: () => (
<IconButtonGroup>
<IconButton label="Edit">
<Icons.Pencil />
</IconButton>
<IconButton label="Clone">
<Icons.Duplicate />
</IconButton>
<IconButton label="Delete" variant="danger">
<Icons.Trash />
</IconButton>
</IconButtonGroup>
Copy link
Collaborator

Choose a reason for hiding this comment

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

You will need to add source code as its incorrect for all variants and group. Also it would have been great if we also show withTooltip example in one of the example, so it replaces the default label?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: fix This PR is fixing a bug source: design-system relates to design-system package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[bug]: disabled prop is inconsistent across Button and IconButton
3 participants