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 IconButton component(s) #262

Merged
merged 5 commits into from
May 29, 2024
Merged

Create IconButton component(s) #262

merged 5 commits into from
May 29, 2024

Conversation

psirenny
Copy link
Contributor

@psirenny psirenny commented May 27, 2024

This creates a much needed IconButton component with four variants: ghost, outline, soft, and solid. @eakbulut would very much appreciate your feedback! There were some decisions made without an obvious right answer.

Zero-offset outline focus ring

I chose to make the outline variant's focus ring share the button's outline. For example:
Screenshot 2024-05-27 at 11 09 32 AM

TailwindUI's canonical outline button does the same thing; but Catalyst UI (also created by the Tailwind Team), does not 🤷. I favored reusing the outline because it's easier to implement and I thought it still looked good. But it's slightly inconsistent, because other elements focus rings are 2px offset from the component. If removing the offset is undesirable then we can implement another way.

Icon scaling

I chose to make the icon scale with the component size. This seemed to be the least brittle approach because it works with any button size. However, I don't know if it's the best approach from a visual POV. It didn't seem bad to me so I kept it. TailwindUI's examples don't scale the icon in an IconButton though. For example:

Screenshot 2024-05-27 at 11 17 19 AM

Skeleton button supports colors and icons

I chose to make the skeleton state very flexible by allowing developers to customize the color and icon. I suspect that if one is using a skeleton in the first place, that they don't know what the color or icon ought to be. Otherwise, they'd just show that. That being said, this allows them the option of having a more specific or less specific skeleton. It's probably easier to see what I mean by experimenting with Storybook's controls.

Notes:

I chose to control aspects of the component with CSS classes instead of React properties wherever possible. For example, making the button a circle is just done by passing in rounded-full. Similarly, controlling the size is done by passing in size-x.

The toggle button is very similar to this component but I'll hold off on updating it until we nail this one down.

Copy link

vercel bot commented May 27, 2024

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

Name Status Preview Comments Updated (UTC)
spear-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 29, 2024 9:01am

@psirenny psirenny added the No review Indicate to Secureframe that this pull request doesn’t require review label May 29, 2024
@psirenny
Copy link
Contributor Author

@eakbulut you gave the green light on this one yesterday, so I'm going to merge this in.

@psirenny psirenny enabled auto-merge (squash) May 29, 2024 09:09
@psirenny psirenny disabled auto-merge May 29, 2024 09:09
@psirenny psirenny merged commit 83c1a54 into main May 29, 2024
5 checks passed
@psirenny psirenny deleted the icon-button branch May 29, 2024 09:09
@org-spear-ai org-spear-ai mentioned this pull request May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
No review Indicate to Secureframe that this pull request doesn’t require review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants