-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Discover] Move truncate-by-height into Discover (#114320)
* [Discover] move source field formatter to discover * [Discover] cleanup source field from field formatters * [Discover] return source field format * [Discover] move truncate by height to discover settings category, apply css via emotion * [Discover] improve code readability, fix i18n * [Discover] fix remaining i18n * [Discover] fix unit tests * [Discover] return truncate-by-height setting to general * [Discover] return i18n naming * [Discover] apply suggestions * [Discover] fix i18n * Update src/plugins/discover/server/ui_settings.ts Co-authored-by: Matthias Wilhelm <[email protected]> * [Discover] fix embeddable and discover grid truncation styles * [Discover] fix tests * [Discover] get rid of emotion * [Discover] apply suggestions * [Discover] inject emotion styles properly * [Discover] remove console.log * [Discover] revert react router changes * [Discover] fix truncate max height reset * [Discover] simplify * [Discover] return injection to the right place * [Discover] remove unused import * [Discover] apply suggestions Co-authored-by: Kibana Machine <[email protected]> Co-authored-by: Matthias Wilhelm <[email protected]>
- Loading branch information
1 parent
3a09678
commit c7866c3
Showing
19 changed files
with
116 additions
and
93 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 was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,10 +103,6 @@ | |
text-align: center; | ||
} | ||
|
||
.truncate-by-height { | ||
overflow: hidden; | ||
} | ||
|
||
.table { | ||
// Nesting | ||
.table { | ||
|
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
51 changes: 51 additions & 0 deletions
51
src/plugins/discover/public/application/helpers/truncate_styles.ts
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,51 @@ | ||
/* | ||
* 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 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 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import createCache from '@emotion/cache'; | ||
import { cache } from '@emotion/css'; | ||
import { serializeStyles } from '@emotion/serialize'; | ||
|
||
/** | ||
* The following emotion cache management was introduced here | ||
* https://ntsim.uk/posts/how-to-update-or-remove-global-styles-in-emotion/ | ||
*/ | ||
const TRUNCATE_GRADIENT_HEIGHT = 15; | ||
const globalThemeCache = createCache({ key: 'truncation' }); | ||
|
||
const buildStylesheet = (maxHeight: number) => { | ||
return [ | ||
` | ||
.dscTruncateByHeight { | ||
overflow: hidden; | ||
max-height: ${maxHeight}px !important; | ||
display: inline-block; | ||
} | ||
.dscTruncateByHeight:before { | ||
top: ${maxHeight - TRUNCATE_GRADIENT_HEIGHT}px; | ||
} | ||
`, | ||
]; | ||
}; | ||
|
||
const flushThemedGlobals = () => { | ||
globalThemeCache.sheet.flush(); | ||
globalThemeCache.inserted = {}; | ||
globalThemeCache.registered = {}; | ||
}; | ||
|
||
export const injectTruncateStyles = (maxHeight: number) => { | ||
if (maxHeight <= 0) { | ||
flushThemedGlobals(); | ||
return; | ||
} | ||
|
||
const serialized = serializeStyles(buildStylesheet(maxHeight), cache.registered); | ||
if (!globalThemeCache.inserted[serialized.name]) { | ||
globalThemeCache.insert('', serialized, globalThemeCache.sheet, true); | ||
} | ||
}; |
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
32 changes: 0 additions & 32 deletions
32
src/plugins/kibana_legacy/public/utils/inject_header_style.ts
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2592,7 +2592,7 @@ | |
dependencies: | ||
"@babel/plugin-syntax-jsx" "^7.2.0" | ||
|
||
"@emotion/babel-plugin@^11.2.0": | ||
"@emotion/babel-plugin@^11.0.0", "@emotion/babel-plugin@^11.2.0": | ||
version "11.2.0" | ||
resolved "https://registry.yarnpkg.com/@emotion/babel-plugin/-/babel-plugin-11.2.0.tgz#f25c6df8ec045dad5ae6ca63df0791673b98c920" | ||
integrity sha512-lsnQBnl3l4wu/FJoyHnYRpHJeIPNkOBMbtDUIXcO8luulwRKZXPvA10zd2eXVN6dABIWNX4E34en/jkejIg/yA== | ||
|
@@ -2653,6 +2653,17 @@ | |
"@emotion/weak-memoize" "^0.2.5" | ||
stylis "^4.0.3" | ||
|
||
"@emotion/cache@^11.5.0": | ||
version "11.5.0" | ||
resolved "https://registry.yarnpkg.com/@emotion/cache/-/cache-11.5.0.tgz#a5eb78cbef8163939ee345e3ddf0af217b845e62" | ||
integrity sha512-mAZ5QRpLriBtaj/k2qyrXwck6yeoz1V5lMt/jfj6igWU35yYlNKs2LziXVgvH81gnJZ+9QQNGelSsnuoAy6uIw== | ||
dependencies: | ||
"@emotion/memoize" "^0.7.4" | ||
"@emotion/sheet" "^1.0.3" | ||
"@emotion/utils" "^1.0.0" | ||
"@emotion/weak-memoize" "^0.2.5" | ||
stylis "^4.0.10" | ||
|
||
"@emotion/core@^10.0.9", "@emotion/core@^10.1.1": | ||
version "10.1.1" | ||
resolved "https://registry.yarnpkg.com/@emotion/core/-/core-10.1.1.tgz#c956c1365f2f2481960064bcb8c4732e5fb612c3" | ||
|
@@ -2682,6 +2693,17 @@ | |
"@emotion/utils" "0.11.3" | ||
babel-plugin-emotion "^10.0.27" | ||
|
||
"@emotion/css@^11.4.0": | ||
version "11.5.0" | ||
resolved "https://registry.yarnpkg.com/@emotion/css/-/css-11.5.0.tgz#0a80017080cb44d47994fe576b9923bfc8b0f6ad" | ||
integrity sha512-mqjz/3aqR9rp40M+pvwdKYWxlQK4Nj3cnNjo3Tx6SM14dSsEn7q/4W2/I7PlgG+mb27iITHugXuBIHH/QwUBVQ== | ||
dependencies: | ||
"@emotion/babel-plugin" "^11.0.0" | ||
"@emotion/cache" "^11.5.0" | ||
"@emotion/serialize" "^1.0.0" | ||
"@emotion/sheet" "^1.0.3" | ||
"@emotion/utils" "^1.0.0" | ||
|
||
"@emotion/[email protected]", "@emotion/hash@^0.8.0": | ||
version "0.8.0" | ||
resolved "https://registry.yarnpkg.com/@emotion/hash/-/hash-0.8.0.tgz#bbbff68978fefdbe68ccb533bc8cbe1d1afb5413" | ||
|
@@ -2780,6 +2802,11 @@ | |
resolved "https://registry.yarnpkg.com/@emotion/sheet/-/sheet-1.0.1.tgz#245f54abb02dfd82326e28689f34c27aa9b2a698" | ||
integrity sha512-GbIvVMe4U+Zc+929N1V7nW6YYJtidj31lidSmdYcWozwoBIObXBnaJkKNDjZrLm9Nc0BR+ZyHNaRZxqNZbof5g== | ||
|
||
"@emotion/sheet@^1.0.3": | ||
version "1.0.3" | ||
resolved "https://registry.yarnpkg.com/@emotion/sheet/-/sheet-1.0.3.tgz#00c326cd7985c5ccb8fe2c1b592886579dcfab8f" | ||
integrity sha512-YoX5GyQ4db7LpbmXHMuc8kebtBGP6nZfRC5Z13OKJMixBEwdZrJ914D6yJv/P+ZH/YY3F5s89NYX2hlZAf3SRQ== | ||
|
||
"@emotion/styled-base@^10.0.27": | ||
version "10.0.31" | ||
resolved "https://registry.yarnpkg.com/@emotion/styled-base/-/styled-base-10.0.31.tgz#940957ee0aa15c6974adc7d494ff19765a2f742a" | ||
|
@@ -27271,6 +27298,11 @@ stylis@^3.5.0: | |
resolved "https://registry.yarnpkg.com/stylis/-/stylis-3.5.4.tgz#f665f25f5e299cf3d64654ab949a57c768b73fbe" | ||
integrity sha512-8/3pSmthWM7lsPBKv7NXkzn2Uc9W7NotcwGNpJaa3k7WMM1XDCA4MgT5k/8BIexd5ydZdboXtU90XH9Ec4Bv/Q== | ||
|
||
stylis@^4.0.10: | ||
version "4.0.10" | ||
resolved "https://registry.yarnpkg.com/stylis/-/stylis-4.0.10.tgz#446512d1097197ab3f02fb3c258358c3f7a14240" | ||
integrity sha512-m3k+dk7QeJw660eIKRRn3xPF6uuvHs/FFzjX3HQ5ove0qYsiygoAhwn5a3IYKaZPo5LrYD0rfVmtv1gNY1uYwg== | ||
|
||
stylis@^4.0.3: | ||
version "4.0.7" | ||
resolved "https://registry.yarnpkg.com/stylis/-/stylis-4.0.7.tgz#412a90c28079417f3d27c028035095e4232d2904" | ||
|