This typographic scale is used to calculate the font sizes which are
- multiplied against the base value and convertd to
- pixel and/or rem values.
+ multiplied against the base value and converted
+ to pixel and/or rem values.
+ The body.scale value determines the base
+ font-size at which every font-size is calculated against.
+
+
+
+
+
+ updateScale(key, value)}
+ // numberProps={{ step: 0.1, style: { width: '6em' } }}
+ groupProps={{ alignItems: 'center' }}
+ />
);
diff --git a/src-docs/src/views/theme/typography/_typography_js.tsx b/src-docs/src/views/theme/typography/_typography_js.tsx
index 1f8efce4401..c9fda345fdc 100644
--- a/src-docs/src/views/theme/typography/_typography_js.tsx
+++ b/src-docs/src/views/theme/typography/_typography_js.tsx
@@ -140,6 +140,29 @@ export const FontScaleJS = () => {
return (
<>
+
+ Font sizing is provided through React hooks and not the global
+ theme. It returns both the font-size and{' '}
+ line-height for the provided{' '}
+ scale. But you can still grab an individual
+ property via the returned object.
+
+ }
+ example={
+
+ The quick brown fox jumped over the blue moon to catch a snail
+
The quick brown fox jumped over the blue moon to catch a snail
@@ -162,22 +177,50 @@ export const FontScaleJS = () => {
}
snippet="euiFontSize('l');"
/>
-
- setMeasurement(e.target.checked ? 'px' : 'rem')}
- />
+
+ Value measurements}
+ description={
+
+ The font sizing function also supports the three main measurements
+ for font-size, rem | px | em, with{' '}
+ rem being default for all EUI components.
+
The quick brown fox jumped over the blue moon to catch a snail
@@ -203,7 +247,7 @@ export const FontScaleJS = () => {
{
field: 'value',
name: 'Function',
- width: '200px',
+ width: 'auto',
valign: 'baseline',
render: (value: React.ReactNode) => (
{value}
diff --git a/src/global_styling/reset/global_styles.tsx b/src/global_styling/reset/global_styles.tsx
index 2337d113ccb..19137c4bcc8 100644
--- a/src/global_styling/reset/global_styles.tsx
+++ b/src/global_styling/reset/global_styles.tsx
@@ -42,11 +42,6 @@ export const EuiGlobalStyles = ({}: EuiGlobalStylesProps) => {
font-size: ${`${font.scale[font.body.scale] * base}px`};
line-height: ${base / (font.scale[font.body.scale] * base)};
font-weight: ${font.weight[font.body.weight]};
- ${
- font.body.letterSpacing
- ? `letter-spacing: ${font.body.letterSpacing};`
- : ''
- }
`;
/**
diff --git a/src/global_styling/variables/_typography.ts b/src/global_styling/variables/_typography.ts
index 5ce3b2b6aea..05a590611bf 100644
--- a/src/global_styling/variables/_typography.ts
+++ b/src/global_styling/variables/_typography.ts
@@ -73,6 +73,7 @@ export const fontBase: _EuiThemeFontBase = {
/*
* Font weights
*/
+
export interface _EuiThemeFontWeight {
light: CSSProperties['fontWeight'];
regular: CSSProperties['fontWeight'];
@@ -89,6 +90,21 @@ export const fontWeight: _EuiThemeFontWeight = {
bold: 700,
};
+/**
+ * Body / Base styles
+ */
+
+export interface _EuiThemeBody {
+ /**
+ * A sizing key from one of the font scales to set as the base body font-size
+ */
+ scale: _EuiThemeFontScale;
+ /**
+ * A font weight key for setting the base body weight
+ */
+ weight: keyof _EuiThemeFontWeight;
+}
+
/*
* Font
*/
@@ -96,11 +112,7 @@ export const fontWeight: _EuiThemeFontWeight = {
export type EuiThemeFont = _EuiThemeFontBase & {
scale: { [key in _EuiThemeFontScale]: number };
weight: _EuiThemeFontWeight;
- body: {
- scale: _EuiThemeFontScale;
- weight: keyof _EuiThemeFontWeight;
- letterSpacing?: CSSProperties['letterSpacing'];
- };
+ body: _EuiThemeBody;
};
export const font: EuiThemeFont = {
diff --git a/src/global_styling/variables/text.ts b/src/global_styling/variables/text.ts
index eff75c38c2b..3d0c1c2c2e8 100644
--- a/src/global_styling/variables/text.ts
+++ b/src/global_styling/variables/text.ts
@@ -8,6 +8,7 @@
import { CSSProperties } from 'react';
import {
+ EuiThemeFontSizeMeasurement,
lineHeightFromBaseline,
fontSizeFromScale,
} from '../../services/theme/typography';
@@ -25,7 +26,7 @@ export type EuiThemeFontSize = {
export const euiFontSize = (
scale: _EuiThemeFontScale,
{ base, font }: UseEuiTheme['euiTheme'],
- measurement: 'px' | 'rem' = 'rem'
+ measurement: EuiThemeFontSizeMeasurement = 'rem'
): EuiThemeFontSize => {
return {
fontSize: fontSizeFromScale(
diff --git a/src/services/theme/typography.ts b/src/services/theme/typography.ts
index e6847b453e3..c0da6a02405 100644
--- a/src/services/theme/typography.ts
+++ b/src/services/theme/typography.ts
@@ -11,6 +11,8 @@ import {
_EuiThemeFontScale,
} from '../../global_styling/variables/_typography';
+export type EuiThemeFontSizeMeasurement = 'px' | 'rem' | 'em';
+
export const LINE_HEIGHT_MULTIPLIER_S = 1.5;
export const LINE_HEIGHT_MULTIPLIER_L = 1.25;
@@ -22,14 +24,15 @@ export const LINE_HEIGHT_MULTIPLIER_L = 1.25;
* @param base - Theme base unit
* @param font - Requires the `body` and `baseline` values
* @param scale - The font scale multiplier
+ * @param measurement - The returned string measurement
* *
- * @returns string - Rem unit aligned to baseline
+ * @returns string - Calculated line-height value aligned to baseline
*/
export function lineHeightFromBaseline(
base: number,
font: EuiThemeFont,
scale: number,
- measurement: 'px' | 'rem' = 'rem'
+ measurement: EuiThemeFontSizeMeasurement = 'rem'
) {
const { baseline, body } = font;
const numerator = base * scale;
@@ -38,6 +41,12 @@ export function lineHeightFromBaseline(
const _lineHeightMultiplier =
numerator <= base ? LINE_HEIGHT_MULTIPLIER_S : LINE_HEIGHT_MULTIPLIER_L;
+ if (measurement === 'em') {
+ // Even though the line-height via `em` cannot be determined against the pixel baseline grid;
+ // we will assume that typically larger scale font-sizes should have a shorter line-height;
+ return _lineHeightMultiplier.toString();
+ }
+
const pixelValue =
Math.floor(Math.round(numerator * _lineHeightMultiplier) / baseline) *
baseline;
@@ -53,8 +62,9 @@ export function lineHeightFromBaseline(
* @param base = 16
* @param scale = full scale
* @param bodyScale = 's'
- * @param scale = 'm'
- * @returns
+ * @param size = 'm'
+ * @param measurement - The returned string measurement
+ * @returns string - Calculated font-size value
*/
export function fontSizeFromScale(
@@ -62,8 +72,12 @@ export function fontSizeFromScale(
scale: { [key in _EuiThemeFontScale]: number },
bodyScale: _EuiThemeFontScale,
size: _EuiThemeFontScale,
- measurement: 'px' | 'rem' = 'rem'
+ measurement: EuiThemeFontSizeMeasurement = 'rem'
) {
+ if (measurement === 'em') {
+ return `${scale[size]}em`;
+ }
+
const numerator = base * scale[size];
const denominator = base * scale[bodyScale];
From 4dadf55cc1c9597d0de8b340bb4c77fea36de442 Mon Sep 17 00:00:00 2001
From: cchaos
Date: Wed, 13 Apr 2022 01:01:24 -0400
Subject: [PATCH 06/16] Separating theme types from values - Moved typography
values into Amsterdam theme - Added `lineHeightMultiplier` back into theme -
Simplified typography functions and moved to functions folder
---
.../views/theme/customizing/_typography.js | 2 +-
.../views/theme/typography/_typography_js.tsx | 11 +--
src/global_styling/index.ts | 2 +
src/global_styling/variables/_typography.ts | 35 +-------
src/global_styling/variables/text.ts | 46 ----------
src/services/theme/index.ts | 1 -
src/services/theme/typography.ts | 87 -------------------
.../global_styling/variables/_typography.ts | 49 +++++++++--
src/themes/amsterdam/theme.ts | 4 +-
9 files changed, 54 insertions(+), 183 deletions(-)
delete mode 100644 src/global_styling/variables/text.ts
delete mode 100644 src/services/theme/typography.ts
diff --git a/src-docs/src/views/theme/customizing/_typography.js b/src-docs/src/views/theme/customizing/_typography.js
index 7d5631ce6ff..de63558bd15 100644
--- a/src-docs/src/views/theme/customizing/_typography.js
+++ b/src-docs/src/views/theme/customizing/_typography.js
@@ -13,7 +13,7 @@ import {
import {
fontWeight,
fontScale,
-} from '../../../../../src/global_styling/variables/_typography';
+} from '../../../../../src/themes/amsterdam/global_styling/variables/_typography';
import { getPropsFromComponent } from '../../../services/props/get_props';
import { ThemeValue } from './_values';
diff --git a/src-docs/src/views/theme/typography/_typography_js.tsx b/src-docs/src/views/theme/typography/_typography_js.tsx
index d2aefc15b12..af7d8b79390 100644
--- a/src-docs/src/views/theme/typography/_typography_js.tsx
+++ b/src-docs/src/views/theme/typography/_typography_js.tsx
@@ -11,12 +11,12 @@ import {
} from '../../../../../src/components';
import {
- fontWeight,
_EuiThemeFontWeight,
FONT_SCALES,
} from '../../../../../src/global_styling/variables/_typography';
-import { euiFontSize } from '../../../../../src/global_styling/variables/text';
-import { EuiThemeFontSizeMeasurement } from '../../../../../src/services/theme/typography';
+import { euiFontSize } from '../../../../../src/global_styling/mixins/_typography';
+import { EuiThemeFontSizeMeasurement } from '../../../../../src/global_styling/functions/typography';
+import { fontWeight } from '../../../../../src/themes/amsterdam/global_styling/variables/_typography';
import { EuiThemeFontBase, EuiThemeFontWeight, ThemeRowType } from '../_props';
import { getPropsFromComponent } from '../../../services/props/get_props';
@@ -204,11 +204,6 @@ export const FontScaleJS = () => {
{
return {
diff --git a/src/global_styling/index.ts b/src/global_styling/index.ts
index 0eee3cdb9d3..18271ef0cef 100644
--- a/src/global_styling/index.ts
+++ b/src/global_styling/index.ts
@@ -7,3 +7,5 @@
*/
export * from './reset/global_styles';
+export * from './functions/typography';
+export * from './mixins/_typography';
diff --git a/src/global_styling/variables/_typography.ts b/src/global_styling/variables/_typography.ts
index 05a590611bf..63b46566c6a 100644
--- a/src/global_styling/variables/_typography.ts
+++ b/src/global_styling/variables/_typography.ts
@@ -8,13 +8,12 @@
import { CSSProperties } from 'react';
import { keysOf } from '../../components/common';
-import { computed } from '../../services/theme/utils';
/*
* Font scale
*/
-// Typographic scale -- loosely based on Major Third (1.250)
+// TODO: How to reduce to just the array
export const fontScale = {
xxxs: 0.5625,
xxs: 0.6875,
@@ -55,19 +54,7 @@ export type _EuiThemeFontBase = {
/**
* Establishes the ideal line-height percentage, but it is the `baseline` integer that establishes the final pixel/rem value
*/
- // lineHeightMultiplier: number;
-};
-
-// Families & base font settings
-export const fontBase: _EuiThemeFontBase = {
- family: "'Inter', BlinkMacSystemFont, Helvetica, Arial, sans-serif",
- familyCode: "'Roboto Mono', Menlo, Courier, monospace",
-
- // Careful using ligatures. Code editors like ACE will often error because of width calculations
- featureSettings: "'calt' 1, 'kern' 1, 'liga' 1",
-
- baseline: computed(([base]) => base / 4, ['base']),
- // lineHeightMultiplier: 1.5,
+ lineHeightMultiplier: number;
};
/*
@@ -82,14 +69,6 @@ export interface _EuiThemeFontWeight {
bold: CSSProperties['fontWeight'];
}
-export const fontWeight: _EuiThemeFontWeight = {
- light: 300,
- regular: 400,
- medium: 500,
- semiBold: 600,
- bold: 700,
-};
-
/**
* Body / Base styles
*/
@@ -114,13 +93,3 @@ export type EuiThemeFont = _EuiThemeFontBase & {
weight: _EuiThemeFontWeight;
body: _EuiThemeBody;
};
-
-export const font: EuiThemeFont = {
- ...fontBase,
- scale: fontScale,
- weight: fontWeight,
- body: {
- scale: 's',
- weight: 'regular',
- },
-};
diff --git a/src/global_styling/variables/text.ts b/src/global_styling/variables/text.ts
deleted file mode 100644
index 3d0c1c2c2e8..00000000000
--- a/src/global_styling/variables/text.ts
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * 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 { CSSProperties } from 'react';
-import {
- EuiThemeFontSizeMeasurement,
- lineHeightFromBaseline,
- fontSizeFromScale,
-} from '../../services/theme/typography';
-import { UseEuiTheme } from '../../services/theme/hooks';
-import { _EuiThemeFontScale } from './_typography';
-
-export type EuiThemeFontSize = {
- fontSize: CSSProperties['fontSize'];
- lineHeight: CSSProperties['lineHeight'];
-};
-
-/**
- * Returns font-size and line-height
- */
-export const euiFontSize = (
- scale: _EuiThemeFontScale,
- { base, font }: UseEuiTheme['euiTheme'],
- measurement: EuiThemeFontSizeMeasurement = 'rem'
-): EuiThemeFontSize => {
- return {
- fontSize: fontSizeFromScale(
- base,
- font.scale,
- font.body.scale,
- scale,
- measurement
- ),
- lineHeight: lineHeightFromBaseline(
- base,
- font,
- font.scale[scale],
- measurement
- ),
- };
-};
diff --git a/src/services/theme/index.ts b/src/services/theme/index.ts
index 5cf307f8879..fb6327bd1e3 100644
--- a/src/services/theme/index.ts
+++ b/src/services/theme/index.ts
@@ -37,5 +37,4 @@ export type {
EuiThemeSystem,
} from './types';
export { COLOR_MODES_STANDARD } from './types';
-export { lineHeightFromBaseline } from './typography';
export { sizeToPixel } from './size';
diff --git a/src/services/theme/typography.ts b/src/services/theme/typography.ts
deleted file mode 100644
index c0da6a02405..00000000000
--- a/src/services/theme/typography.ts
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * 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 {
- EuiThemeFont,
- _EuiThemeFontScale,
-} from '../../global_styling/variables/_typography';
-
-export type EuiThemeFontSizeMeasurement = 'px' | 'rem' | 'em';
-
-export const LINE_HEIGHT_MULTIPLIER_S = 1.5;
-export const LINE_HEIGHT_MULTIPLIER_L = 1.25;
-
-/**
- * Calculates the line-height to the closest multiple of the baseline
- * EX: A proper line-height for text is 1.5 times the font-size.
- * If our base font size (euiFontSize) is 16, and our baseline is 4. To ensure the
- * text stays on the baseline, we pass a multiplier to calculate a line-height.
- * @param base - Theme base unit
- * @param font - Requires the `body` and `baseline` values
- * @param scale - The font scale multiplier
- * @param measurement - The returned string measurement
- * *
- * @returns string - Calculated line-height value aligned to baseline
- */
-export function lineHeightFromBaseline(
- base: number,
- font: EuiThemeFont,
- scale: number,
- measurement: EuiThemeFontSizeMeasurement = 'rem'
-) {
- const { baseline, body } = font;
- const numerator = base * scale;
- const denominator = base * font.scale[body.scale];
-
- const _lineHeightMultiplier =
- numerator <= base ? LINE_HEIGHT_MULTIPLIER_S : LINE_HEIGHT_MULTIPLIER_L;
-
- if (measurement === 'em') {
- // Even though the line-height via `em` cannot be determined against the pixel baseline grid;
- // we will assume that typically larger scale font-sizes should have a shorter line-height;
- return _lineHeightMultiplier.toString();
- }
-
- const pixelValue =
- Math.floor(Math.round(numerator * _lineHeightMultiplier) / baseline) *
- baseline;
- return measurement === 'px'
- ? `${pixelValue}px`
- : `${(pixelValue / denominator).toFixed(4)}rem`;
-}
-
-/**
- *
- *
- *
- * @param base = 16
- * @param scale = full scale
- * @param bodyScale = 's'
- * @param size = 'm'
- * @param measurement - The returned string measurement
- * @returns string - Calculated font-size value
- */
-
-export function fontSizeFromScale(
- base: number,
- scale: { [key in _EuiThemeFontScale]: number },
- bodyScale: _EuiThemeFontScale,
- size: _EuiThemeFontScale,
- measurement: EuiThemeFontSizeMeasurement = 'rem'
-) {
- if (measurement === 'em') {
- return `${scale[size]}em`;
- }
-
- const numerator = base * scale[size];
- const denominator = base * scale[bodyScale];
-
- return measurement === 'px'
- ? `${numerator}px`
- : `${(numerator / denominator).toFixed(4)}rem`;
-}
diff --git a/src/themes/amsterdam/global_styling/variables/_typography.ts b/src/themes/amsterdam/global_styling/variables/_typography.ts
index aa305c97699..e253ebb195f 100644
--- a/src/themes/amsterdam/global_styling/variables/_typography.ts
+++ b/src/themes/amsterdam/global_styling/variables/_typography.ts
@@ -6,12 +6,51 @@
* Side Public License, v 1.
*/
+import { computed } from '../../../../services/theme/utils';
import {
EuiThemeFont,
- font,
+ _EuiThemeFontBase,
+ _EuiThemeFontWeight,
} from '../../../../global_styling/variables/_typography';
-/**
- * With the removal of the Legacy theme, Amsterdam's overrides have moved to the default
- */
-export const font_ams: EuiThemeFont = font;
+// Typographic scale -- loosely based on Major Third (1.250)
+export const fontScale = {
+ xxxs: 0.5625,
+ xxs: 0.6875,
+ xs: 0.75,
+ s: 0.875,
+ m: 1,
+ l: 1.375,
+ xl: 1.6875,
+ xxl: 2.125,
+};
+
+// Families & base font settings
+export const fontBase: _EuiThemeFontBase = {
+ family: "'Inter', BlinkMacSystemFont, Helvetica, Arial, sans-serif",
+ familyCode: "'Roboto Mono', Menlo, Courier, monospace",
+
+ // Careful using ligatures. Code editors like ACE will often error because of width calculations
+ featureSettings: "'calt' 1, 'kern' 1, 'liga' 1",
+
+ baseline: computed(([base]) => base / 4, ['base']),
+ lineHeightMultiplier: 1.5,
+};
+
+export const fontWeight: _EuiThemeFontWeight = {
+ light: 300,
+ regular: 400,
+ medium: 500,
+ semiBold: 600,
+ bold: 700,
+};
+
+export const font: EuiThemeFont = {
+ ...fontBase,
+ scale: fontScale,
+ weight: fontWeight,
+ body: {
+ scale: 's',
+ weight: 'regular',
+ },
+};
diff --git a/src/themes/amsterdam/theme.ts b/src/themes/amsterdam/theme.ts
index b6ce8e37fd3..30ed5de0471 100644
--- a/src/themes/amsterdam/theme.ts
+++ b/src/themes/amsterdam/theme.ts
@@ -13,7 +13,7 @@ import { breakpoint } from '../../global_styling/variables/_breakpoint';
import { base, size } from '../../global_styling/variables/_size';
import { colors_ams } from './global_styling/variables/_colors';
-import { font_ams } from './global_styling/variables/_typography';
+import { font } from './global_styling/variables/_typography';
import { border_ams } from './global_styling/variables/_borders';
export const AMSTERDAM_NAME_KEY = 'EUI_THEME_AMSTERDAM';
@@ -22,7 +22,7 @@ export const euiThemeAmsterdam: EuiThemeShape = {
colors: colors_ams,
base,
size,
- font: font_ams,
+ font,
border: border_ams,
animation,
breakpoint,
From 0a37a113ea0a515af0722380fed14e9712410c52 Mon Sep 17 00:00:00 2001
From: cchaos
Date: Wed, 13 Apr 2022 01:04:34 -0400
Subject: [PATCH 07/16] add files
---
src/global_styling/functions/typography.ts | 80 ++++++++++++++++++++++
src/global_styling/mixins/_typography.ts | 35 ++++++++++
2 files changed, 115 insertions(+)
create mode 100644 src/global_styling/functions/typography.ts
create mode 100644 src/global_styling/mixins/_typography.ts
diff --git a/src/global_styling/functions/typography.ts b/src/global_styling/functions/typography.ts
new file mode 100644
index 00000000000..ce107e09e9e
--- /dev/null
+++ b/src/global_styling/functions/typography.ts
@@ -0,0 +1,80 @@
+/*
+ * 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 { _EuiThemeFontScale } from '../variables/_typography';
+import { UseEuiTheme } from '../../services/theme/hooks';
+
+export type EuiThemeFontSizeMeasurement = 'px' | 'rem' | 'em';
+
+/**
+ *
+ *
+ *
+ * @param base = 16
+ * @param scale = full scale
+ * @param bodyScale = 's'
+ * @param size = 'm'
+ * @param measurement - The returned string measurement
+ * @returns string - Calculated font-size value
+ */
+
+export function fontSizeFromScale(
+ scale: _EuiThemeFontScale,
+ { base, font }: UseEuiTheme['euiTheme'],
+ measurement: EuiThemeFontSizeMeasurement = 'rem'
+) {
+ if (measurement === 'em') {
+ return `${font.scale[scale]}em`;
+ }
+
+ const numerator = base * font.scale[scale];
+ const denominator = base * font.scale[font.body.scale];
+
+ return measurement === 'px'
+ ? `${numerator}px`
+ : `${(numerator / denominator).toFixed(4)}rem`;
+}
+
+/**
+ * Calculates the line-height to the closest multiple of the baseline
+ * EX: A proper line-height for text is 1.5 times the font-size.
+ * If our base font size (euiFontSize) is 16, and our baseline is 4. To ensure the
+ * text stays on the baseline, we pass a multiplier to calculate a line-height.
+ * @param base - Theme base unit
+ * @param font - Requires the `body` and `baseline` values
+ * @param scale - The font scale multiplier
+ * @param measurement - The returned string measurement
+ * *
+ * @returns string - Calculated line-height value aligned to baseline
+ */
+
+export function lineHeightFromBaseline(
+ scale: _EuiThemeFontScale,
+ { base, font }: UseEuiTheme['euiTheme'],
+ measurement: EuiThemeFontSizeMeasurement = 'rem'
+) {
+ const { baseline, body, lineHeightMultiplier } = font;
+ const numerator = base * font.scale[scale];
+ const denominator = base * font.scale[body.scale];
+
+ const _lineHeightMultiplier =
+ numerator <= base ? lineHeightMultiplier : lineHeightMultiplier * 0.833;
+
+ if (measurement === 'em') {
+ // Even though the line-height via `em` cannot be determined against the pixel baseline grid;
+ // we will assume that typically larger scale font-sizes should have a shorter line-height;
+ return _lineHeightMultiplier.toFixed(4).toString();
+ }
+
+ const pixelValue =
+ Math.floor(Math.round(numerator * _lineHeightMultiplier) / baseline) *
+ baseline;
+ return measurement === 'px'
+ ? `${pixelValue}px`
+ : `${(pixelValue / denominator).toFixed(4)}rem`;
+}
diff --git a/src/global_styling/mixins/_typography.ts b/src/global_styling/mixins/_typography.ts
new file mode 100644
index 00000000000..c4f001d44ba
--- /dev/null
+++ b/src/global_styling/mixins/_typography.ts
@@ -0,0 +1,35 @@
+/*
+ * 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 { CSSProperties } from 'react';
+import {
+ EuiThemeFontSizeMeasurement,
+ lineHeightFromBaseline,
+ fontSizeFromScale,
+} from '../functions/typography';
+import { UseEuiTheme } from '../../services/theme/hooks';
+import { _EuiThemeFontScale } from '../variables/_typography';
+
+export type EuiThemeFontSize = {
+ fontSize: CSSProperties['fontSize'];
+ lineHeight: CSSProperties['lineHeight'];
+};
+
+/**
+ * Returns font-size and line-height
+ */
+export const euiFontSize = (
+ scale: _EuiThemeFontScale,
+ euiTheme: UseEuiTheme['euiTheme'],
+ measurement: EuiThemeFontSizeMeasurement = 'rem'
+): EuiThemeFontSize => {
+ return {
+ fontSize: fontSizeFromScale(scale, euiTheme, measurement),
+ lineHeight: lineHeightFromBaseline(scale, euiTheme, measurement),
+ };
+};
From 46ea7e54bdd9e2fa048170d3ed244dc6cb881125 Mon Sep 17 00:00:00 2001
From: cchaos
Date: Wed, 13 Apr 2022 01:12:41 -0400
Subject: [PATCH 08/16] More moving files
---
.../src/views/theme/typography/_typography_js.tsx | 8 ++++----
src/global_styling/index.ts | 1 -
.../{functions => local_functions}/typography.ts | 11 ++++++-----
src/global_styling/mixins/_typography.ts | 10 ++++++----
4 files changed, 16 insertions(+), 14 deletions(-)
rename src/global_styling/{functions => local_functions}/typography.ts (91%)
diff --git a/src-docs/src/views/theme/typography/_typography_js.tsx b/src-docs/src/views/theme/typography/_typography_js.tsx
index af7d8b79390..270a14219e7 100644
--- a/src-docs/src/views/theme/typography/_typography_js.tsx
+++ b/src-docs/src/views/theme/typography/_typography_js.tsx
@@ -15,7 +15,7 @@ import {
FONT_SCALES,
} from '../../../../../src/global_styling/variables/_typography';
import { euiFontSize } from '../../../../../src/global_styling/mixins/_typography';
-import { EuiThemeFontSizeMeasurement } from '../../../../../src/global_styling/functions/typography';
+import { _EuiThemeFontSizeMeasurement } from '../../../../../src/global_styling/local_functions/typography';
import { fontWeight } from '../../../../../src/themes/amsterdam/global_styling/variables/_typography';
import { EuiThemeFontBase, EuiThemeFontWeight, ThemeRowType } from '../_props';
@@ -140,7 +140,7 @@ const scaleKeys = FONT_SCALES;
export const FontScaleJS = () => {
const { euiTheme } = useEuiTheme();
- const measurements: EuiThemeFontSizeMeasurement[] = ['rem', 'px', 'em'];
+ const measurements: _EuiThemeFontSizeMeasurement[] = ['rem', 'px', 'em'];
const measurementButtons = measurements.map((m) => {
return {
@@ -150,7 +150,7 @@ export const FontScaleJS = () => {
});
const [measurementSelected, setMeasurementSelected] = useState<
- EuiThemeFontSizeMeasurement
+ _EuiThemeFontSizeMeasurement
>(measurementButtons[0].id);
return (
@@ -195,7 +195,7 @@ export const FontScaleJS = () => {
options={measurementButtons}
idSelected={measurementSelected}
onChange={(id) =>
- setMeasurementSelected(id as EuiThemeFontSizeMeasurement)
+ setMeasurementSelected(id as _EuiThemeFontSizeMeasurement)
}
color="accent"
isFullWidth
diff --git a/src/global_styling/index.ts b/src/global_styling/index.ts
index 18271ef0cef..2053d3662f5 100644
--- a/src/global_styling/index.ts
+++ b/src/global_styling/index.ts
@@ -7,5 +7,4 @@
*/
export * from './reset/global_styles';
-export * from './functions/typography';
export * from './mixins/_typography';
diff --git a/src/global_styling/functions/typography.ts b/src/global_styling/local_functions/typography.ts
similarity index 91%
rename from src/global_styling/functions/typography.ts
rename to src/global_styling/local_functions/typography.ts
index ce107e09e9e..7bb027c5dff 100644
--- a/src/global_styling/functions/typography.ts
+++ b/src/global_styling/local_functions/typography.ts
@@ -6,11 +6,12 @@
* Side Public License, v 1.
*/
-import { _EuiThemeFontScale } from '../variables/_typography';
+import {
+ _EuiThemeFontScale,
+ _EuiThemeFontSizeMeasurement,
+} from '../variables/_typography';
import { UseEuiTheme } from '../../services/theme/hooks';
-export type EuiThemeFontSizeMeasurement = 'px' | 'rem' | 'em';
-
/**
*
*
@@ -26,7 +27,7 @@ export type EuiThemeFontSizeMeasurement = 'px' | 'rem' | 'em';
export function fontSizeFromScale(
scale: _EuiThemeFontScale,
{ base, font }: UseEuiTheme['euiTheme'],
- measurement: EuiThemeFontSizeMeasurement = 'rem'
+ measurement: _EuiThemeFontSizeMeasurement = 'rem'
) {
if (measurement === 'em') {
return `${font.scale[scale]}em`;
@@ -56,7 +57,7 @@ export function fontSizeFromScale(
export function lineHeightFromBaseline(
scale: _EuiThemeFontScale,
{ base, font }: UseEuiTheme['euiTheme'],
- measurement: EuiThemeFontSizeMeasurement = 'rem'
+ measurement: _EuiThemeFontSizeMeasurement = 'rem'
) {
const { baseline, body, lineHeightMultiplier } = font;
const numerator = base * font.scale[scale];
diff --git a/src/global_styling/mixins/_typography.ts b/src/global_styling/mixins/_typography.ts
index c4f001d44ba..de3b4da48f1 100644
--- a/src/global_styling/mixins/_typography.ts
+++ b/src/global_styling/mixins/_typography.ts
@@ -8,12 +8,14 @@
import { CSSProperties } from 'react';
import {
- EuiThemeFontSizeMeasurement,
lineHeightFromBaseline,
fontSizeFromScale,
-} from '../functions/typography';
+} from '../local_functions/typography';
import { UseEuiTheme } from '../../services/theme/hooks';
-import { _EuiThemeFontScale } from '../variables/_typography';
+import {
+ _EuiThemeFontScale,
+ _EuiThemeFontSizeMeasurement,
+} from '../variables/_typography';
export type EuiThemeFontSize = {
fontSize: CSSProperties['fontSize'];
@@ -26,7 +28,7 @@ export type EuiThemeFontSize = {
export const euiFontSize = (
scale: _EuiThemeFontScale,
euiTheme: UseEuiTheme['euiTheme'],
- measurement: EuiThemeFontSizeMeasurement = 'rem'
+ measurement: _EuiThemeFontSizeMeasurement = 'rem'
): EuiThemeFontSize => {
return {
fontSize: fontSizeFromScale(scale, euiTheme, measurement),
From c336f0dfec1230542296ceda7eca006a12015a92 Mon Sep 17 00:00:00 2001
From: cchaos
Date: Wed, 13 Apr 2022 01:20:10 -0400
Subject: [PATCH 09/16] More moving files
---
.../views/theme/typography/_typography_js.tsx | 19 +++++++++----------
src/global_styling/index.ts | 1 +
src/global_styling/variables/_typography.ts | 2 ++
3 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/src-docs/src/views/theme/typography/_typography_js.tsx b/src-docs/src/views/theme/typography/_typography_js.tsx
index 270a14219e7..cbf750cdb0b 100644
--- a/src-docs/src/views/theme/typography/_typography_js.tsx
+++ b/src-docs/src/views/theme/typography/_typography_js.tsx
@@ -12,17 +12,16 @@ import {
import {
_EuiThemeFontWeight,
- FONT_SCALES,
-} from '../../../../../src/global_styling/variables/_typography';
-import { euiFontSize } from '../../../../../src/global_styling/mixins/_typography';
-import { _EuiThemeFontSizeMeasurement } from '../../../../../src/global_styling/local_functions/typography';
-import { fontWeight } from '../../../../../src/themes/amsterdam/global_styling/variables/_typography';
+ _EuiThemeFontSizeMeasurement,
+ _EuiThemeFontScale,
+ euiFontSize,
+} from '../../../../../src/global_styling';
import { EuiThemeFontBase, EuiThemeFontWeight, ThemeRowType } from '../_props';
import { getPropsFromComponent } from '../../../services/props/get_props';
+import { getDescription } from '../../../services/props/get_description';
import { ThemeExample } from '../_components/_theme_example';
import { ThemeValuesTable } from '../_components/_theme_values_table';
-import { getDescription } from '../../../services/props/get_description';
export const FontJS = () => {
const { euiTheme } = useEuiTheme();
@@ -87,13 +86,14 @@ export const FontJS = () => {
);
};
-const weightKeys = Object.keys(fontWeight) as Array;
-
export const FontWeightJS: FunctionComponent = ({
description,
}) => {
const { euiTheme } = useEuiTheme();
const weightProps = getPropsFromComponent(EuiThemeFontWeight);
+ const weightKeys = Object.keys(euiTheme.font.weight) as Array<
+ keyof _EuiThemeFontWeight
+ >;
return (
<>
@@ -135,10 +135,9 @@ export const FontWeightJS: FunctionComponent = ({
);
};
-const scaleKeys = FONT_SCALES;
-
export const FontScaleJS = () => {
const { euiTheme } = useEuiTheme();
+ const scaleKeys = Object.keys(euiTheme.font.scale) as _EuiThemeFontScale[];
const measurements: _EuiThemeFontSizeMeasurement[] = ['rem', 'px', 'em'];
diff --git a/src/global_styling/index.ts b/src/global_styling/index.ts
index 2053d3662f5..d9de65bf61a 100644
--- a/src/global_styling/index.ts
+++ b/src/global_styling/index.ts
@@ -8,3 +8,4 @@
export * from './reset/global_styles';
export * from './mixins/_typography';
+export * from './variables/_typography';
diff --git a/src/global_styling/variables/_typography.ts b/src/global_styling/variables/_typography.ts
index 63b46566c6a..209321b091d 100644
--- a/src/global_styling/variables/_typography.ts
+++ b/src/global_styling/variables/_typography.ts
@@ -9,6 +9,8 @@
import { CSSProperties } from 'react';
import { keysOf } from '../../components/common';
+export type _EuiThemeFontSizeMeasurement = 'px' | 'rem' | 'em';
+
/*
* Font scale
*/
From 67a3d978f620623320647c3577e1b764bd64a1e3 Mon Sep 17 00:00:00 2001
From: cchaos
Date: Wed, 13 Apr 2022 01:37:52 -0400
Subject: [PATCH 10/16] Added hook version with default
---
.../views/theme/typography/_typography_js.tsx | 19 ++++++++++---------
src/global_styling/mixins/_typography.ts | 11 ++++++++++-
.../global_styling/variables/title.ts | 2 ++
3 files changed, 22 insertions(+), 10 deletions(-)
diff --git a/src-docs/src/views/theme/typography/_typography_js.tsx b/src-docs/src/views/theme/typography/_typography_js.tsx
index cbf750cdb0b..ac03c4ecd6e 100644
--- a/src-docs/src/views/theme/typography/_typography_js.tsx
+++ b/src-docs/src/views/theme/typography/_typography_js.tsx
@@ -15,6 +15,7 @@ import {
_EuiThemeFontSizeMeasurement,
_EuiThemeFontScale,
euiFontSize,
+ useEuiFontSize,
} from '../../../../../src/global_styling';
import { EuiThemeFontBase, EuiThemeFontWeight, ThemeRowType } from '../_props';
@@ -155,26 +156,26 @@ export const FontScaleJS = () => {
return (
<>
useEuiFontSize()}
description={
- Font sizing is provided through React hooks and not the global
- theme. It returns both the font-size and{' '}
- line-height for the provided{' '}
- scale. But you can still grab an individual
- property via the returned object.
+ Font sizing is provided through this React hook (or function
+ version) and not the global theme. It returns both the{' '}
+ font-size and line-height for
+ the provided scale. But you can still grab an
+ individual property via the returned object.
}
example={
The quick brown fox jumped over the blue moon to catch a snail
}
- snippet="euiFontSize('l');"
+ snippet="useEuiFontSize('l');"
/>
{
items={scaleKeys.map((scale, index) => {
return {
id: scale,
- value: `euiFontSize('${scale}'${
+ value: `useEuiFontSize('${scale}'${
measurementSelected !== 'rem' ? `, '${measurementSelected}'` : ''
})`,
size: `${
diff --git a/src/global_styling/mixins/_typography.ts b/src/global_styling/mixins/_typography.ts
index de3b4da48f1..989780e7e4d 100644
--- a/src/global_styling/mixins/_typography.ts
+++ b/src/global_styling/mixins/_typography.ts
@@ -11,7 +11,7 @@ import {
lineHeightFromBaseline,
fontSizeFromScale,
} from '../local_functions/typography';
-import { UseEuiTheme } from '../../services/theme/hooks';
+import { useEuiTheme, UseEuiTheme } from '../../services/theme/hooks';
import {
_EuiThemeFontScale,
_EuiThemeFontSizeMeasurement,
@@ -35,3 +35,12 @@ export const euiFontSize = (
lineHeight: lineHeightFromBaseline(scale, euiTheme, measurement),
};
};
+
+// Hook version
+export const useEuiFontSize = (
+ scale: _EuiThemeFontScale = 'm',
+ measurement: _EuiThemeFontSizeMeasurement = 'rem'
+): EuiThemeFontSize => {
+ const { euiTheme } = useEuiTheme();
+ return euiFontSize(scale, euiTheme, measurement);
+};
diff --git a/src/themes/amsterdam/global_styling/variables/title.ts b/src/themes/amsterdam/global_styling/variables/title.ts
index ff7f60ae072..e6334bfaa66 100644
--- a/src/themes/amsterdam/global_styling/variables/title.ts
+++ b/src/themes/amsterdam/global_styling/variables/title.ts
@@ -20,6 +20,8 @@ import { computed } from '../../../../services/theme/utils';
// For Amsterdam, change all font-weights to bold and remove letter-spacing
+// TODO: Move to EuiTitle component
+
export const title_ams: EuiThemeTitle = FONT_SCALES.reduce((acc, elem) => {
acc[elem] = {
...title[elem],
From 68b4b0105238acac383a80eb2d56b5aae8ccf112 Mon Sep 17 00:00:00 2001
From: cchaos
Date: Tue, 19 Apr 2022 17:25:48 -0400
Subject: [PATCH 11/16] Docs cleanup
---
.../views/theme/typography/_typography_js.tsx | 24 +++++++++++++++++--
.../src/views/theme/typography/typography.tsx | 12 ++++++++++
2 files changed, 34 insertions(+), 2 deletions(-)
diff --git a/src-docs/src/views/theme/typography/_typography_js.tsx b/src-docs/src/views/theme/typography/_typography_js.tsx
index ac03c4ecd6e..f9d7531904d 100644
--- a/src-docs/src/views/theme/typography/_typography_js.tsx
+++ b/src-docs/src/views/theme/typography/_typography_js.tsx
@@ -162,8 +162,7 @@ export const FontScaleJS = () => {
Font sizing is provided through this React hook (or function
version) and not the global theme. It returns both the{' '}
font-size and line-height for
- the provided scale. But you can still grab an
- individual property via the returned object.
+ the provided scale.
}
example={
@@ -177,6 +176,26 @@ export const FontScaleJS = () => {
}
snippet="useEuiFontSize('l');"
/>
+ useEuiFontSize().fontSize}
+ description={
+
+ To use precisely only the font-size value, you
+ will still use the same hook (or function) to grab the individual
+ property via the returned object.
+
+ }
+ example={
+
+ The quick brown fox jumped over the blue moon to catch a snail
+
+ While these functions and hooks exist to get precise font sizing and
+ associated line-height, we still highly recommend using the{' '}
+
+ EuiText
+ {' '}
+ and{' '}
+
+ EuiTitle
+ {' '}
+ components as wrappers of your content instead.
+
From 7ad158edb8f76e11302069a2d6c671f2a3cbe367 Mon Sep 17 00:00:00 2001
From: cchaos
Date: Tue, 19 Apr 2022 17:53:24 -0400
Subject: [PATCH 12/16] File cleanup
---
src-docs/src/views/theme/_props.tsx | 2 +-
.../__snapshots__/provider.test.tsx.snap | 16 +++++++-------
src/global_styling/functions/index.ts | 9 ++++++++
.../typography.ts | 22 ++++++++-----------
src/global_styling/index.ts | 4 ++--
src/global_styling/mixins/_helpers.ts | 1 -
src/global_styling/mixins/_typography.ts | 12 +++++-----
.../variables/{title.ts => _title.ts} | 2 +-
src/global_styling/variables/index.ts | 10 +++++++++
.../variables/{_shadow.ts => shadow.ts} | 0
.../{_typography.ts => typography.ts} | 0
src/services/theme/types.ts | 2 +-
.../global_styling/mixins/_shadow.ts | 2 +-
.../global_styling/variables/_typography.ts | 2 +-
.../global_styling/variables/title.ts | 4 ++--
15 files changed, 51 insertions(+), 37 deletions(-)
create mode 100644 src/global_styling/functions/index.ts
rename src/global_styling/{local_functions => functions}/typography.ts (86%)
rename src/global_styling/variables/{title.ts => _title.ts} (96%)
create mode 100644 src/global_styling/variables/index.ts
rename src/global_styling/variables/{_shadow.ts => shadow.ts} (100%)
rename src/global_styling/variables/{_typography.ts => typography.ts} (100%)
diff --git a/src-docs/src/views/theme/_props.tsx b/src-docs/src/views/theme/_props.tsx
index efd1cbdd469..844b44ec92f 100644
--- a/src-docs/src/views/theme/_props.tsx
+++ b/src-docs/src/views/theme/_props.tsx
@@ -30,7 +30,7 @@ import {
_EuiThemeFontBase,
_EuiThemeFontWeight,
_EuiThemeFontScale,
-} from '../../../../src/global_styling/variables/_typography';
+} from '../../../../src/global_styling/variables/typography';
export const EuiThemeFontBase: FunctionComponent<_EuiThemeFontBase> = () => (
diff --git a/src/components/provider/__snapshots__/provider.test.tsx.snap b/src/components/provider/__snapshots__/provider.test.tsx.snap
index d4aa0803c0f..d6aad36324f 100644
--- a/src/components/provider/__snapshots__/provider.test.tsx.snap
+++ b/src/components/provider/__snapshots__/provider.test.tsx.snap
@@ -240,10 +240,10 @@ exports[`EuiProvider applying modifications propagates \`modify\` 1`] = `
"featureSettings": "'calt' 1, 'kern' 1, 'liga' 1",
"lineHeightMultiplier": 1.5,
"scale": Object {
- "l": 1.25,
+ "l": 1.375,
"m": 1,
"s": 0.875,
- "xl": 1.75,
+ "xl": 1.6875,
"xs": 0.75,
"xxl": 2.125,
"xxs": 0.6875,
@@ -535,10 +535,10 @@ exports[`EuiProvider changing color modes propagates \`colorMode\` 1`] = `
"featureSettings": "'calt' 1, 'kern' 1, 'liga' 1",
"lineHeightMultiplier": 1.5,
"scale": Object {
- "l": 1.25,
+ "l": 1.375,
"m": 1,
"s": 0.875,
- "xl": 1.75,
+ "xl": 1.6875,
"xs": 0.75,
"xxl": 2.125,
"xxs": 0.6875,
@@ -829,10 +829,10 @@ exports[`EuiProvider is rendered 1`] = `
"featureSettings": "'calt' 1, 'kern' 1, 'liga' 1",
"lineHeightMultiplier": 1.5,
"scale": Object {
- "l": 1.25,
+ "l": 1.375,
"m": 1,
"s": 0.875,
- "xl": 1.75,
+ "xl": 1.6875,
"xs": 0.75,
"xxl": 2.125,
"xxs": 0.6875,
@@ -1123,10 +1123,10 @@ exports[`EuiProvider providing an @emotion cache config applies the cache to glo
"featureSettings": "'calt' 1, 'kern' 1, 'liga' 1",
"lineHeightMultiplier": 1.5,
"scale": Object {
- "l": 1.25,
+ "l": 1.375,
"m": 1,
"s": 0.875,
- "xl": 1.75,
+ "xl": 1.6875,
"xs": 0.75,
"xxl": 2.125,
"xxs": 0.6875,
diff --git a/src/global_styling/functions/index.ts b/src/global_styling/functions/index.ts
new file mode 100644
index 00000000000..dc40cbda36d
--- /dev/null
+++ b/src/global_styling/functions/index.ts
@@ -0,0 +1,9 @@
+/*
+ * 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.
+ */
+
+export * from './typography';
diff --git a/src/global_styling/local_functions/typography.ts b/src/global_styling/functions/typography.ts
similarity index 86%
rename from src/global_styling/local_functions/typography.ts
rename to src/global_styling/functions/typography.ts
index 7bb027c5dff..5f07a0c4408 100644
--- a/src/global_styling/local_functions/typography.ts
+++ b/src/global_styling/functions/typography.ts
@@ -9,22 +9,19 @@
import {
_EuiThemeFontScale,
_EuiThemeFontSizeMeasurement,
-} from '../variables/_typography';
+} from '../variables/typography';
import { UseEuiTheme } from '../../services/theme/hooks';
/**
- *
- *
- *
- * @param base = 16
- * @param scale = full scale
- * @param bodyScale = 's'
- * @param size = 'm'
+ * Calculates the font-size value based on the provided scale key
+ * @param scale - The font scale key
+ * @param theme - Requires the `base` and `font` keys
* @param measurement - The returned string measurement
+ * *
* @returns string - Calculated font-size value
*/
-export function fontSizeFromScale(
+export function euiFontSizeFromScale(
scale: _EuiThemeFontScale,
{ base, font }: UseEuiTheme['euiTheme'],
measurement: _EuiThemeFontSizeMeasurement = 'rem'
@@ -46,15 +43,14 @@ export function fontSizeFromScale(
* EX: A proper line-height for text is 1.5 times the font-size.
* If our base font size (euiFontSize) is 16, and our baseline is 4. To ensure the
* text stays on the baseline, we pass a multiplier to calculate a line-height.
- * @param base - Theme base unit
- * @param font - Requires the `body` and `baseline` values
- * @param scale - The font scale multiplier
+ * @param scale - The font scale key
+ * @param theme - Requires the `base` and `font` keys
* @param measurement - The returned string measurement
* *
* @returns string - Calculated line-height value aligned to baseline
*/
-export function lineHeightFromBaseline(
+export function euiLineHeightFromBaseline(
scale: _EuiThemeFontScale,
{ base, font }: UseEuiTheme['euiTheme'],
measurement: _EuiThemeFontSizeMeasurement = 'rem'
diff --git a/src/global_styling/index.ts b/src/global_styling/index.ts
index 9e69132c532..5fc347eaf52 100644
--- a/src/global_styling/index.ts
+++ b/src/global_styling/index.ts
@@ -7,6 +7,6 @@
*/
export * from './reset/global_styles';
-export * from './variables/_typography';
-export * from './variables/_shadow';
+export * from './functions';
+export * from './variables';
export * from './mixins';
diff --git a/src/global_styling/mixins/_helpers.ts b/src/global_styling/mixins/_helpers.ts
index a8bbb53cc50..2b424f33da2 100644
--- a/src/global_styling/mixins/_helpers.ts
+++ b/src/global_styling/mixins/_helpers.ts
@@ -160,7 +160,6 @@ export const useEuiXScrollWithShadows = createStyleHookFromMixin(
euiXScrollWithShadows
);
-// One hook to rule them all
interface EuiScrollOverflowStyles {
direction?: 'y' | 'x';
mask?: boolean;
diff --git a/src/global_styling/mixins/_typography.ts b/src/global_styling/mixins/_typography.ts
index 989780e7e4d..c67f776249e 100644
--- a/src/global_styling/mixins/_typography.ts
+++ b/src/global_styling/mixins/_typography.ts
@@ -8,14 +8,14 @@
import { CSSProperties } from 'react';
import {
- lineHeightFromBaseline,
- fontSizeFromScale,
-} from '../local_functions/typography';
+ euiLineHeightFromBaseline,
+ euiFontSizeFromScale,
+} from '../functions/typography';
import { useEuiTheme, UseEuiTheme } from '../../services/theme/hooks';
import {
_EuiThemeFontScale,
_EuiThemeFontSizeMeasurement,
-} from '../variables/_typography';
+} from '../variables/typography';
export type EuiThemeFontSize = {
fontSize: CSSProperties['fontSize'];
@@ -31,8 +31,8 @@ export const euiFontSize = (
measurement: _EuiThemeFontSizeMeasurement = 'rem'
): EuiThemeFontSize => {
return {
- fontSize: fontSizeFromScale(scale, euiTheme, measurement),
- lineHeight: lineHeightFromBaseline(scale, euiTheme, measurement),
+ fontSize: euiFontSizeFromScale(scale, euiTheme, measurement),
+ lineHeight: euiLineHeightFromBaseline(scale, euiTheme, measurement),
};
};
diff --git a/src/global_styling/variables/title.ts b/src/global_styling/variables/_title.ts
similarity index 96%
rename from src/global_styling/variables/title.ts
rename to src/global_styling/variables/_title.ts
index fa57d5cd712..ed162098793 100644
--- a/src/global_styling/variables/title.ts
+++ b/src/global_styling/variables/_title.ts
@@ -8,7 +8,7 @@
import { CSSProperties } from 'react';
import { computed } from '../../services/theme/utils';
-import { _EuiThemeFontScale, FONT_SCALES } from './_typography';
+import { _EuiThemeFontScale, FONT_SCALES } from './typography';
/**
* NOTE: These were quick conversions of their Sass counterparts.
diff --git a/src/global_styling/variables/index.ts b/src/global_styling/variables/index.ts
new file mode 100644
index 00000000000..2c8cb28a9ac
--- /dev/null
+++ b/src/global_styling/variables/index.ts
@@ -0,0 +1,10 @@
+/*
+ * 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.
+ */
+
+export * from './typography';
+export * from './shadow';
diff --git a/src/global_styling/variables/_shadow.ts b/src/global_styling/variables/shadow.ts
similarity index 100%
rename from src/global_styling/variables/_shadow.ts
rename to src/global_styling/variables/shadow.ts
diff --git a/src/global_styling/variables/_typography.ts b/src/global_styling/variables/typography.ts
similarity index 100%
rename from src/global_styling/variables/_typography.ts
rename to src/global_styling/variables/typography.ts
diff --git a/src/services/theme/types.ts b/src/services/theme/types.ts
index a19b29fd5a2..a1e9058830c 100644
--- a/src/services/theme/types.ts
+++ b/src/services/theme/types.ts
@@ -15,7 +15,7 @@ import {
EuiThemeBase,
EuiThemeSize,
} from '../../global_styling/variables/_size';
-import { EuiThemeFont } from '../../global_styling/variables/_typography';
+import { EuiThemeFont } from '../../global_styling/variables/typography';
import { _EuiThemeFocus } from '../../global_styling/variables/_states';
export const COLOR_MODES_STANDARD = {
diff --git a/src/themes/amsterdam/global_styling/mixins/_shadow.ts b/src/themes/amsterdam/global_styling/mixins/_shadow.ts
index 104c1107fc5..4374c958391 100644
--- a/src/themes/amsterdam/global_styling/mixins/_shadow.ts
+++ b/src/themes/amsterdam/global_styling/mixins/_shadow.ts
@@ -9,7 +9,7 @@
import { useEuiTheme, UseEuiTheme } from '../../../../services/theme';
import { getShadowColor } from '../functions';
import { createStyleHookFromMixin } from '../../../../global_styling/utils';
-import { _EuiShadowSizes } from '../../../../global_styling/variables/_shadow';
+import { _EuiShadowSizes } from '../../../../global_styling/variables/shadow';
export interface EuiShadowCustomColor {
color?: string;
diff --git a/src/themes/amsterdam/global_styling/variables/_typography.ts b/src/themes/amsterdam/global_styling/variables/_typography.ts
index e253ebb195f..f60cfbb760d 100644
--- a/src/themes/amsterdam/global_styling/variables/_typography.ts
+++ b/src/themes/amsterdam/global_styling/variables/_typography.ts
@@ -11,7 +11,7 @@ import {
EuiThemeFont,
_EuiThemeFontBase,
_EuiThemeFontWeight,
-} from '../../../../global_styling/variables/_typography';
+} from '../../../../global_styling/variables/typography';
// Typographic scale -- loosely based on Major Third (1.250)
export const fontScale = {
diff --git a/src/themes/amsterdam/global_styling/variables/title.ts b/src/themes/amsterdam/global_styling/variables/title.ts
index e6334bfaa66..f7433fc01fa 100644
--- a/src/themes/amsterdam/global_styling/variables/title.ts
+++ b/src/themes/amsterdam/global_styling/variables/title.ts
@@ -14,8 +14,8 @@
import {
title,
EuiThemeTitle,
-} from '../../../../global_styling/variables/title';
-import { FONT_SCALES } from '../../../../global_styling/variables/_typography';
+} from '../../../../global_styling/variables/_title';
+import { FONT_SCALES } from '../../../../global_styling/variables/typography';
import { computed } from '../../../../services/theme/utils';
// For Amsterdam, change all font-weights to bold and remove letter-spacing
From 860aeafb1a58a57207f16a5f2b5a959544f37bdb Mon Sep 17 00:00:00 2001
From: cchaos
Date: Tue, 19 Apr 2022 18:24:24 -0400
Subject: [PATCH 13/16] Better body docs
---
src-docs/src/views/theme/_props.tsx | 4 ++-
.../views/theme/customizing/_typography.js | 35 ++++++++++++++++---
2 files changed, 34 insertions(+), 5 deletions(-)
diff --git a/src-docs/src/views/theme/_props.tsx b/src-docs/src/views/theme/_props.tsx
index 844b44ec92f..f66cba4a72d 100644
--- a/src-docs/src/views/theme/_props.tsx
+++ b/src-docs/src/views/theme/_props.tsx
@@ -30,7 +30,8 @@ import {
_EuiThemeFontBase,
_EuiThemeFontWeight,
_EuiThemeFontScale,
-} from '../../../../src/global_styling/variables/typography';
+ _EuiThemeBody,
+} from '../../../../src/global_styling';
export const EuiThemeFontBase: FunctionComponent<_EuiThemeFontBase> = () => (
@@ -41,6 +42,7 @@ export const EuiThemeFontWeight: FunctionComponent<_EuiThemeFontWeight> = () =>
export const EuiThemeFontScale: FunctionComponent<_EuiThemeFontScale> = () => (
);
+export const EuiThemeBody: FunctionComponent<_EuiThemeBody> = () => ;
import {
_EuiThemeBorderColorValues,
diff --git a/src-docs/src/views/theme/customizing/_typography.js b/src-docs/src/views/theme/customizing/_typography.js
index de63558bd15..a6ec485d064 100644
--- a/src-docs/src/views/theme/customizing/_typography.js
+++ b/src-docs/src/views/theme/customizing/_typography.js
@@ -22,6 +22,7 @@ import {
EuiThemeFontBase,
EuiThemeFontWeight,
EuiThemeFontScale,
+ EuiThemeBody,
} from '../_props';
import { useDebouncedUpdate } from '../hooks';
@@ -52,6 +53,7 @@ export default ({ onThemeUpdate }) => {
const baseProps = getPropsFromComponent(EuiThemeFontBase);
const weightProps = getPropsFromComponent(EuiThemeFontWeight);
const scaleProps = getPropsFromComponent(EuiThemeFontScale);
+ const bodyProps = getPropsFromComponent(EuiThemeBody);
const fontFamilies = fontClone.family.split(',');
const codeFontFamilies = fontClone.familyCode.split(',');
@@ -139,7 +141,7 @@ export default ({ onThemeUpdate }) => {
onUpdate={(value) => updateFont('baseline', value)}
/>
- {/*
+ {
value={font.lineHeightMultiplier}
onUpdate={(value) => updateFont('lineHeightMultiplier', value)}
numberProps={{ step: 0.1 }}
- /> */}
+ />
@@ -225,9 +227,17 @@ export default ({ onThemeUpdate }) => {
groupProps={{ alignItems: 'center' }}
/>
))}
+
-
+
+
+
+