Skip to content

EuiAccordion convert Sass to Emotion CSS#5826

Merged
1Copenut merged 22 commits intoelastic:mainfrom
1Copenut:feature/tpierce-eui-accordion-emotion
May 17, 2022
Merged

EuiAccordion convert Sass to Emotion CSS#5826
1Copenut merged 22 commits intoelastic:mainfrom
1Copenut:feature/tpierce-eui-accordion-emotion

Conversation

@1Copenut
Copy link
Copy Markdown
Contributor

@1Copenut 1Copenut commented Apr 20, 2022

Summary

PR to move EuiAccordion to Emotion CSS. This is dependent on @cchaos work on font-size and line-height. I'll add those items as they're ready.

I'm opting to remove the breaking change label. We've decided to hold off refactoring the accordion in form work to another PR:

I could use a hand from reviewers to determine if this is still a breaking change. My hunch is no, because the work for EuiAccordion as part of a form has been walked back and will be a separate PR.

#5826 (comment)


Checklist

  • Checked in both light and dark modes
  • Checked in mobile
  • Checked in Chrome, Safari, Edge, and Firefox
  • Props have proper autodocs and playground toggles
  • Added documentation
  • Checked Code Sandbox works for any docs examples
  • Added or updated jest and cypress tests
  • Checked for breaking changes and labeled appropriately
  • Checked for accessibility including keyboard-only and screenreader modes
  • Updated the Figma library counterpart
  • A changelog entry exists and is marked appropriately

1Copenut added 2 commits April 20, 2022 15:07
* Fixed the WithEuiTheme HOC export TypeScript errors.
* Refactoring Emotion to exports for relevant tags.
* Adding named export for child wrapper.
* Moving last stateful CSS to Emotion before adding padding prop.
* Adding last Emotion styles using paddingSize prop.
* Small refactoring of types before updating tests.

WIP. Need to add TS props for passing builds.
@1Copenut 1Copenut self-assigned this Apr 20, 2022
@kibanamachine
Copy link
Copy Markdown

Preview documentation changes for this PR: https://eui.elastic.co/pr_5826/

@kibanamachine
Copy link
Copy Markdown

Preview documentation changes for this PR: https://eui.elastic.co/pr_5826/

1 similar comment
@kibanamachine
Copy link
Copy Markdown

Preview documentation changes for this PR: https://eui.elastic.co/pr_5826/

