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(checkbox): Add theming support #456

Merged
merged 8 commits into from
Feb 13, 2020

Conversation

anicholls
Copy link
Contributor

@anicholls anicholls commented Feb 11, 2020

Summary

We're adding theming to our inputs. The consumer must wrap their components in a CanvasProvider and then they can pass their custom theme to any child components through the theme prop.

Partially addresses #358

Checklist

  • branch has been rebased on the latest master commit
  • tests are changed or added
  • yarn test passes
  • code adheres to the API & Pattern guidelines

@cypress
Copy link

cypress bot commented Feb 11, 2020



Test summary

155 0 0 0


Run details

Project canvas-kit
Status Passed
Commit 963dbca
Started Feb 12, 2020 11:50 PM
Ended Feb 12, 2020 11:53 PM
Duration 03:24 💡
OS Linux Ubuntu Linux - 16.04
Browser Electron 78

View run in Cypress Dashboard ➡️


This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard

*
* @returns {CSSObject} the css object for the focus ring style
*/
export function themedFocusRing(
Copy link
Contributor Author

@anicholls anicholls Feb 11, 2020

Choose a reason for hiding this comment

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

Interested to hear thoughts on this. I did this for a few reasons:

  1. Unfortunately because we are usually calling this from within a class component, we can't use React.useContext. This means we need to pass the theme into the focusRing function. It would have been pretty nasty passing in every prop just to get theme at the end.

  2. I'm often frustrated by the unclear nature of these params when you see them in use. The added complexity of an options object was worth it for the legibility and possibility for future changes IMO. This now looks like themedFocusRing(theme, {separation: 2, animate: false}) instead of focusRing(2, 2, false). I realize IDE hinting could help, but I still prefer the options object.

  3. Rather than trying to hack the existing focusRing function to accept individual params vs. an options object without a breaking change, I figured a new function would be cleaner. We can consider deprecating focusRing in the future.

Copy link
Member

Choose a reason for hiding this comment

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

I'm fine with this change. The theme context can be passed either through the Hooks API or the Context API. I think this function shouldn't be burdened to care how theme gets here.

@anicholls anicholls mentioned this pull request Feb 12, 2020
4 tasks
</ComponentStatesTable>
</StaticStates>
));
.add('States', () => <CheckboxStates />)
Copy link
Member

Choose a reason for hiding this comment

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

Story source won't be very useful for these stories, but that is probably okay because we don't expect people to use the source code for these visual stories.

Copy link
Contributor

Choose a reason for hiding this comment

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

yep yep, I think we pulled this out into a variable because StaticStates won't make much sense to someone viewing the source code.

@anicholls anicholls merged commit 9fe884f into Workday:master Feb 13, 2020
@anicholls anicholls deleted the theming-checkbox branch February 13, 2020 00:03
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.

3 participants