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.
migrate style overrides from scss to leverage emotion (elastic#204463)
## Summary This PR migrates style overrides within core from SCSS to leverage emotion. Why is this necessary? Kibana builds it's stylesheets we get 4 stylesheets for all the supported themes, in which in turn impacts the files built. Switching to leveraging emotion makes it such that we don't need to build 4 files anymore for this particular cases in turn reducing the page load bundle size. This PR results in ~12% reduction in the page load bundle, that would have come into effect from [the PR](elastic#203840) that introduces the new Borealis theme as a default. The results can be seen in [this build](https://buildkite.com/elastic/kibana-pull-request/builds/260881) <!-- ### 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: Elastic Machine <elasticmachine@users.noreply.github.com>
- Loading branch information
1 parent
96b97b5
commit 3229a92
Showing
8 changed files
with
169 additions
and
141 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
164 changes: 164 additions & 0 deletions
164
packages/core/application/core-application-common/src/global_app_style.tsx
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the "Elastic License | ||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
* Public License v 1"; you may not use this file except in compliance with, at | ||
* your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
* License v3.0 only", or the "Server Side Public License, v 1". | ||
*/ | ||
|
||
import React from 'react'; | ||
import { css, Global } from '@emotion/react'; | ||
import { useEuiTheme, type UseEuiTheme } from '@elastic/eui'; | ||
|
||
export const renderingOverrides = (euiTheme: UseEuiTheme['euiTheme']) => css` | ||
#kibana-body { | ||
// DO NOT ADD ANY OVERFLOW BEHAVIORS HERE | ||
// It will break the sticky navigation | ||
min-height: 100%; | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
// Affixes a div to restrict the position of charts tooltip to the visible viewport minus the header | ||
#app-fixed-viewport { | ||
pointer-events: none; | ||
visibility: hidden; | ||
position: fixed; | ||
top: var(--kbnAppHeadersOffset, var(--euiFixedHeadersOffset, 0)); | ||
right: 0; | ||
bottom: 0; | ||
left: 0; | ||
} | ||
.kbnAppWrapper { | ||
// DO NOT ADD ANY OTHER STYLES TO THIS SELECTOR | ||
// This a very nested dependency happening in "all" apps | ||
display: flex; | ||
flex-flow: column nowrap; | ||
flex-grow: 1; | ||
z-index: 0; // This effectively puts every high z-index inside the scope of this wrapper to it doesn't interfere with the header and/or overlay mask | ||
position: relative; // This is temporary for apps that relied on this being present on \`.application\` | ||
} | ||
.kbnBody { | ||
padding-top: var(--euiFixedHeadersOffset, 0); | ||
} | ||
// Conditionally override :root CSS fixed header variable. Updating \`--euiFixedHeadersOffset\` | ||
//on the body will cause all child EUI components to automatically update their offsets | ||
.kbnBody--hasHeaderBanner { | ||
--euiFixedHeadersOffset: var(--kbnHeaderOffsetWithBanner); | ||
// Offset fixed EuiHeaders by the top banner | ||
.euiHeader[data-fixed-header] { | ||
margin-top: var(--kbnHeaderBannerHeight); | ||
} | ||
// Prevent banners from covering full screen data grids | ||
.euiDataGrid--fullScreen { | ||
height: calc(100vh - var(--kbnHeaderBannerHeight)); | ||
top: var(--kbnHeaderBannerHeight); | ||
} | ||
} | ||
// Set a body CSS variable for the app container to use - calculates the total | ||
// height of all fixed headers + the sticky action menu toolbar | ||
.kbnBody--hasProjectActionMenu { | ||
--kbnAppHeadersOffset: calc( | ||
var(--kbnHeaderOffset) + var(--kbnProjectHeaderAppActionMenuHeight) | ||
); | ||
&.kbnBody--hasHeaderBanner { | ||
--kbnAppHeadersOffset: calc( | ||
var(--kbnHeaderOffsetWithBanner) + var(--kbnProjectHeaderAppActionMenuHeight) | ||
); | ||
} | ||
} | ||
.kbnBody--chromeHidden { | ||
// stylelint-disable-next-line length-zero-no-unit | ||
--euiFixedHeadersOffset: 0px; | ||
&.kbnBody--hasHeaderBanner { | ||
--euiFixedHeadersOffset: var(--kbnHeaderBannerHeight); | ||
} | ||
&.kbnBody--hasProjectActionMenu { | ||
--kbnAppHeadersOffset: var(--euiFixedHeadersOffset, 0); | ||
} | ||
} | ||
`; | ||
|
||
export const bannerStyles = (euiTheme: UseEuiTheme['euiTheme']) => css` | ||
.header__topBanner { | ||
position: fixed; | ||
top: 0; | ||
left: 0; | ||
height: var(--kbnHeaderBannerHeight); | ||
width: 100%; | ||
z-index: ${euiTheme.levels.header}; | ||
} | ||
.header__topBannerContainer { | ||
height: 100%; | ||
width: 100%; | ||
} | ||
`; | ||
|
||
export const chromeStyles = (euiTheme: UseEuiTheme['euiTheme']) => css` | ||
.euiDataGrid__restrictBody { | ||
.headerGlobalNav, | ||
.kbnQueryBar { | ||
display: none; | ||
} | ||
} | ||
.euiDataGrid__restrictBody.euiBody--headerIsFixed { | ||
.euiFlyout { | ||
top: 0; | ||
height: 100%; | ||
} | ||
} | ||
.chrHeaderHelpMenu__version { | ||
text-transform: none; | ||
} | ||
.chrHeaderBadge__wrapper { | ||
align-self: center; | ||
margin-right: ${euiTheme.size.base}; | ||
} | ||
.header__toggleNavButtonSection { | ||
.euiBody--collapsibleNavIsDocked & { | ||
display: none; | ||
} | ||
} | ||
.header__breadcrumbsWithExtensionContainer { | ||
overflow: hidden; // enables text-ellipsis in the last breadcrumb | ||
.euiHeaderBreadcrumbs { | ||
// stop breadcrumbs from growing. | ||
// this makes the extension appear right next to the last breadcrumb | ||
flex-grow: 0; | ||
margin-right: 0; | ||
overflow: hidden; // enables text-ellipsis in the last breadcrumb | ||
} | ||
} | ||
.header__breadcrumbsAppendExtension { | ||
flex-grow: 1; | ||
} | ||
`; | ||
|
||
export const GlobalAppStyle = () => { | ||
const { euiTheme } = useEuiTheme(); | ||
return ( | ||
<Global | ||
styles={css` | ||
${bannerStyles(euiTheme)} ${chromeStyles(euiTheme)} ${renderingOverrides(euiTheme)} | ||
`} | ||
/> | ||
); | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
@import './base'; | ||
@import './chrome/index'; | ||
@import './rendering/index'; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.