@elastic/eui
Version:
Elastic UI Component Library
60 lines (56 loc) • 3.66 kB
JavaScript
import _defineProperty from "@babel/runtime/helpers/defineProperty";
import _objectDestructuringEmpty from "@babel/runtime/helpers/objectDestructuringEmpty";
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
/*
* 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 React from 'react';
import { Global, css } from '@emotion/react';
import { euiFocusRing, euiScrollBarStyles } from '../mixins';
import { logicalCSS } from '../functions';
import { transparentize } from '../../services/color';
import { useEuiTheme } from '../../services/theme';
import { resetStyles as reset } from './reset';
import { jsx as ___EmotionJSX } from "@emotion/react";
export var EuiGlobalStyles = function EuiGlobalStyles(_ref) {
_objectDestructuringEmpty(_ref);
var euiThemeContext = useEuiTheme();
var euiTheme = euiThemeContext.euiTheme,
colorMode = euiThemeContext.colorMode;
var base = euiTheme.base,
colors = euiTheme.colors,
font = euiTheme.font;
/**
* Declaring the top level scrollbar colors to match the theme also requires setting the sizes on Chrome
* so that it knows to use custom styles. Therefore, we just reuse the same scrollbar mixin with thick size.
*/
var scrollbarStyles = euiScrollBarStyles(euiThemeContext, {
trackColor: euiTheme.components.scrollbarTrackColor,
width: 'auto'
});
/**
* This font reset sets all our base font/typography related properties
* that are needed to override browser-specific element settings.
*/
var fontBodyScale = font.scale[font.body.scale];
var fontReset = {
fontFamily: font.family,
fontSize: "".concat(font.defaultUnits === 'px' ? fontBodyScale * base : fontBodyScale).concat(font.defaultUnits),
lineHeight: base / (fontBodyScale * base),
fontWeight: font.weight[font.body.weight]
};
/**
* Final styles
*/
var styles = /*#__PURE__*/css(reset, " html{", scrollbarStyles, " ", fontReset, " text-size-adjust:100%;font-kerning:normal;", logicalCSS('height', '100%'), " background-color:", colors.body, ";color:", colors.textParagraph, ";}code,pre,kbd,samp{font-family:", font.familyCode, ";}input,textarea,select{", _objectSpread(_objectSpread({}, fontReset), {}, {
fontSize: '1rem' // Inherit from html root
}), ";}select:disabled{opacity:1;}button{font-family:", font.family, ";}em{font-style:italic;}strong{font-weight:", font.weight.bold, ";}*:focus{", euiFocusRing(euiThemeContext), ";}::selection{background:", transparentize(colors.primary, colorMode === 'LIGHT' ? 0.1 : 0.2), ";}a{color:", colors.textPrimary, ";&,&:hover,&:focus{text-decoration:none;}}.euiBody-hasPortalContent{position:relative;};label:styles;");
return ___EmotionJSX(Global, {
styles: styles
});
};