Skip to content

[experiment] Adaptive Illustrations for themes and color modes #206540

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

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

clintandrewhall
Copy link
Contributor

@clintandrewhall clintandrewhall commented Jan 14, 2025

For any given illustration in Kibana, we maintain two discrete files: one for light mode, and one for dark mode. With the introduction of the Borealis theme, we would theoretically need to maintain four versions of each illustration.

By using CSS variables with appropriate fallbacks embedded in a single SVG, we can adapt the colors of the SVG to both the theme and color mode of Kibana. This will allow us to reduce the number of SVGs we need to maintain, and provide a more consistent UX between themes and color modes.

svg-diff

This is a proof-of-concept which uses a single SVG file and a JSON file of tokens and their color values. These are both read by a React component-- `Illustration`-- which compiles the color profile and adds the SVG to the DOM.

Demo and Docs

Storybook: Adaptive Illustrations
Documentation: Adaptive Illustrations writeup

To try the demo, you can view the Storybook built with this PR.

You can also check out this PR and run the Storybook locally:

gh pr checkout 206540
yarn kbn bootstrap
yarn storybook shared_ux

@clintandrewhall clintandrewhall added Team:Platform-Design Team Label for Kibana Design Team. Support the Analyze group of plugins. WIP Work in progress release_note:skip Skip the PR/issue when compiling release notes EUI backport:skip This commit does not require backporting Team:SharedUX Team label for AppEx-SharedUX (formerly Global Experience) ci:build-storybooks labels Jan 14, 2025
@elasticmachine
Copy link
Contributor

elasticmachine commented Jan 14, 2025

🤖 Jobs for this PR can be triggered through checkboxes. 🚧

ℹ️ To trigger the CI, please tick the checkbox below 👇

  • Click to trigger kibana-pull-request for this PR!
  • Click to trigger kibana-deploy-project-from-pr for this PR!

@clintandrewhall clintandrewhall force-pushed the experiments/adaptive-illustrations branch from 829e3b9 to 803ec26 Compare January 14, 2025 06:21
@JasonStoltz
Copy link
Member

CC @ryankeairns @elastic/eui-team

@JasonStoltz
Copy link
Member

JasonStoltz commented Jan 14, 2025

<Removed this comment, Clint posted a link to the doc below>

@clintandrewhall
Copy link
Contributor Author

@JasonStoltz Yeah, I had to wait for CI to complete the Storybook build before I could post the link to the doc.

@JasonStoltz
Copy link
Member

JasonStoltz commented Jan 14, 2025

I like this. It solves some problems:

  • Since source of truth for SVGs, they wouldn't be copy/pasted around the codebase. Much easier to find.
  • They naturally adapt as we tweak the theme -- no need to recreate every SVG every time we touch a theme color.
  • Not maintaining 4 variations of a single SVG

Questions or challenges I see:

  • How hard will it actually be to go through each SVG and manually replace the hardcoded values with CSS variables? Are there some cases where it could be really tricky?
  • What if a designer needs to tweak an SVG? Once it's converted to use CSS variables, I guess it can't really go back to the design tool for edits.

@clintandrewhall
Copy link
Contributor Author

How hard will it actually be to go through each SVG and manually replace the hardcoded values with CSS variables? Are there some cases where it could be really tricky?

I did a quick RegEx find-and-replace with both of these SVGs. The toughest part was figuring out the color changes, rather than replacing fill= with style=.

What if a designer needs to tweak an SVG?

I think we can just tweak the source-- I assume there's an Adobe Illustrator file or similar somewhere-- but we could just as easily write a script to convert back and forth between fill and style.

We could always keep both formats: one as source SVG, one as Kibana web-adaptable SVG...?

@eokoneyo
Copy link
Contributor

How hard will it actually be to go through each SVG and manually replace the hardcoded values with CSS variables? Are there some cases where it could be really tricky?

I did a quick RegEx find-and-replace with both of these SVGs. The toughest part was figuring out the color changes, rather than replacing fill= with style=.

What if a designer needs to tweak an SVG?

I think we can just tweak the source-- I assume there's an Adobe Illustrator file or similar somewhere-- but we could just as easily write a script to convert back and forth between fill and style.

