Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion packages/eui/src/components/code/code.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,19 @@ import { css } from '@emotion/react';
import {
highContrastModeStyles,
logicalShorthandCSS,
logicalCSS,
euiLineHeightFromBaseline,
} from '../../global_styling';
import { UseEuiTheme } from '../../services';
import { euiCodeSyntaxVariables } from './code_syntax.styles';

export const euiCodeStyles = (euiThemeContext: UseEuiTheme) => {
const codeSyntaxVariables = euiCodeSyntaxVariables(euiThemeContext);
const { euiTheme } = euiThemeContext;
// Get line-height for 's' scale (0.9em relative to parent 'm' scale)
// Since code is 0.9em, we need to calculate line-height based on the effective font size
// Parent is typically 'm' scale, so 0.9em of 'm' is approximately 's' scale
const lineHeight = euiLineHeightFromBaseline('s', euiTheme);

return {
/*
Expand All @@ -25,7 +31,9 @@ export const euiCodeStyles = (euiThemeContext: UseEuiTheme) => {
euiCode: css`
font-family: ${euiTheme.font.familyCode};
font-size: 0.9em; /* 1 */
${logicalShorthandCSS('padding', '0.2em 0.5em')} /* 1 */
line-height: ${lineHeight}; /* Match text line heights */
${logicalCSS('height', '20px')} /* Fixed height of 20px */
${logicalShorthandCSS('padding', '0 0.5em')} /* 1 - Remove vertical padding to maintain 20px height */
background-color: ${codeSyntaxVariables.inlineBackgroundColor};
${highContrastModeStyles(euiThemeContext, {
forced: `
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exports[`euiTextStyles sizes m 1`] = `
"
font-size: 1.1429rem;
line-height: 1.7143rem;
line-height: 1.5714rem;

h1 {
font-size: 2.1429rem;
Expand All @@ -15,7 +15,7 @@ exports[`euiTextStyles sizes m 1`] = `

h2 {
font-size: 1.7143rem;
line-height: 2.0000rem;
line-height: 2.1429rem;

&:not(:first-child) {
margin-block-start: 24px;
Expand All @@ -28,7 +28,7 @@ exports[`euiTextStyles sizes m 1`] = `

h3 {
font-size: 1.4286rem;
line-height: 1.7143rem;
line-height: 1.8571rem;

&:not(:first-child) {
margin-block-start: 24px;
Expand All @@ -41,7 +41,7 @@ exports[`euiTextStyles sizes m 1`] = `

h4 {
font-size: 1.1429rem;
line-height: 1.7143rem;
line-height: 1.5714rem;

&:not(:first-child) {
margin-block-start: 24px;
Expand All @@ -67,7 +67,7 @@ exports[`euiTextStyles sizes m 1`] = `

h6 {
font-size: 0.8571rem;
line-height: 1.1429rem;
line-height: 1.2857rem;

&:not(:first-child) {
margin-block-start: 24px;
Expand All @@ -84,12 +84,12 @@ exports[`euiTextStyles sizes m 1`] = `
pre,
> ul,
> ol {
margin-block-end: 1.7143rem;
margin-block-end: 1.5714rem;
}

ul,
ol {
margin-inline-start: 1.7143rem;
margin-inline-start: 1.5714rem;
}

/* The styles of the nested ordered lists follow the style of GitHub
Expand Down Expand Up @@ -123,7 +123,7 @@ exports[`euiTextStyles sizes m 1`] = `
dt,
.eui-definitionListReverse dd {
font-size: 1.1429rem;
line-height: 1.7143rem;
line-height: 1.5714rem;
}

.eui-definitionListReverse dt {
Expand All @@ -136,7 +136,7 @@ exports[`euiTextStyles sizes m 1`] = `
}

pre:not(.euiCodeBlock__pre) {
padding: 1.7143rem;
padding: 1.5714rem;
}

code:not(.euiCode):not(.euiCodeBlock__code) {
Expand Down Expand Up @@ -165,19 +165,19 @@ exports[`euiTextStyles sizes m 1`] = `
exports[`euiTextStyles sizes relative 1`] = `
"
font-size: 1em;
line-height: 1.5000;
line-height: 1.3750;

h1 {
font-size: 1.875em;
line-height: 1.2495;
line-height: 1.2000;
}
h1:not(:last-child) {
margin-block-end: 12px;
}

h2 {
font-size: 1.5em;
line-height: 1.2495;
line-height: 1.2500;

&:not(:first-child) {
margin-block-start: 24px;
Expand All @@ -190,7 +190,7 @@ exports[`euiTextStyles sizes relative 1`] = `

h3 {
font-size: 1.25em;
line-height: 1.2495;
line-height: 1.3000;

&:not(:first-child) {
margin-block-start: 24px;
Expand All @@ -203,7 +203,7 @@ exports[`euiTextStyles sizes relative 1`] = `

h4 {
font-size: 1em;
line-height: 1.5000;
line-height: 1.3750;

&:not(:first-child) {
margin-block-start: 24px;
Expand All @@ -216,7 +216,7 @@ exports[`euiTextStyles sizes relative 1`] = `

h5 {
font-size: 0.875em;
line-height: 1.5000;
line-height: 1.4286;

&:not(:first-child) {
margin-block-start: 24px;
Expand Down Expand Up @@ -246,12 +246,12 @@ exports[`euiTextStyles sizes relative 1`] = `
pre,
> ul,
> ol {
margin-block-end: 1.5000em;
margin-block-end: 1.3750em;
}

ul,
ol {
margin-inline-start: 1.5000em;
margin-inline-start: 1.3750em;
}

/* The styles of the nested ordered lists follow the style of GitHub
Expand Down Expand Up @@ -285,7 +285,7 @@ exports[`euiTextStyles sizes relative 1`] = `
dt,
.eui-definitionListReverse dd {
font-size: 1em;
line-height: 1.5000;
line-height: 1.3750;
}

.eui-definitionListReverse dt {
Expand All @@ -298,7 +298,7 @@ exports[`euiTextStyles sizes relative 1`] = `
}

pre:not(.euiCodeBlock__pre) {
padding: 1.5000em;
padding: 1.3750em;
}

code:not(.euiCode):not(.euiCodeBlock__code) {
Expand All @@ -316,15 +316,15 @@ exports[`euiTextStyles sizes s 1`] = `

h1 {
font-size: 1.8750rem;
line-height: 2.2857rem;
line-height: 2.1429rem;
}
h1:not(:last-child) {
margin-block-end: 8px;
}

h2 {
font-size: 1.5000rem;
line-height: 1.7143rem;
line-height: 1.8571rem;

&:not(:first-child) {
margin-block-start: 16px;
Expand All @@ -337,7 +337,7 @@ exports[`euiTextStyles sizes s 1`] = `

h3 {
font-size: 1.2500rem;
line-height: 1.4286rem;
line-height: 1.5714rem;

&:not(:first-child) {
margin-block-start: 16px;
Expand All @@ -363,7 +363,7 @@ exports[`euiTextStyles sizes s 1`] = `

h5 {
font-size: 0.8750rem;
line-height: 1.1429rem;
line-height: 1.2857rem;

&:not(:first-child) {
margin-block-start: 16px;
Expand All @@ -376,7 +376,7 @@ exports[`euiTextStyles sizes s 1`] = `

h6 {
font-size: 0.7500rem;
line-height: 1.1429rem;
line-height: 1.2143rem;

&:not(:first-child) {
margin-block-start: 16px;
Expand Down Expand Up @@ -459,19 +459,19 @@ exports[`euiTextStyles sizes s 1`] = `
exports[`euiTextStyles sizes xs 1`] = `
"
font-size: 0.8571rem;
line-height: 1.1429rem;
line-height: 1.2857rem;

h1 {
font-size: 1.6071rem;
line-height: 2.0000rem;
line-height: 2.1429rem;
}
h1:not(:last-child) {
margin-block-end: 4px;
}

h2 {
font-size: 1.2857rem;
line-height: 1.4286rem;
line-height: 1.5714rem;

&:not(:first-child) {
margin-block-start: 8px;
Expand All @@ -497,7 +497,7 @@ exports[`euiTextStyles sizes xs 1`] = `

h4 {
font-size: 0.8571rem;
line-height: 1.1429rem;
line-height: 1.2857rem;

&:not(:first-child) {
margin-block-start: 8px;
Expand All @@ -510,7 +510,7 @@ exports[`euiTextStyles sizes xs 1`] = `

h5 {
font-size: 0.7500rem;
line-height: 1.1429rem;
line-height: 1.2143rem;

&:not(:first-child) {
margin-block-start: 8px;
Expand All @@ -523,7 +523,7 @@ exports[`euiTextStyles sizes xs 1`] = `

h6 {
font-size: 0.6429rem;
line-height: 0.8571rem;
line-height: 1.0000rem;

&:not(:first-child) {
margin-block-start: 8px;
Expand All @@ -540,12 +540,12 @@ exports[`euiTextStyles sizes xs 1`] = `
pre,
> ul,
> ol {
margin-block-end: 1.1429rem;
margin-block-end: 1.2857rem;
}

ul,
ol {
margin-inline-start: 1.1429rem;
margin-inline-start: 1.2857rem;
}

/* The styles of the nested ordered lists follow the style of GitHub
Expand Down Expand Up @@ -579,7 +579,7 @@ exports[`euiTextStyles sizes xs 1`] = `
dt,
.eui-definitionListReverse dd {
font-size: 0.8571rem;
line-height: 1.1429rem;
line-height: 1.2857rem;
}

.eui-definitionListReverse dt {
Expand All @@ -592,7 +592,7 @@ exports[`euiTextStyles sizes xs 1`] = `
}

pre:not(.euiCodeBlock__pre) {
padding: 1.1429rem;
padding: 1.2857rem;
}

code:not(.euiCode):not(.euiCodeBlock__code) {
Expand Down
3 changes: 3 additions & 0 deletions packages/eui/src/components/text/text.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
logicalShorthandCSS,
logicalTextAlignCSS,
euiFontSize,
euiLineHeightFromBaseline,
_FontScaleOptions,
mathWithUnits,
} from '../../global_styling';
Expand Down Expand Up @@ -202,6 +203,8 @@ const euiScaleText = (

code:not(.euiCode):not(.euiCodeBlock__code) {
font-size: .9em; /* 90% of parent font size */
/* Match text line heights - since code is 0.9em relative to parent 'm' scale, use 's' scale line-height */
line-height: ${euiLineHeightFromBaseline('s', euiTheme, options)};
}
${highContrastModeStyles(euiThemeContext, {
// For EuiCodeBlocks, set the margin on the wrapper instead of on the <pre>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ exports[`euiTitle mixin returns a static object of title font properties for eac
"color": "#111C2C",
"fontSize": "2.1429rem",
"fontWeight": 600,
"letterSpacing": "-0.015rem",
"lineHeight": "2.5714rem",
}
`;
Expand All @@ -14,7 +15,8 @@ exports[`euiTitle mixin returns a static object of title font properties for eac
"color": "#111C2C",
"fontSize": "1.7143rem",
"fontWeight": 600,
"lineHeight": "2.0000rem",
"letterSpacing": "-0.01rem",
"lineHeight": "2.1429rem",
}
`;

Expand All @@ -23,7 +25,8 @@ exports[`euiTitle mixin returns a static object of title font properties for eac
"color": "#111C2C",
"fontSize": "1.4286rem",
"fontWeight": 600,
"lineHeight": "1.7143rem",
"letterSpacing": "-0.005rem",
"lineHeight": "1.8571rem",
}
`;

Expand All @@ -32,7 +35,7 @@ exports[`euiTitle mixin returns a static object of title font properties for eac
"color": "#111C2C",
"fontSize": "1.1429rem",
"fontWeight": 600,
"lineHeight": "1.7143rem",
"lineHeight": "1.5714rem",
}
`;

Expand All @@ -50,6 +53,6 @@ exports[`euiTitle mixin returns a static object of title font properties for eac
"color": "#111C2C",
"fontSize": "0.8571rem",
"fontWeight": 600,
"lineHeight": "1.1429rem",
"lineHeight": "1.2857rem",
}
`;
Loading