Skip to content

[Maps] EUI Visual Refresh Integration#204434

Merged
cqliu1 merged 9 commits intoelastic:mainfrom
cqliu1:borealis/maps/replace-euiThemeVars
Jan 23, 2025
Merged

[Maps] EUI Visual Refresh Integration#204434
cqliu1 merged 9 commits intoelastic:mainfrom
cqliu1:borealis/maps/replace-euiThemeVars

Conversation

@cqliu1
Copy link
Copy Markdown
Contributor

@cqliu1 cqliu1 commented Dec 16, 2024

Summary

Related to #203132.
Closes #204591.

This replaces all references to euiThemeVars in favor of the useEuiTheme hook in maps.

Checklist

Check the PR satisfies following conditions.

Reviewers should verify this PR satisfies this list as well.

  • Any text added follows EUI's writing guidelines, uses sentence case text and includes i18n support
  • Documentation was added for features that require explanation or tutorials
  • Unit or functional tests were updated or added to match the most common scenarios
  • If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the docker list
  • This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The release_note:breaking label should be applied in these situations.
  • Flaky Test Runner was used on any tests changed
  • The PR description includes the appropriate Release Notes section, and the correct release_note:* label is applied per the guidelines

Identify risks

Does this PR introduce any risks? For example, consider risks like hard to test bugs, performance regression, potential of data loss.

Describe the risk, its severity, and mitigation for each identified risk. Invite stakeholders and evaluate how to proceed before merging.

@cqliu1 cqliu1 changed the title [Maps][Borealis] Replace euiThemeVars usage [Maps] EUI Visual Refresh Dec 17, 2024
@cqliu1 cqliu1 changed the title [Maps] EUI Visual Refresh [Maps] EUI Visual Refresh Integration Dec 17, 2024
@cqliu1 cqliu1 marked this pull request as ready for review December 18, 2024 05:20
@cqliu1 cqliu1 requested a review from a team as a code owner December 18, 2024 05:20
@cqliu1 cqliu1 added Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas t// v9.0.0 Feature:Maps EUI Visual Refresh labels Dec 18, 2024
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/kibana-presentation (Team:Presentation)

@cqliu1 cqliu1 added release_note:skip Skip the PR/issue when compiling release notes backport:version Backport to applied version labels labels Dec 18, 2024
@nreese nreese self-requested a review December 18, 2024 14:39
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.

circleStyle is defined in props but never used in props.

Copy link
Copy Markdown
Contributor

@nreese nreese left a comment

Choose a reason for hiding this comment

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

I am not sure about the direction where EUI themes are only available in a react component. There are times when we need access to EUI themes outside of a react component. For example, to get hex codes to pass to map-libre. I think we need to loop in @elastic/kibana-design and have a discussion about their plans to deprecate euiThemeVars as this will not work for maps and external libraries like maplibre.

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.

How about removing circleStyle const here

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.

Fyi, we realized that there are usages where a non-react way to get theme tokens are still required.
We'll not deprecate it completely, but we deprecate it for react components where euiTheme should be used.

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.

Then use circleStyle from props here.

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.

Now that MasksByFieldOrigin is a react component, how about moving it into a separate file?

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.

Looks like euiTheme is unused

Copy link
Copy Markdown
Contributor

@nreese nreese Dec 18, 2024

Choose a reason for hiding this comment

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

'textSubdued' is not going to work. This value is passed to maplibre for rendering and must be a hex value. For example, this is what a map looks like with a value of 'textSubdued'. The reason being is that OTHER_CATEGORY_DEFAULT_COLOR_TOKEN is used to create a maplibre expression. The expression is invalid with a value of 'textSubdued' so maplibre does not include the expression and all styling is lost.

Screenshot 2024-12-18 at 7 54 00 AM

When instead, it should look like this
Screenshot 2024-12-18 at 7 55 18 AM

@ryankeairns
Copy link
Copy Markdown
Contributor

I am not sure about the direction where EUI themes are only available in a react component. There are times when we need access to EUI themes outside of a react component. For example, to get hex codes to pass to map-libre. I think we need to loop in @elastic/kibana-design and have a discussion about their plans to deprecate euiThemeVars as this will not work for maps and external libraries like maplibre.

