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

refactor(wordcloud): cleanup config, types and theming (#1358) #1407

Merged
merged 7 commits into from
Dec 15, 2021

Conversation

nickofthyme
Copy link
Collaborator

Summary

Refactor wordcloud spec to cleanup duplicate or unused config and types.

BREAKING CHANGES

The WorkcloudSpec.config prop is removed as it was not used other than assigning margins even with erroneous properties. All wordcloud properties are now driven from the WorkcloudSpec directly. Since the wordcloud is unique in that it's styles are driven by the data I think keeping them on the spec is more favorable than moving them to the theme as they would be overridden more frequently. This does not provide a themed instance of the chart type but this could possibly come from .brightening the provided colors of the text elements.

Changes include

  • WorkcloudSpec.margin deleted in favor of Theme.chartMargins.
  • WorkcloudConfigs is removed in favor of singular WordcloudViewModel type which is extended to form WordcloudSpec.

Details

Applies #1358 to master

Other Changes:

  • Word types are refined to reflect the mutating nature of d3TagCloud function.
  • Added vrt screenshots to test template variations in story.
  • Cleaned up wordcloud story.
  • Added typings for d3-cloud

Checklist

  • The proper chart type label has been added (e.g. :xy, :partition)
  • The proper feature labels have been added (e.g. :interactions, :axis)
  • The :theme label has been added and the @elastic/eui-design team has been pinged when there are Theme API changes
  • All related issues have been linked (i.e. closes #123, fixes #123)
  • New public API exports have been added to packages/charts/src/index.ts
  • Unit tests have been added or updated to match the most common scenarios
  • The proper documentation and/or storybook story has been added or updated
  • The code has been checked for cross-browser compatibility (Chrome, Firefox, Safari, Edge)
  • Visual changes have been tested with all available themes including dark, light, eui-dark & eui-light

BREAKING CHANGES:

The `WorkcloudSpec.config` prop is removed as it was not used other than assigning `margins` even with erroneous properties. All wordcloud properties are now driven from the `WorkcloudSpec` directly. Since the wordcloud is unique in that it's styles are driven by the data I think keeping them on the spec is more favorable than moving them to the theme as they would be overridden more frequently. This does not provide a themed instance of the chart type but this could possibly come from `.brightening` the provided colors of the text elements.

Changes include

- `WorkcloudSpec.margin` deleted in favor of `Theme.chartMargins`.
- `WorkcloudConfigs` is removed in favor of singular `WordcloudViewModel` type which is extended to form `WordcloudSpec`.
@nickofthyme nickofthyme added :styling Styling related issue :theme :wordcloud Wordcloud related issues breaking change labels Sep 23, 2021
@@ -1,4 +1,5 @@
@import '~@elastic/eui/dist/eui_theme_light';
@import '~@elastic/charts/src/theme_light';
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is recommended by EUI team to fix base styles. Causing changes to integration/tests/__image_snapshots__/interactions-test-ts-interactions-tooltips-should-render-current-tooltip-in-dark-theme-1-snap.png.

Copy link
Member

Choose a reason for hiding this comment

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

In the screenshot, it looks like it's using the light theme tooltip color instead of the dark one.
There is also another difference: this is not the same result as it appear on storybook (in storybook the tooltip bg color is black, not dark gray)

Copy link
Member

Choose a reason for hiding this comment

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

@nickofthyme before merging please check my comment above

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah this is not the right fix for this. I reverted this in e20aece and will pickup this fix in #1463.

Copy link
Contributor

@monfera monfera left a comment

Choose a reason for hiding this comment

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

LGTM, read through the code and still like the code noise removals ✂️

Comment on lines +64 to +66
const getTemplate = (name: string): WordcloudKnobs => {
switch (name) {
case 'single':
Copy link
Member

Choose a reason for hiding this comment

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

What is the benefit of changing this to a function?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

easier typing but yeah doesn't really make much difference.

@@ -1,4 +1,5 @@
@import '~@elastic/eui/dist/eui_theme_light';
@import '~@elastic/charts/src/theme_light';
Copy link
Member

Choose a reason for hiding this comment

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

In the screenshot, it looks like it's using the light theme tooltip color instead of the dark one.
There is also another difference: this is not the same result as it appear on storybook (in storybook the tooltip bg color is black, not dark gray)

@nickofthyme
Copy link
Collaborator Author

@elasticmachine merge upstream

@nickofthyme nickofthyme enabled auto-merge (squash) December 15, 2021 22:09
@nickofthyme nickofthyme requested a review from markov00 December 15, 2021 22:09
@nickofthyme nickofthyme merged commit 41894a6 into elastic:master Dec 15, 2021
@nickofthyme nickofthyme deleted the wordcloud-theming branch December 15, 2021 22:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change :styling Styling related issue :theme :wordcloud Wordcloud related issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants