Skip to content

Export props for components#4517

Merged
snide merged 9 commits intoelastic:masterfrom
snide:exportprops
Feb 17, 2021
Merged

Export props for components#4517
snide merged 9 commits intoelastic:masterfrom
snide:exportprops

Conversation

@snide
Copy link
Contributor

@snide snide commented Feb 12, 2021

Summary

Killed some time while waiting on my kids to come home from school. This will need discussion.

While building out doc components I ran into a couple places where the props were not properly exported. I decided to do an audit of what EUI exports and fixed the changes. I also corrected some naming inconsistencies to match our normal patterns (ex: using _EuiSomething for internally referenced props).

Changes

  • Props are now exported for all components down to the dist. This I believe means we can now use import { EuiComponentNameProps } from @elastic/eui/ without reaching into source.

Breaking changes

  • Used EuiComponentNameProps naming schema for all exported props. In less than a dozen instances, we exported them simply as Props. We weren't really exporting these in a lot of cases, but I think it's worthwhile to label this as a breaking change. My guess is this will cause a minor upgrade pain in Kibana/Cloud.

Checklist

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

@cchaos
Copy link
Contributor

cchaos commented Feb 12, 2021

The other thing that I've run into too, if we want to beef up this PR, is that we don't always do the component extensions like extending CommonProps or HTMLAttributes<DivELement> directly in the exported props. I'd like to make that a better pattern too.

@kibanamachine
Copy link

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

@snide
Copy link
Contributor Author

snide commented Feb 12, 2021

@cchaos I'll chat with you next week. I went a little nuts and fixed all the things. Don't worry, I was playing music loud and having fun using vim macros. I'll drink plenty of bourbon tonight to make up for it.

@snide snide added the breaking change PRs with breaking changes. (Don't delete - used for automation) label Feb 12, 2021
@kibanamachine
Copy link

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

@snide
Copy link
Contributor Author

snide commented Feb 13, 2021

jenkins test this

@kibanamachine
Copy link

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

@thompsongl
Copy link
Contributor

_EuiSomething for internally referenced props

I like this idea. It seems like the typical pattern for internal props is to just omit a prefix, which isn't actually very helpful.

@cchaos
Copy link
Contributor

cchaos commented Feb 16, 2021

Same! I've also started doing this with specifically internal JS files by starting them with a leading underscore like _page_docs.tsx.

Copy link
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.

Did a quick scan and LGTM!

Copy link
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.

🙏 Thanks for this!

I think it makes sense to export types for anything in the top-level API, which includes things like EuiHue and EuiSaturation that I thought were internal but aren't.

Comment on lines +21 to +26
export {
EuiColorPickerSwatch,
EuiColorPickerSwatchProps,
} from './color_picker_swatch';
export { EuiHue, EuiHueProps } from './hue';
export { EuiSaturation, EuiSaturationProps } from './saturation';
Copy link
Contributor

Choose a reason for hiding this comment

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

These three are really just internal components. I guess there's on harm in exporting the types, though.

@cchaos cchaos removed the breaking change PRs with breaking changes. (Don't delete - used for automation) label Feb 17, 2021
Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com>
@kibanamachine
Copy link

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

snide and others added 2 commits February 17, 2021 12:02
Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com>
@kibanamachine
Copy link

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

@kibanamachine
Copy link

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

@snide
Copy link
Contributor Author

snide commented Feb 17, 2021

Feedback addressed. Merging.

@snide snide merged commit 015b7cd into elastic:master Feb 17, 2021
@snide snide deleted the exportprops branch February 17, 2021 23:20
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