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

Nested overrides playground #3940

Merged
merged 5 commits into from Nov 19, 2020
Merged

Nested overrides playground #3940

merged 5 commits into from Nov 19, 2020

Conversation

tajo
Copy link
Member

@tajo tajo commented Nov 19, 2020

This PR adds support for nested overrides into our interactive playground and makes the whole UI more condensed:

Screen Shot 2020-11-19 at 1 29 16 PM

Features

  • It works recursively, so it should work even for most complex cases.
  • Accordion now uses the stateless version that's always in sync with the code snippet. For example if you delete an override, it will close the related tree branch in the playground. This was buggy before because we had only stateful accordion.
  • There is a nested tooltip you can hover over and get more info.
  • It is very easy to configure this for each component (this PR updates only Select -> Tag to demo it).
overrides: {
  custom: {
    names: [
      'Root',
      TagConfig,

Before, the names could be only strings. Now, it can be also a component configuration to represent the nested override.

  • Default style object for override now omits return {} to limit code nesting (as you can see in the screenshot). There was actually a bug in @babel/generator that did not correctly parenthesized returning object of the arrow function () => ({}) and resulted in syntax error. Fortunately, it was recently fixed so that's the only reason why react-view needed to be bumped.

@tajo tajo added the docs label Nov 19, 2020
@vercel
Copy link

vercel bot commented Nov 19, 2020

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/uber-ui-platform/baseweb/lvaumb46b
✅ Preview: https://baseweb-git-nested-overrides.uber-ui-platform.vercel.app

@codesandbox-ci
Copy link

codesandbox-ci bot commented Nov 19, 2020

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 6c149a0:

Sandbox Source
Basic usage Configuration

@tajo tajo marked this pull request as ready for review November 19, 2020 21:49
@tajo tajo changed the title WIP: Nested overrides playground Nested overrides playground Nov 19, 2020
Copy link
Collaborator

@chasestarr chasestarr left a comment

Choose a reason for hiding this comment

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

Works well for this particular nested override. Feel free to ignore the comment I made until a later pr

{overrideKey}
{nested ? (
<NestedTooltip
name={componentName}
Copy link
Collaborator

Choose a reason for hiding this comment

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

There are some nested overrides that don't have the same key as the component name. For example there are multiple 'Select' components in the datepicker. May need to add some key value pair in the config file

https://github.com/uber/baseweb/blob/master/src/datepicker/types.js#L29

Copy link
Member Author

Choose a reason for hiding this comment

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

for that case it should be enough to do

overrides: {
  custom: {
    names: [
      'Root',
      {...TagConfig, componentName: 'TagRenamed' }

if not, will come up with some different fix later

@tajo tajo merged commit a0cb5d2 into master Nov 19, 2020
@tajo tajo deleted the nested-overrides branch November 19, 2020 22:51
@gergelyke
Copy link
Contributor

this is really cool 👏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants