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

feat(react): add IconTab component with size prop #10301

Merged
merged 17 commits into from
Jan 14, 2022
Merged

feat(react): add IconTab component with size prop #10301

merged 17 commits into from
Jan 14, 2022

Conversation

abbeyhrt
Copy link
Contributor

Closes #9991

Adds IconTab which just extends Tab with an added size prop for "default" and "lg" for 16px icons and 20px icons respectively.

I wasn't sure how to go about adding the size prop for Tab since it is only intended to be used with icons as the label. I added IconTab with the hope that it would make its intended use clear.

Changelog

New

  • IconTab component
  • size prop
  • Icon20Only story

Testing / Reviewing

Go to carbon-react-next storybook and verify that the individual Tabs for Icon only and Icon 20 only match the specs above. 40x40 for 16px icons and 48x48 for 20px icons.

@abbeyhrt abbeyhrt requested review from a team as code owners December 15, 2021 23:09
@netlify
Copy link

netlify bot commented Dec 15, 2021

✔️ Deploy Preview for carbon-react-next ready!

🔨 Explore the source changes: cd2612c

🔍 Inspect the deploy log: https://app.netlify.com/sites/carbon-react-next/deploys/61e1b8e1cdab6f0008b8dd2e

😎 Browse the preview: https://deploy-preview-10301--carbon-react-next.netlify.app

@netlify
Copy link

netlify bot commented Dec 15, 2021

✔️ Deploy Preview for carbon-components-react ready!

🔨 Explore the source changes: cd2612c

🔍 Inspect the deploy log: https://app.netlify.com/sites/carbon-components-react/deploys/61e1b8e19b24bd00089fa146

😎 Browse the preview: https://deploy-preview-10301--carbon-components-react.netlify.app

@netlify
Copy link

netlify bot commented Dec 15, 2021

✔️ Deploy Preview for carbon-elements ready!

🔨 Explore the source changes: cd2612c

🔍 Inspect the deploy log: https://app.netlify.com/sites/carbon-elements/deploys/61e1b8e11391850008d46a80

😎 Browse the preview: https://deploy-preview-10301--carbon-elements.netlify.app

Copy link
Member

@tay1orjones tay1orjones left a comment

Choose a reason for hiding this comment

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

A couple small things, otherwise looks great!

The question of adding this as a component vs placing these classes behind prop(s) on Tab lingers with me. What if it was a single prop on Tab that did both?

iconSize: PropTypes.oneOf([16, 20])

Without a default we can infer that .#{$prefix}--tabs__nav-item--icon should only be applied if we have a value for iconSize. This would also toggle .#{$prefix}--tabs__nav-item--icon--{default || lg} of course.

I'm open to either approach, curious what do you think?


IconTab.propTypes = {
/**
* Provide an icons to be rendered inside of `IconTab` as the visual label for Tab.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* Provide an icons to be rendered inside of `IconTab` as the visual label for Tab.
* Provide an icon to be rendered inside of `IconTab` as the visual label for Tab.

*/
className: PropTypes.string,
/**
* size of IconTab, default is intended for use with size 16 icons and lg is intended for use with size 20 icons.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* size of IconTab, default is intended for use with size 16 icons and lg is intended for use with size 20 icons.
* Specify the size of the `children` icon. `default` is intended for use with size 16 icons and `lg` is intended for use with size 20 icons.


.#{$prefix}--tabs__nav-item--icon--lg {
// had to use exact pixels because there is no way to get to 48px h/w without it.
padding: 13px 14px;
Copy link
Member

Choose a reason for hiding this comment

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

I think px values are generally converted to rem elsewhere in the codebase

Suggested change
padding: 13px 14px;
padding: rem(13px) rem(14px);

Comment on lines 66 to 77
<Tabs>
<TabList aria-label="List of tabs">
<Tab disabled>
<IconTab size="lg" disabled>
<Monster20 />
</Tab>
<Tab>
</IconTab>
<IconTab size="lg">
<Corn20 />
</Tab>
<Tab>
</IconTab>
<IconTab size="lg">
<Bat20 />
</Tab>
</IconTab>
</TabList>
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be possible to do <IconTabs size="lg"> so that we could define the size at the top-level of the component?

We could have the .cds--tabs__nav-item--icon class be something like:

.cds--tabs__nav-item--icon {
  min-height: var(--cds-tab-height, /* add whatever default height is */);
}

And in tabs set that CSS Custom Property depending on the prop passed in

@abbeyhrt abbeyhrt requested a review from joshblack January 10, 2022 20:20
Copy link
Contributor

@joshblack joshblack left a comment

Choose a reason for hiding this comment

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

Looks great! Just left a comment for a prop change, it's super small though so could be tackled later on.

/**
* If using `IconTab`, specify the size of the icon being used.
*/
iconSize: PropTypes.oneOf(['16', '20']),
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
iconSize: PropTypes.oneOf(['16', '20']),
iconSize: PropTypes.oneOf(['default', 'lg']),

I believe we should use the size names from other components to match convention there, let me know if I'm off 👍

@kodiakhq kodiakhq bot merged commit 405c510 into carbon-design-system:main Jan 14, 2022
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.

[Tabs]: Add size prop to icon-only Tabs variant
3 participants