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(components): expose sidebar context #512

Merged
merged 1 commit into from
Nov 27, 2019

Conversation

nikilok
Copy link
Contributor

@nikilok nikilok commented Nov 27, 2019

Purpose

Expose sidebar context that allows it to be used with the useContext hook.
Currently the sideBar context is accessed using the render props method like so.

<SidebarContextConsumer>
  {({ isSidebarOpen, toggleSidebar } = {}) =>
    <SideNavToggle
      onClick={toggleSidebar}
    />
  )}
</SidebarContextConsumer>

This method of accessing was necessary in the past, however with the availability of the useContext hook it makes things a lot more simpler and elegant.

Approach and changes

With this PR, we also enable consuming the context with the useContext hook, however we still support the older render props access method so we don't break things.

 import { SidebarContext } from '@sumup/circuit-ui';
 
 const { toggleSidebar, isSidebarOpen } = useContext(SidebarContext);

Definition of done

  • Development completed
  • Reviewers assigned
  • Unit and integration tests
  • Meets minimum browser support
  • Meets accessibility requirements

expose sidebar context that allows it to be used with the useContext hook.
This allows the side bar
context to be used in a simpler pattern that does not require the render props method of usage.
@codecov
Copy link

codecov bot commented Nov 27, 2019

Codecov Report

Merging #512 into canary will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           canary     #512   +/-   ##
=======================================
  Coverage   79.65%   79.65%           
=======================================
  Files         172      172           
  Lines        2477     2477           
  Branches      445      445           
=======================================
  Hits         1973     1973           
  Misses        388      388           
  Partials      116      116
Impacted Files Coverage Δ
src/components/Sidebar/SidebarContext.js 100% <100%> (ø) ⬆️

Copy link
Contributor

@robinmetral robinmetral left a comment

Choose a reason for hiding this comment

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

🚀

@nikilok nikilok merged commit 78a44b2 into canary Nov 27, 2019
@nikilok nikilok deleted the feature/expose-sidebar-context branch November 27, 2019 14:35
@connor-baer
Copy link
Member

🎉 This PR is included in version 1.4.1-canary.6 🎉

The release is available on:

Your semantic-release bot 📦🚀

@connor-baer
Copy link
Member

🎉 This PR is included in version 1.5.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

connor-baer pushed a commit that referenced this pull request Dec 11, 2019
expose sidebar context that allows it to be used with the useContext hook.
This allows the side bar
context to be used in a simpler pattern that does not require the render props method of usage.
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.

4 participants