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

Add new React Tabs-based component #1305

Merged
merged 6 commits into from
Jun 4, 2021
Merged

Add new React Tabs-based component #1305

merged 6 commits into from
Jun 4, 2021

Conversation

jaredcwhite
Copy link
Collaborator

@jaredcwhite jaredcwhite commented Jun 1, 2021

Pull Request Template

Issue

Addresses #1157

  • This change addresses the issue in full
  • This change addresses only certain aspects of the issue
  • This change is a dependency for another issue
  • This change has a dependency from another issue

Description

This PR adds the React Tabs dependency and wraps those components so we get default styling. The previous Tab subcomponent of TabNav has been renamed to TabNavItem.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Prototype/POC (not to merge)
  • This change is a refactor/address technical debt
  • This change requires a documentation update
  • This change requires a SQL Script

How Can This Be Tested/Reviewed?

  • Storybook (Navigation / Tabs)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have reviewed the changes in a desktop view
  • I have reviewed the changes in a mobile view
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have assigned reviewers
  • I have updated the changelog to include a description of my changes

@jaredcwhite
Copy link
Collaborator Author

@slowbot Good thing we have a checklist! I just looked at the Storybook example in a narrow (aka mobile) window size and the tabs look pretty funky. Wonder what you think we should do. Truncate and add elipsis… ? Make them horizontally scrolling?

@netlify
Copy link

netlify bot commented Jun 1, 2021

✔️ Deploy Preview for clever-edison-cd22c1 ready!

🔨 Explore the source changes: 123e884

🔍 Inspect the deploy log: https://app.netlify.com/sites/clever-edison-cd22c1/deploys/60bab5d91f79ec000874af63

😎 Browse the preview: https://deploy-preview-1305--clever-edison-cd22c1.netlify.app

Copy link
Collaborator

@slowbot slowbot left a comment

Choose a reason for hiding this comment

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

@jaredcwhite Added a couple of small style updates. Otherwise LGTM

@emilyjablonski
Copy link
Collaborator

@software-project what do you think about Jared's comment concerning the tabs on mobile?

afterEach(cleanup)

describe("<Tabs>", () => {
it("displays the right CSS", () => {
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 just testing implementation details - is there a way we can test component or prop functionality without looking at class names?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I tried to at least test the left/right arrow keys like on TabNav but was unsuccessful. Spent a while trying to get the events to fire but something was off. Basically we'd be testing a third-party component anyway, so not sure how much we need to dig into that. Maybe write a test to simulate clicking on the different tabs and double-check if that works?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Fair point on the 3rd party component :) I'll take a quick peek

Copy link
Collaborator

@emilyjablonski emilyjablonski Jun 3, 2021

Choose a reason for hiding this comment

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

Looks like it's really well tested on their end. I took a peek just to see how they did it bc I also couldn't get the tabs to change, and it looks like they're pulling in another RTL sub-package called userEvent (🤷‍♀️) I would still recommend we change the first test though. I don't think we should rely on any of their class names, as we could pull a new version of this and it could break the test but no functionality. Maybe we can just test our own prop? Something like:
it("can pass a custom class name", () => { const { container } = render( <Tabs defaultIndex={1}> <TabList> <Tab className="other-tab">Other</Tab> <Tab>Default</Tab> </TabList> <TabPanel className="other-panel">OtherPanel</TabPanel> <TabPanel>DefaultPanel</TabPanel> </Tabs> ) expect(container.getElementsByClassName("other-tab").length).toBe(1) expect(container.getElementsByClassName("other-panel").length).toBe(1) })

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks @emilyjablonski, I'll try that…good call on not hardcoding their internal class names. I'll see if I can remove one from our stylesheet in lieu of a custom one as well.

@slowbot
Copy link
Collaborator

slowbot commented Jun 3, 2021

@jaredcwhite There are a few options for mobile tabs but I think stacking makes the most sense
See: https://inclusive-components.design/tabbed-interfaces/

@jaredcwhite
Copy link
Collaborator Author

@slowbot That sounds good. I'll work on a stacked presentation for mobile.

@emilyjablonski
Copy link
Collaborator

One comment on the test, otherwise LGTM! I personally think the mobile piece could be a separate issue if you want to break it out. Up to you.

@jaredcwhite
Copy link
Collaborator Author

I got the mobile tab stacking implemented and improved the resiliency of the tab/panel CSS and testing.

Copy link
Collaborator

@slowbot slowbot left a comment

Choose a reason for hiding this comment

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

@jaredcwhite jaredcwhite merged commit 14ac5f8 into master Jun 4, 2021
@jaredcwhite jaredcwhite deleted the new-tabs-component branch June 4, 2021 23:23
@jaredcwhite jaredcwhite mentioned this pull request Jun 7, 2021
28 tasks
willrlin referenced this pull request in CityOfDetroit/bloom Jun 9, 2021
* Add new React Tabs-based component, switch old Tab to TabNavItem

* Add disabled tab style

* adding slight style updates

* Responsive tab design

* Update tabs selected class name, tests

* Add info on Tabs component to Changlog

Co-authored-by: Jesse Arnold <jessearnold@Jesses-MacBook-Pro.local>
willrlin referenced this pull request in CityOfDetroit/bloom Jun 9, 2021
willrlin referenced this pull request in CityOfDetroit/bloom Jun 9, 2021
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.

None yet

3 participants