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(heatmap): dark mode with theme controls #1406

Merged
merged 14 commits into from
Dec 15, 2021

Conversation

nickofthyme
Copy link
Collaborator

Summary

Adds dark mode to goal charts with configurable theme styles.

Screen Recording 2021-09-02 at 02 31 07 PM

BREAKING CHANGES

The HeatmapSpec.config prop is removed. All properties have been moved/renamed under new Theme.heatmap options with the following exceptions:

  • HeatmapSpec.margin was not used, Theme.chartMargins should be used in the future.
  • HeatmapSpec.fontFamily HeatmapSpec.width and HeatmapSpec.height all removed as they were never used.

Details

Applies #1356 to master

The Heatmap, Partition and WordCloud specs all have no connection to the chart theme and thus have no canonical inheritance to dark mode. This PR fixes this for the Heatmap chart and adds some added styles to the text labels as exposed in xy charts. The HeatmapConfig was broken down and moved into Theme or the HeatmapSpec accordingly. We should avoid having a Config option to control theme as this not only creates a disconnect but also allows for multiple sources of truth for similar options and another property requirement to toggle for theming between dark and light modes.

In the future I think it would great if we have a Config alternative to the react props in addition to the Theme options.

Issues

closes #1335

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

adds dark mode to goal charts with configurable theme styles.

BREAKING CHANGE:

The `HeatmapSpec.config` prop is removed. All properties have been moved/renamed under new `Theme.heatmap` options with the following exceptions:

- `HeatmapSpec.margin` was not used, `Theme.chartMargins` should be used in the future.
- `HeatmapSpec.fontFamily` `HeatmapSpec.width` and `HeatmapSpec.height` all removed as they were never used.
@nickofthyme nickofthyme added enhancement New feature or request :styling Styling related issue :heatmap Heatmap/Swimlane chart related issue :theme breaking change labels Sep 23, 2021
Comment on lines +234 to +239
heatmap: {
maxRowHeight: 30,
maxColumnWidth: 30,
brushArea: {
visible: true,
stroke: '#D3DAE6', // euiColorLightShade,
Copy link
Contributor

@monfera monfera Sep 29, 2021

Choose a reason for hiding this comment

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

At some point in the future, the longwinded theme object ladders could be farmed out so they're external to src. Their types are already public for external themeability. Worth trying to place them outside src to see if anything balks

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.

The code looks good to me! I'd rely on @rshen91 or @markov00 doing proper smoke testing, due to more familiarity with themes. I made only optional code comments

The dark mocks look unusual in that (likely) low values are very salient white against the black background, another palette would be more appropriate, so our examples look more or less OK.

For the record I'm not a big fan of the gridline-free mock where it's hard to read which row a cell is in.

Also in some next PR the highlight could be fixed (I discussed it with @rshen91 earlier)

Copy link
Member

@markov00 markov00 left a comment

Choose a reason for hiding this comment

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

changes LGTM
We should align and work together with EUI team to introduce the right changes to the theme

Comment on lines +910 to +914
// Warning: (ae-forgotten-export) The symbol "SpecRequiredProps" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "SpecOptionalProps" needs to be exported by the entry point index.d.ts
//
// @alpha (undocumented)
export const Heatmap: React_2.FunctionComponent<Pick<HeatmapSpec, 'id' | 'data' | 'colorScale'> & Partial<Omit<HeatmapSpec, 'chartType' | 'specType' | 'id' | 'data'>>>;
export const Heatmap: React_2.FunctionComponent<SpecRequiredProps_8 & SpecOptionalProps_8>;
Copy link
Member

Choose a reason for hiding this comment

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

not in this PR but we should find a way to express this in the right way

Copy link
Collaborator Author

@nickofthyme nickofthyme Dec 15, 2021

Choose a reason for hiding this comment

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

Could you elaborate what you mean here? Would #1421 solve this?

@rshen91 rshen91 mentioned this pull request Nov 24, 2021
5 tasks
nickofthyme and others added 7 commits December 15, 2021 16:21
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.
@nickofthyme nickofthyme changed the title feat(heatmap): dark mode with theme controls (#1356) feat(heatmap): dark mode with theme controls Dec 15, 2021
@nickofthyme nickofthyme enabled auto-merge (squash) December 15, 2021 23:29
@nickofthyme nickofthyme merged commit f29c8dd into elastic:master Dec 15, 2021
@nickofthyme nickofthyme deleted the heatmap-theming branch December 15, 2021 23:46
nickofthyme pushed a commit that referenced this pull request Dec 17, 2021
# [41.0.0](v40.2.0...v41.0.0) (2021-12-17)

### Bug Fixes

* replace createRef with useRef in Functional Components. ([#1524](#1524)) ([9538417](9538417))

### Code Refactoring

* **goal:** remove deprecated config ([#1408](#1408)) ([312e31d](312e31d))

### Features

* **heatmap:** dark mode with theme controls ([#1406](#1406)) ([f29c8dd](f29c8dd))
* **legend:** custom legend width ([#1467](#1467)) ([51f50df](51f50df))

### BREAKING CHANGES

* **goal:** The `GoalSpec.config` prop is removed. All properties have been moved/renamed under new `Theme.goal` options with the following exceptions:

- `Config.margin` is now controlled by `Theme.chartMargins` and is no longer a margin ratio as before.
- `Config.backgroundColor` is now controlled by `Theme.background.color`, even though it's not yet used.
- `fontFamily` moved into each respective label styles
- `angleStart` and `angleEnd` are moved onto the `GoalSpec` as optional values.
- `sectorLineWidth`, `width` and `height` all removed as they were never used.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change enhancement New feature or request :heatmap Heatmap/Swimlane chart related issue :styling Styling related issue :theme
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Heatmap] visualizations don't adjust color values for dark mode
3 participants