forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SharedUX] Modify code editor theme definition and resolution impleme…
…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 <eksomail@gmail.com> Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
- Loading branch information
1 parent
44c130c
commit 61bde76
Showing
30 changed files
with
340 additions
and
244 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.