Skip to content

TabMenu => TypeScript#213

Merged
nvmusoke merged 4 commits intomasterfrom
tab-menu-ts
Aug 24, 2020
Merged

TabMenu => TypeScript#213
nvmusoke merged 4 commits intomasterfrom
tab-menu-ts

Conversation

@mdespuits
Copy link
Copy Markdown
Contributor

Accomplishes two things:

  • Converts all TabMenu components to TS
  • Deprecates setting a plain string of active as a way to change styling rather than rely on the existing property.

I also add an Example section to the TabMenu storybook

Fixes #194

@mdespuits mdespuits marked this pull request as ready for review June 12, 2020 20:38
className: customClassName,
active = false,
children,
onClick = () => {},
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@pixelbandito @sebastianvera @dkordik As I opened this PR, I noticed that this onClick handler is simply dropping any ability to listen to click events on this component. Seems like a bug. Thoughts on removing this?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

does seem odd that this prop is given a default value if it's not actually used in the component... seems safe to remove as it's unused. (I wonder if the blame would reveal anything interesting- maybe it was formerly used and never cleaned up?)

Comment thread src/components/TabMenu/Item/Item.tsx Outdated
Copy link
Copy Markdown
Contributor

@pixelbandito pixelbandito left a comment

Choose a reason for hiding this comment

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

Looks ok so far, but I'd like to give it some more attention Monday.

Comment thread src/components/TabMenu/Item/Item.tsx Outdated
Comment thread src/components/TabMenu/Item/Item.tsx Outdated
@pixelbandito
Copy link
Copy Markdown
Contributor

Can you verify that tab content missing className doesn't break when this goes out.

Comment thread src/components/TabMenu/Item/Item.tsx Outdated
Comment thread src/components/TabMenu/Item/Item.tsx Outdated
...props
}) => {
const className = classNames(styles.Item, customClassName, {
[styles.active]: active || children,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this will now set the active class if "children" is truthy? will that not give false positives for inactive tabs? (where "children" would contain the node with the name of the inactive tab?)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

maybe a good first step would be to keep the functionality as is for the TS conversion, while adding some ?. to that section so it no longer errors when there is no child node with a className prop?

    if (React.isValidElement(child)) {
      return child.props?.className?.indexOf('active') >= 0;
    }

@pixelbandito pixelbandito requested a review from dkordik August 4, 2020 16:43
@nvmusoke nvmusoke merged commit 1744170 into master Aug 24, 2020
@nvmusoke nvmusoke deleted the tab-menu-ts branch August 24, 2020 21:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Convert TabMenu and TabMenu.Item to TypeScript

4 participants