We could always keep both formats: one as source SVG, one as Kibana web-adaptable SVG...?

  • How hard will it actually be to go through each SVG and manually replace the hardcoded values with CSS variables? Are there some cases where it could be really tricky?
  • What if a designer needs to tweak an SVG? Once it's converted to use CSS variables, I guess it can't really go back to the design tool for edits.

with regards to the point about manually replacing hardcoded values, ideally we could consider some util that transforms regular svgs to "kibana web adaptable svg". If we are able to make something of this sort, then the questions pertaining to making a regular SVG into our "adaptable SVG", alongside accommodating tweaks after it already exists as an adaptable SVG sort of goes away, really it's the heuristics for generating the customization points and having it be meaningful that would then be what we'd have to agree on.

clintandrewhall added a commit that referenced this pull request Jan 15, 2025
## Summary

After a CI run, Storybooks are built. Each commit is built and uploaded
separately, which makes sense:


https://github.com/elastic/kibana/blob/main/.buildkite/scripts/steps/storybooks/build_and_upload.ts#L24

Unfortunately, we don't have a way to consistently point to main, or to
a PR.

## PRs

Using #206540 as an example, the
Storybook is currently hosted at:


https://ci-artifacts.kibana.dev/storybooks/pr-206540/803ec26fb200e1fd23c33ead174dcc5356262cfc

This means that, if I push another commit, the URL will change... so all
of the links I've posted in Slack are now invalid. This PR changes the
URL so it will remain:

https://ci-artifacts.kibana.dev/storybooks/pr-206540

regardless of how many commits I push.

## `main`

Furthermore, being able to visit
https://ci-artifacts.kibana.dev/storybooks/main/latest/index.html to see
the most recent Storybook build is awesome. The issue is each Storybook
is hosted with that same hash:


https://ci-artifacts.kibana.dev/storybooks/main/5ad3ef7b0a76968a31b0824bd08f9132c374c841/shared_ux/index.html

So this PR alters the URL so you can consistently point to the latest
Storybook build:

https://ci-artifacts.kibana.dev/storybooks/main/shared_ux/index.html
viduni94 pushed a commit to viduni94/kibana that referenced this pull request Jan 23, 2025
## Summary

After a CI run, Storybooks are built. Each commit is built and uploaded
separately, which makes sense:


https://github.com/elastic/kibana/blob/main/.buildkite/scripts/steps/storybooks/build_and_upload.ts#L24

Unfortunately, we don't have a way to consistently point to main, or to
a PR.

## PRs

Using elastic#206540 as an example, the
Storybook is currently hosted at:


https://ci-artifacts.kibana.dev/storybooks/pr-206540/803ec26fb200e1fd23c33ead174dcc5356262cfc

This means that, if I push another commit, the URL will change... so all
of the links I've posted in Slack are now invalid. This PR changes the
URL so it will remain:

https://ci-artifacts.kibana.dev/storybooks/pr-206540

regardless of how many commits I push.

## `main`

Furthermore, being able to visit
https://ci-artifacts.kibana.dev/storybooks/main/latest/index.html to see
the most recent Storybook build is awesome. The issue is each Storybook
is hosted with that same hash:


https://ci-artifacts.kibana.dev/storybooks/main/5ad3ef7b0a76968a31b0824bd08f9132c374c841/shared_ux/index.html

So this PR alters the URL so you can consistently point to the latest
Storybook build:

https://ci-artifacts.kibana.dev/storybooks/main/shared_ux/index.html
@clintandrewhall clintandrewhall linked an issue May 29, 2025 that may be closed by this pull request
@kibanamachine kibanamachine requested a review from a team June 16, 2025 13:25
@clintandrewhall
Copy link
Contributor Author

/ci

@elasticmachine
Copy link
Contributor

elasticmachine commented Jun 16, 2025

💔 Build Failed

Failed CI Steps

History

cc @eokoneyo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting ci:build-storybooks EUI release_note:skip Skip the PR/issue when compiling release notes Team:Platform-Design Team Label for Kibana Design Team. Support the Analyze group of plugins. Team:SharedUX Team label for AppEx-SharedUX (formerly Global Experience) WIP Work in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Horizon] Theme-adaptive Illustrations
4 participants