UNPKG

@elastic/eui

Version:

Elastic UI Component Library

105 lines (104 loc) 9.22 kB
/* * 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 { css } from '@emotion/react'; import { euiFontSize, logicalCSS, logicalSizeCSS, mathWithUnits } from '../../global_styling'; import { highContrastModeStyles } from '../../global_styling/functions/high_contrast'; import { euiDataGridCellOutlineSelectors, euiDataGridCellOutlineStyles } from './body/cell/data_grid_cell.styles'; export var euiDataGridVariables = function euiDataGridVariables(euiThemeContext) { var euiTheme = euiThemeContext.euiTheme; return { cellPadding: { s: euiTheme.size.xs, m: mathWithUnits(euiTheme.size.m, function (x) { return x / 2; }), l: euiTheme.size.s }, lineHeight: { s: euiFontSize(euiThemeContext, 'xs').lineHeight, m: euiFontSize(euiThemeContext, 'm').lineHeight }, fontSize: { s: euiFontSize(euiThemeContext, 'xs').fontSize, m: euiFontSize(euiThemeContext, 's').fontSize }, levels: { // Sits above content and cell focus outlines/actions, but below cell // expansion popovers. Cell popovers no longer use a fixed z-index — they // derive theirs from their anchor's stacking context (see // data_grid_cell_popover.tsx) — so this only needs to clear the grid's // own internal layers. stickyHeader: Number(euiTheme.levels.header) - 1 } }; }; export var euiDataGridStyles = function euiDataGridStyles(euiThemeContext) { var euiTheme = euiThemeContext.euiTheme, highContrastMode = euiThemeContext.highContrastMode; var _euiDataGridVariables = euiDataGridVariables(euiThemeContext), _cellPadding = _euiDataGridVariables.cellPadding, lineHeight = _euiDataGridVariables.lineHeight, _fontSize = _euiDataGridVariables.fontSize; var _euiDataGridCellOutli = euiDataGridCellOutlineSelectors(), outlineSelectors = _euiDataGridCellOutli.outline; var borderColors = { default: highContrastMode ? euiTheme.border.color : euiTheme.components.dataGridBorderColor, vertical: highContrastMode ? euiTheme.border.color : euiTheme.components.dataGridVerticalLineBorderColor }; var border = "".concat(euiTheme.border.width.thin, " solid ").concat(borderColors.default); return { euiDataGrid: /*#__PURE__*/css("display:flex;flex-direction:column;align-items:stretch;", logicalCSS('height', '100%'), " overflow:hidden;*:where(& .euiDataGridRow){background-color:", euiTheme.components.dataGridRowBackground, ";}*:where(&.euiDataGrid--rowHoverHighlight .euiDataGridRow:hover){background-color:", euiTheme.components.dataGridRowBackgroundHover, ";}*:where(& .euiDataGridRow--selected){background-color:", euiTheme.components.dataGridRowBackgroundSelect, ";}*:where(& .euiDataGridRow--marked){background-color:", euiTheme.components.dataGridRowBackgroundMarked, ";.euiDataGridRowCell.euiDataGridRowCell{", outlineSelectors.marked, "{", euiDataGridCellOutlineStyles(euiThemeContext).markedStyles, ";}}}*:where(&.euiDataGrid--rowHoverHighlight .euiDataGridRow--marked){&:hover{background-color:", euiTheme.components.dataGridRowBackgroundMarkedHover, ";}}*:where(\n &.euiDataGrid--rowHoverHighlight .euiDataGridRow--selected:hover\n ){background-color:", euiTheme.components.dataGridRowBackgroundSelectHover, ";}*:where(&.euiDataGrid--stripes .euiDataGridRow){background-color:", euiTheme.components.dataGridRowStripesBackground, ";}*:where(&.euiDataGrid--stripes .euiDataGridRow--striped){background-color:", euiTheme.components.dataGridRowStripesBackgroundStriped, ";}*:where(\n &.euiDataGrid--stripes.euiDataGrid--rowHoverHighlight\n .euiDataGridRow:hover\n ){background-color:", euiTheme.components.dataGridRowStripesBackgroundHover, ";}*:where(\n &.euiDataGrid--stripes.euiDataGrid--rowHoverHighlight\n .euiDataGridRow--striped:hover\n ){background-color:", euiTheme.components.dataGridRowStripesBackgroundStripedHover, ";}*:where(&.euiDataGrid--stripes .euiDataGridRow--selected){background-color:", euiTheme.components.dataGridRowStripesBackgroundSelect, ";}*:where(&.euiDataGrid--stripes .euiDataGridRow--marked){background-color:", euiTheme.components.dataGridRowBackgroundMarked, ";}*:where(\n &.euiDataGrid--stripes.euiDataGrid--rowHoverHighlight\n .euiDataGridRow--selected:hover\n ){background-color:", euiTheme.components.dataGridRowStripesBackgroundSelectHover, ";}*:where(&.euiDataGrid--rowHoverHighlight .euiDataGridRow)::before{content:'';position:absolute;z-index:-1;pointer-events:none;inset:0;background-color:", euiTheme.components.dataGridRowBackground, ";};label:euiDataGrid;"), cellPadding: { cellPadding: function cellPadding(size) { return /*#__PURE__*/css(".euiDataGridHeaderCell,.euiDataGridRowCell__content{padding:", _cellPadding[size], ";}.euiDataGridRowCell__content--lineCountHeight,.euiDataGridRowCell__content--autoBelowLineCountHeight{", highContrastModeStyles(euiThemeContext, { // Workaround to trim line-clamp and padding - @see https://github.com/elastic/eui/issues/7780 none: "\n ".concat(logicalCSS('padding-bottom', 0), "\n ").concat(logicalCSS('border-bottom', "".concat(_cellPadding[size], " solid transparent")), "\n "), // Unfortunately this workaround backfires in Windows high contrast themes, which force // border-color, so we can't use it. We'll use a clip-path workaround instead. get forced() { var bottomY = "calc(100% - ".concat(_cellPadding[size], ")"); return "clip-path: polygon(0 0, 100% 0, 100% ".concat(bottomY, ", 0 ").concat(bottomY, ");"); } }), ";}.euiDataGridHeaderCell__button{margin-block:-", _cellPadding[size], ";};label:cellPadding;"); }, get s() { return /*#__PURE__*/css(this.cellPadding('s'), ";label:s;"); }, get m() { return /*#__PURE__*/css(this.cellPadding('m'), ";label:m;"); }, get l() { return /*#__PURE__*/css(this.cellPadding('l'), ";label:l;"); } }, fontSize: { fontSize: function fontSize(size) { return /*#__PURE__*/css(".euiDataGridHeaderCell,.euiDataGridRowCell{font-size:", _fontSize[size], ";line-height:", lineHeight[size], ";};label:fontSize;"); }, get s() { return /*#__PURE__*/css(this.fontSize('s'), ";label:s;"); }, get m() { return /*#__PURE__*/css(this.fontSize('m'), ";label:m;"); }, get l() { return /*#__PURE__*/css(this.fontSize('m'), ";label:l;"); } }, borders: { none: null, horizontal: /*#__PURE__*/css("label:borders;.euiDataGridRowCell:not(.euiDataGridFooterCell),.euiDataGridFooter,&:not(.euiDataGrid--headerUnderline) .euiDataGridHeader{", logicalCSS('border-bottom', border), ";}&:not(.euiDataGrid--footerOverline) .euiDataGridFooter{", logicalCSS('border-top', border), " ", logicalCSS('margin-top', "-".concat(euiTheme.border.width.thin)), ";}.euiDataGridHeader{", logicalCSS('border-top', border), ";}&:is(.euiDataGrid--noHeader) .euiDataGridRow:first-of-type .euiDataGridRowCell{", logicalCSS('border-top', border), ";};label:horizontal;"), all: /*#__PURE__*/css("label:borders;.euiDataGridRowCell{&:not(.euiDataGridFooterCell){", logicalCSS('border-bottom', border), " ", logicalCSS('border-right', // Visually lighten vertical borders "".concat(euiTheme.border.width.thin, " solid ").concat(borderColors.vertical)), ";}&--firstColumn{", logicalCSS('border-left', border), ";}&--lastColumn{", logicalCSS('border-right-color', euiTheme.components.dataGridBorderColor), ";}}.euiDataGridFooterCell,.euiDataGridHeaderCell{", logicalCSS('border-right', border), " &:first-of-type{", logicalCSS('border-left', border), ";}}.euiDataGridFooter{", logicalCSS('border-bottom', border), ";}&:not(.euiDataGrid--footerOverline) .euiDataGridFooter{", logicalCSS('border-top', border), " ", logicalCSS('margin-top', "-".concat(euiTheme.border.width.thin)), ";}&:not(.euiDataGrid--headerUnderline) .euiDataGridHeader{", logicalCSS('border-bottom', border), ";}&:is(.euiDataGrid--noControls) .euiDataGridHeader{", logicalCSS('border-top', border), ";}&:is(.euiDataGrid--noHeader.euiDataGrid--noControls) .euiDataGridRow:first-of-type .euiDataGridRowCell{", logicalCSS('border-top', border), ";}.euiDataGrid__controls{border:", border, ";background-color:", euiTheme.colors.body, ";};label:all;") }, // Sits below the controls above it and pagination below it euiDataGrid__content: /*#__PURE__*/css("z-index:1;position:relative;flex-grow:1;", logicalSizeCSS('100%'), " ", logicalCSS('max-width', '100%'), " overflow:hidden;font-feature-settings:'tnum' 1;;label:euiDataGrid__content;"), // Wrapper around EuiDataGrid euiDataGrid__focusWrap: /*#__PURE__*/css(logicalCSS('height', '100%'), ";;label:euiDataGrid__focusWrap;") }; };