This should loop in @elastic/eui-team

@cqliu1 cqliu1 force-pushed the borealis/maps/replace-euiThemeVars branch 2 times, most recently from 3a25a3c to 0c4e9a4 Compare January 6, 2025 19:52
@cqliu1 cqliu1 added backport:skip This PR does not require backporting and removed backport:version Backport to applied version labels labels Jan 7, 2025
@cqliu1 cqliu1 force-pushed the borealis/maps/replace-euiThemeVars branch from 61f662d to 59afe56 Compare January 8, 2025 22:26
@cqliu1 cqliu1 force-pushed the borealis/maps/replace-euiThemeVars branch from 189fe21 to 51ebf31 Compare January 17, 2025 01:23
@cqliu1 cqliu1 requested review from a team as code owners January 17, 2025 19:03
@cqliu1 cqliu1 removed request for a team, gergoabraham, hop-dev and parkiino January 17, 2025 20:28
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.

@nreese Is it okay if we just hard code this color hex for the default other category color? It looks fine in both light and dark mode, and otherwise the user can change the color if they're not happy with it. Then we can avoid the huge refactor necessary to access euiTheme from parts of maps that aren't in React.
Screenshot 2025-01-17 at 12 40 19 PM
Screenshot 2025-01-17 at 12 42 20 PM

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.

Using a static value is ok. How about using #cad3e2, its the current value for euiThemeVars.euiColorLightShade. #516381 is very dark with dark themed tiles.

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.

Sure thing, here's how #cad3e2 looks in light and dark mode
Screenshot 2025-01-21 at 8 23 15 AM
Screenshot 2025-01-21 at 8 24 03 AM

@cqliu1 cqliu1 requested review from a team as code owners January 21, 2025 16:27
[CI] Auto-commit changed files from 'node scripts/yarn_deduplicate'

Fix jest tests

BROKEN

Switch to euiThemeGetColor

[CI] Auto-commit changed files from 'node scripts/eslint --no-cache --fix'

Remove vector layer changes

Remove console log

Undo default map changes

[CI] Auto-commit changed files from 'node scripts/yarn_deduplicate'

fix tsconfig

Remove vector layer changes

Fix types

[CI] Auto-commit changed files from 'node scripts/yarn_deduplicate'

Fix tests

Change other category swatches

Change category swatches
);

useEffect(() => {
mapSettings$.next({
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.

Re-setting backgroundColor removes user selected background color.

To view problem

  1. create a new map
  2. remove baselayer
  3. add EMS boundaries world country layer.
  4. Clicking "settings" in map top nave and provide a background color.
  5. add map to dashboard, save dashboard.
  6. re-open dashboard. Notice how custom background color is removed.

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.

Oh yeah I'll remove this bit of code. I opted to make the default background color transparent instead of having to pass an EUI color into the default map settings object, which also fixes the white flash that you see on some maps in dark mode.

return {
api,
Component: () => {
const { euiTheme } = useEuiTheme();
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.

euiTheme can be removed since its no longer used.

@elasticmachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
maps 1276 1277 +1

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
maps 3.1MB 3.1MB +273.0B

History

Copy link
Copy Markdown
Contributor

@nreese nreese left a comment

Choose a reason for hiding this comment

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

kibana-presentation changes LGTM. Thanks for removing euiThemes from maps
code review, tested in chrome

Copy link
Copy Markdown
Contributor

@andreadelrio andreadelrio left a comment

Choose a reason for hiding this comment

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

LGTM

@kibanamachine
Copy link
Copy Markdown
Contributor

Starting backport for target branches: 8.x

https://github.com/elastic/kibana/actions/runs/12939436185

@kibanamachine
Copy link
Copy Markdown
Contributor

💚 All backports created successfully

Status Branch Result
8.x

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:version Backport to applied version labels EUI Visual Refresh Feature:Maps release_note:skip Skip the PR/issue when compiling release notes Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas t// v8.18.0 v9.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Maps] EUI Visual Refresh Integration and QA

7 participants