-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[SharedUX] Modify code editor theme definition and resolution implementation to account for color modes in EUI Theme #203337
Conversation
* Register custom themes | ||
*/ | ||
registerTheme(ESQL_LIGHT_THEME_ID, buildESQLTheme({ darkMode: false })); | ||
registerTheme(ESQL_DARK_THEME_ID, buildESQLTheme({ darkMode: true })); | ||
registerTheme(CONSOLE_THEME_ID, buildConsoleTheme()); | ||
registerTheme(CODE_EDITOR_LIGHT_THEME_ID, buildLightTheme()); | ||
registerTheme(CODE_EDITOR_DARK_THEME_ID, buildDarkTheme()); | ||
registerTheme(CODE_EDITOR_LIGHT_THEME_TRANSPARENT_ID, buildLightTransparentTheme()); | ||
registerTheme(CODE_EDITOR_DARK_THEME_TRANSPARENT_ID, buildDarkTransparentTheme()); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of this is now handled in the actual component implementation of the code editor, see https://github.com/elastic/kibana/pull/203337/files#diff-21b735fba0b5df628e2664a3605f8401d082a4eb32ab0b1ede5fae2db5251030R177-R193
export const CODE_EDITOR_LIGHT_THEME_ID = 'codeEditorLightTheme'; | ||
export const CODE_EDITOR_DARK_THEME_ID = 'codeEditorDarkTheme'; | ||
export const CODE_EDITOR_LIGHT_THEME_TRANSPARENT_ID = 'codeEditorLightTransparentTheme'; | ||
export const CODE_EDITOR_DARK_THEME_TRANSPARENT_ID = 'codeEditorDarkTransparentTheme'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no need for light and dark variations of the same theme anymore, we resolve this automatically now
a4234d4
to
9c0bf5c
Compare
442bd20
to
096c71b
Compare
This comment was marked as outdated.
This comment was marked as outdated.
096c71b
to
f28fb80
Compare
f28fb80
to
fbd5730
Compare
fbd5730
to
cfe6d1d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, it's looking good. But tbh, I was not able to figure out what some "lightestShades"/"emptyShades" etc. legacy colors do there. It's currently allowed to use them afaik, so I guess we can merge like this and figure out later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be just unnecessary (we can have only subdued panel prop, that's all)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
45b7b51
to
e0db868
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codeowner changes look good and appear to work well 🎉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3db0b7a
to
965dc0d
Compare
…ifically opting to override
965dc0d
to
c724ae5
Compare
Hi @stratoula , I took a second look at this, it's true the previous changes made it such that identifiers were colored and not matching the overall text color, and I think with suggestions the colors were wrong, I made some adjustments in b30bc9e that I think should resolve these concerns. Could you help take a second look? |
@eokoneyo thanx, much appreciated. Even from the screenshot I can see that the columns (new or existing) such as the |
Thanks for pointing this out @stratoula. I've resolved this in 3252105, here's how it all looks now. Apologies for the noise. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Except for a small question, now it looks ok to me
I tested this at light dark mode for Amsterdam and Borealis themes. LGTM
💚 Build Succeeded
Metrics [docs]Public APIs missing comments
Async chunks
Page load bundle
Unknown metric groupsAPI count
ESLint disabled line counts
References to deprecated APIs
Total ESLint disabled count
History
cc @eokoneyo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! reviewed the code and smoke checked different editors in light/dark theme
…ntation to account for color modes in EUI Theme (elastic#203337) ## Summary <!-- ### DONT MERGE, THIS PR DEPENDS ON AN UPDATE TO EUI, THAT'S IN FLIGHT --> Closes elastic#202782 This PR reworks how custom themes used within the kibana code editor for the default visual look and ones specific to supported languages are defined to accomodate the upcoming visual refresh, the approach here leverages the `euiTheme` object value returned from the `useEuiTheme` hook, now a single theme declaration is all that is required such that using either the `colorMode `value or the `euiTheme` from the provided `UseEUITheme` value it's possible to craft a theme that's in the context of kIbana, color mode aware and the editor would be able to resolve the appropriate colors depending on the user's color mode. This required some modification to monaco itself; now when defining languages if the `CustomLanguageType` specification is being followed, a function that resolves to a standard monaco theme can be provided on the property `languageThemeResolver` which will be passed the `euiTheme` when registering this theme. It's worth mentioning that this can also be done manually by leveraging the custom method `registerLanguageThemeResolver` added on the monaco editor object, like so ```tsx monaco.editor.registerLanguageThemeResolver(LanguageID, languageThemeResolver); ``` However one should take note that when calling this method directly, the ID passed must correlate to a registered language ID, else the theme will not be available for use after Monaco is initialised, hence the theme name must equal an existing language ID if it's to be used for a specific language. ## How to test - Enable borealis, like so; - in your `kibana.dev.yml` file include the following config; ```yml uiSettings.experimental.themeSwitcherEnabled: true ``` - start kibana using the following command; `KBN_OPTIMIZER_THEMES="borealislight,borealisdark,v8light,v8dark" yarn start --run-examples` - Tryout all downstream of the code editor to ascertain the code editor colors are as should be for both Amsterdam and Borealis; downstreams include; - ES|QL editor, navigate to discover and click the "try ES|QL" button - Dev tools, on clicking the nav hamburger menu under the management menu group there's a menu item that links to all dev tools - Index Management use cases; navigate to stack management, under Index management select any existing index, then navigate to it's settings this should load up the code editor. - Saved Object use case; navigate to stack management, under saved objects attempt inspecting any saved object we'd be presented with the code editor etc. <!-- ### 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](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) 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](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) - [ ] 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](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) 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](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) ### 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. - [ ] [See some risk examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) - [ ] ... --> --------- Co-authored-by: ek-so <[email protected]> Co-authored-by: kibanamachine <[email protected]>
…ntation to account for color modes in EUI Theme (elastic#203337) ## Summary <!-- ### DONT MERGE, THIS PR DEPENDS ON AN UPDATE TO EUI, THAT'S IN FLIGHT --> Closes elastic#202782 This PR reworks how custom themes used within the kibana code editor for the default visual look and ones specific to supported languages are defined to accomodate the upcoming visual refresh, the approach here leverages the `euiTheme` object value returned from the `useEuiTheme` hook, now a single theme declaration is all that is required such that using either the `colorMode `value or the `euiTheme` from the provided `UseEUITheme` value it's possible to craft a theme that's in the context of kIbana, color mode aware and the editor would be able to resolve the appropriate colors depending on the user's color mode. This required some modification to monaco itself; now when defining languages if the `CustomLanguageType` specification is being followed, a function that resolves to a standard monaco theme can be provided on the property `languageThemeResolver` which will be passed the `euiTheme` when registering this theme. It's worth mentioning that this can also be done manually by leveraging the custom method `registerLanguageThemeResolver` added on the monaco editor object, like so ```tsx monaco.editor.registerLanguageThemeResolver(LanguageID, languageThemeResolver); ``` However one should take note that when calling this method directly, the ID passed must correlate to a registered language ID, else the theme will not be available for use after Monaco is initialised, hence the theme name must equal an existing language ID if it's to be used for a specific language. ## How to test - Enable borealis, like so; - in your `kibana.dev.yml` file include the following config; ```yml uiSettings.experimental.themeSwitcherEnabled: true ``` - start kibana using the following command; `KBN_OPTIMIZER_THEMES="borealislight,borealisdark,v8light,v8dark" yarn start --run-examples` - Tryout all downstream of the code editor to ascertain the code editor colors are as should be for both Amsterdam and Borealis; downstreams include; - ES|QL editor, navigate to discover and click the "try ES|QL" button - Dev tools, on clicking the nav hamburger menu under the management menu group there's a menu item that links to all dev tools - Index Management use cases; navigate to stack management, under Index management select any existing index, then navigate to it's settings this should load up the code editor. - Saved Object use case; navigate to stack management, under saved objects attempt inspecting any saved object we'd be presented with the code editor etc. <!-- ### 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](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) 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](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) - [ ] 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](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) 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](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) ### 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. - [ ] [See some risk examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) - [ ] ... --> --------- Co-authored-by: ek-so <[email protected]> Co-authored-by: kibanamachine <[email protected]>
…ntation to account for color modes in EUI Theme (elastic#203337) ## Summary <!-- ### DONT MERGE, THIS PR DEPENDS ON AN UPDATE TO EUI, THAT'S IN FLIGHT --> Closes elastic#202782 This PR reworks how custom themes used within the kibana code editor for the default visual look and ones specific to supported languages are defined to accomodate the upcoming visual refresh, the approach here leverages the `euiTheme` object value returned from the `useEuiTheme` hook, now a single theme declaration is all that is required such that using either the `colorMode `value or the `euiTheme` from the provided `UseEUITheme` value it's possible to craft a theme that's in the context of kIbana, color mode aware and the editor would be able to resolve the appropriate colors depending on the user's color mode. This required some modification to monaco itself; now when defining languages if the `CustomLanguageType` specification is being followed, a function that resolves to a standard monaco theme can be provided on the property `languageThemeResolver` which will be passed the `euiTheme` when registering this theme. It's worth mentioning that this can also be done manually by leveraging the custom method `registerLanguageThemeResolver` added on the monaco editor object, like so ```tsx monaco.editor.registerLanguageThemeResolver(LanguageID, languageThemeResolver); ``` However one should take note that when calling this method directly, the ID passed must correlate to a registered language ID, else the theme will not be available for use after Monaco is initialised, hence the theme name must equal an existing language ID if it's to be used for a specific language. ## How to test - Enable borealis, like so; - in your `kibana.dev.yml` file include the following config; ```yml uiSettings.experimental.themeSwitcherEnabled: true ``` - start kibana using the following command; `KBN_OPTIMIZER_THEMES="borealislight,borealisdark,v8light,v8dark" yarn start --run-examples` - Tryout all downstream of the code editor to ascertain the code editor colors are as should be for both Amsterdam and Borealis; downstreams include; - ES|QL editor, navigate to discover and click the "try ES|QL" button - Dev tools, on clicking the nav hamburger menu under the management menu group there's a menu item that links to all dev tools - Index Management use cases; navigate to stack management, under Index management select any existing index, then navigate to it's settings this should load up the code editor. - Saved Object use case; navigate to stack management, under saved objects attempt inspecting any saved object we'd be presented with the code editor etc. <!-- ### 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](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) 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](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) - [ ] 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](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) 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](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) ### 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. - [ ] [See some risk examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) - [ ] ... --> --------- Co-authored-by: ek-so <[email protected]> Co-authored-by: kibanamachine <[email protected]>
Summary
Closes #202782
This PR reworks how custom themes used within the kibana code editor for the default visual look and ones specific to supported languages are defined to accomodate the upcoming visual refresh, the approach here leverages the
euiTheme
object value returned from theuseEuiTheme
hook, now a single theme declaration is all that is required such that using either thecolorMode
value or theeuiTheme
from the providedUseEUITheme
value it's possible to craft a theme that's in the context of kIbana, color mode aware and the editor would be able to resolve the appropriate colors depending on the user's color mode.This required some modification to monaco itself; now when defining languages if the
CustomLanguageType
specification is being followed, a function that resolves to a standard monaco theme can be provided on the propertylanguageThemeResolver
which will be passed theeuiTheme
when registering this theme. It's worth mentioning that this can also be done manually by leveraging the custom methodregisterLanguageThemeResolver
added on the monaco editor object, like soHowever one should take note that when calling this method directly, the ID passed must correlate to a registered language ID, else the theme will not be available for use after Monaco is initialised, hence the theme name must equal an existing language ID if it's to be used for a specific language.
How to test
kibana.dev.yml
file include the following config;KBN_OPTIMIZER_THEMES="borealislight,borealisdark,v8light,v8dark" yarn start --run-examples