@1Copenut 1Copenut added the breaking change PRs with breaking changes. (Don't delete - used for automation) label Apr 21, 2022
@kibanamachine
Copy link
Copy Markdown

Preview documentation changes for this PR: https://eui.elastic.co/pr_5826/

@1Copenut 1Copenut marked this pull request as ready for review April 26, 2022 18:44
@1Copenut 1Copenut changed the title [WIP] EuiAccordion convert Sass to Emotion CSS EuiAccordion convert Sass to Emotion CSS Apr 26, 2022
@1Copenut
Copy link
Copy Markdown
Contributor Author

I could use a hand from reviewers to determine if this is still a breaking change. My hunch is no, because the work for EuiAccordion as part of a form has been walked back and will be a separate PR.

@kibanamachine
Copy link
Copy Markdown

Preview documentation changes for this PR: https://eui.elastic.co/pr_5826/

Copy link
Copy Markdown
Contributor

@cchaos cchaos left a comment

Choose a reason for hiding this comment

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

Something has gone wrong with the Playground 😬
Screen Shot 2022-04-26 at 16 08 02 PM

@kibanamachine
Copy link
Copy Markdown

Preview documentation changes for this PR: https://eui.elastic.co/pr_5826/

@thompsongl
Copy link
Copy Markdown
Contributor

Something has gone wrong with the Playground

@1Copenut I'll look into this

@1Copenut
Copy link
Copy Markdown
Contributor Author

Something has gone wrong with the Playground

@1Copenut I'll look into this

@thompsongl There were two errors initially. I figured out the ID issue by adding a prop type to the accordion playground.js file:

propsToUse.id = {
  ...propsToUse.id,
  value: htmlIdGenerator('generated')(),
+ type: PropTypes.String,
};

The other I have no goodly idea.

@1Copenut 1Copenut requested a review from cchaos April 27, 2022 20:23
@kibanamachine
Copy link
Copy Markdown

Preview documentation changes for this PR: https://eui.elastic.co/pr_5826/

@kibanamachine
Copy link
Copy Markdown

Preview documentation changes for this PR: https://eui.elastic.co/pr_5826/

Copy link
Copy Markdown
Contributor

@cchaos cchaos left a comment

Choose a reason for hiding this comment

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

Playground

One oddness I'm trying to understand is that while in the Playground, when toggling isLoading to true, the spinner never shows up (even though it works fine in the docs). This isn't unique to this PR as it occurs in production. However, the difference I am seeing between prod and this PR is that when isLoading=true and arrowDisplay="none" I'm still seeing the arrow:

This PR
Screen Shot 2022-04-28 at 14 42 49 PM

Prod
Screen Shot 2022-04-28 at 14 42 59 PM


Snapshot

I feel strongly that we should fix this before we merge this PR, but the snapshots are rendering the entire JSON output of the theme.

Snippet
exports[`EuiAccordion behavior closes when clicked twice 1`] = `
<WithEuiTheme(EuiAccordionClass)
  id="18"
>
  <EuiAccordionClass
    arrowDisplay="left"
    buttonElement="button"
    element="div"
    id="18"
    initialIsOpen={false}
    isLoading={false}
    isLoadingMessage={false}
    paddingSize="none"
    theme={
      Object {
        "colorMode": "LIGHT",
        "euiTheme": Object {
          "animation": Object {
            "bounce": "cubic-bezier(.34, 1.61, .7, 1)",
            "extraFast": "90ms",
            "extraSlow": "500ms",
            "fast": "150ms",
            "normal": "250ms",
            "resistance": "cubic-bezier(.694, .0482, .335, 1)",
            "slow": "350ms",
          },
          "base": 16,
          "border": Object {
            "color": "#D3DAE6",
            "editable": "2px dotted #D3DAE6",
            "radius": Object {
              "medium": "6px",
              "small": "4px",
            },
            "thick": "2px solid #D3DAE6",
            "thin": "1px solid #D3DAE6",
            "width": Object {
              "thick": "2px",
              "thin": "1px",
            },
          },

Styles based on props

Lastly, we should really only be doing the prop checking in the component TSX. The styles should purely be key: css pairs where key is the value of the prop (like the paddingSize one). See this section of the wiki: https://github.com/elastic/eui/blob/main/wiki/writing-styles-with-emotion.md#component-props-that-enable-styles

@kibanamachine
Copy link
Copy Markdown

Preview documentation changes for this PR: https://eui.elastic.co/pr_5826/

@kibanamachine
Copy link
Copy Markdown

Preview documentation changes for this PR: https://eui.elastic.co/pr_5826/

@kibanamachine
Copy link
Copy Markdown

Preview documentation changes for this PR: https://eui.elastic.co/pr_5826/

@1Copenut
Copy link
Copy Markdown
Contributor Author

1Copenut commented May 9, 2022

@cchaos I confirmed the loading spinner is working on localhost playground if I toggle isLoading and add a a string like "Loading" to the isLoadingMessage prop box.


Screen Shot 2022-05-09 at 4 26 47 PM

@1Copenut 1Copenut requested a review from cchaos May 9, 2022 21:30
@cchaos
Copy link
Copy Markdown
Contributor

cchaos commented May 10, 2022

@1Copenut I've located the isLoading problem to the fact that it does nothing unless extraAction or isLoadingMessage is defined. It seems this logic is in place in production right now so it's not related to this PR specifically. However, it may be a nice chance to quickly change the logic so that no matter the state of extraAction if isLoading=true you'll always see the loading spinner. Right now simply adding isLoading=true to a basic instance does nothing.

@1Copenut 1Copenut removed the breaking change PRs with breaking changes. (Don't delete - used for automation) label May 10, 2022
@1Copenut
Copy link
Copy Markdown
Contributor Author

@cchaos Logged the request to simplify loading prop logic in #5893. Looking at the code, it was going to be slightly more involved than I first thought. Capturing your comment so I can pick it up again tomorrow.

Copy link
Copy Markdown
Contributor

@cchaos cchaos left a comment

Choose a reason for hiding this comment

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

Design code LGTM (one tiny suggestion). I double checked any effects on EuiCollapsibleNavGroup and EuiNotificationEvent as well.

Worth getting an eng to look over the class stuff.

Comment on lines +99 to +102
euiAccordion__spinner: css``,
isLoading: css`
margin-right: ${euiTheme.size.xs};
`,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: the spinner only shows up when isLoading is true, so there's no need for this qualifier, it can just be applied directly to the base selector.

Suggested change
euiAccordion__spinner: css``,
isLoading: css`
margin-right: ${euiTheme.size.xs};
`,
euiAccordion__spinner: css`
margin-right: ${euiTheme.size.xs};
`,

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.

Thanks Caroline. Change made and snapshot updated.

@kibanamachine
Copy link
Copy Markdown

Preview documentation changes for this PR: https://eui.elastic.co/pr_5826/

@cchaos cchaos added this to the Elastic Stack 8.4 milestone May 16, 2022
@cchaos
Copy link
Copy Markdown
Contributor

cchaos commented May 16, 2022

I'm pushing this PR off to Stack 8.4 release because I know that changes to EuiAccordion in the past have caused consumers grief. So I worry about this one so close to 8.3 FF.

Copy link
Copy Markdown
Contributor

@thompsongl thompsongl left a comment

Choose a reason for hiding this comment

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

Code changes LGTM

I'm pushing this PR off to Stack 8.4 release because I know that changes to EuiAccordion in the past have caused consumers grief. So I worry about this one so close to 8.3 FF.

Probably safe to merge this. v57 is the last one going into 8.3, and any backports won't include the changes here. But feel free to wait til next week if you want.

Copy link
Copy Markdown
Contributor

@breehall breehall left a comment

Choose a reason for hiding this comment

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

This looks good to me! Great work on this Trevor!

@1Copenut 1Copenut merged commit 922a789 into elastic:main May 17, 2022
@1Copenut 1Copenut deleted the feature/tpierce-eui-accordion-emotion branch May 17, 2022 19:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants