Repository navigation
feat(ui-components): implement basic Button component - #45421
Conversation
|
👀 Review this PR in a CodeSee Review Map |
f65bed4 to
3241bf6
Compare
| switch (size) { | ||
| case 'large': | ||
| classNames.push('px-4 py-2.5 text-lg'); | ||
| break; | ||
| case 'small': | ||
| classNames.push('px-2.5 py-1 text-sm'); | ||
| break; | ||
| // default size is 'medium' | ||
| default: | ||
| classNames.push('px-3 py-1.5 text-md'); | ||
| } |
There was a problem hiding this comment.
px is horizontal padding, and py is vertical padding.
The values are from Tailwind padding doc:
{p}-1is 4px{p}-1.5is 6px{p}-2.5is 10px{p}-3is 12px{p}-4is 16px
As for the text classes, refer to the changes I made to the tailwind.config.js file for their values.
Some values here are slightly different from those of the current button component. I have added the rationale to the issue description, under the "Spacing and typography" section, but I'm just copy-pasting it here:
The current values of font size, line height, and padding from Bootstrap seem a bit strange to me, as there are some odd numbers in there, which I think would add some challenges in scaling/positioning. Now that we switch to Tailwind, my proposal is to adopt its system and slightly adjust the styling of our component.
| Size | Current | New |
|---|---|---|
| Small | padding: 5px 10px font-size: 16pxline-height: 1.5 |
padding: 4px 10px font-size: 16pxline-height: 1.5 |
| Medium | padding: 6px 12px font-size: 18pxline-height: 1.42857143 |
padding: 6px 12px font-size: 18pxline-height: 1.42857143 |
| Large | padding: 10px 16px font-size: 23pxline-height: 1.3333333 |
padding: 10px 16px font-size: 24pxline-height: 1.3333333 |
3241bf6 to
70bd3f1
Compare
| [size, variant] | ||
| ); | ||
|
|
||
| return ( |
There was a problem hiding this comment.
Forwarding refs seem to be the best practice. React.forwardRef
Once added, we could write a test for it as well.


Checklist:
Update index.md)mainbranch of freeCodeCamp.Ref #45357
This PR:
variantsizeonClicktypeScreenshot