Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EuiMarkdownEditor] Improving markdown format styles #3534

Merged
Changes from 4 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
100 changes: 39 additions & 61 deletions src/components/markdown_editor/_markdown_format.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,41 +9,33 @@
// 7. Tables
// 8. Code

// Functions
// Note: The inlined base font size is set in common/functions/font.js. It should match $euiMdFontSize.
$euiDefaultFontSize: 14px;
$browserDefaultFontSize: 16px;

@function canvasToEm($size) {
@return #{$size / $euiDefaultFontSize}em;
// We're setting a function o transform px in em
// because it's easier to think in px
@function em($pixels, $context: $browserDefaultFontSize) {
@return #{$pixels/$context}em;
}

.euiMarkdownFormat {
@include euiFont;
@include euiText;

// Font size variables
$euiMarkdownFontSizeS: canvasToEm(12px);
$euiMarkdownFontSize: canvasToEm(14px);
$euiMarkdownFontSizeL: canvasToEm(20px);
$euiMarkdownFontSizeXL: canvasToEm(28px);
$euiMarkdownFontSizeXXL: canvasToEm(36px);

// Spacing variables
$euiMarkdownSizeL: canvasToEm(24px);
$euiMarkdownSize: canvasToEm(16px);
$euiMarkdownSizeS: canvasToEm(12px);
$euiMarkdownSizeXS: canvasToEm(8px);
$euiMarkdownSizeXXS: canvasToEm(4px);

// Grayscale variables
$euiMarkdownAlphaLightestShade: rgba($euiColorFullShade, .05);
$euiMarkdownAlphaLightShade: rgba($euiColorFullShade, .15);
$euiMarkdownAlphaDarkShade: rgba($euiColorFullShade, .65);

// Reverse grayscale for opposite of theme
$euiMarkdownAlphaLightestShadeReversed: rgba($euiColorEmptyShade, .05);
$euiMarkdownAlphaLightShadeReversed: rgba($euiColorEmptyShade, .15);
$euiMarkdownAlphaDarkShadeReversed: rgba($euiColorEmptyShade, .65);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We likely have a decision to make here. The alpha values are used because Canvas displays markdown on backgrounds of various colors. We can say that Canvas uses it's own styling, or we support it here. Do you have any opinions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should support these scenarios.

$euiMarkdownFontSizeXS: em(12px);
$euiMarkdownFontSizeS: em(14px);
$euiMarkdownFontSize: em(16px);
$euiMarkdownFontSizeM: em(18px);
$euiMarkdownFontSizeL: em(20px);
$euiMarkdownFontSizeXL: em(28px);
$euiMarkdownFontSizeXXL: em(36px);

$euiMarkdownSizeXXS: em(4px);
$euiMarkdownSizeXS: em(8px);
$euiMarkdownSizeS: em(12px);
$euiMarkdownSize: em(16px);
$euiMarkdownSizeL: em(24px);



> *:first-child {
// sass-lint:disable-block no-important
Expand Down Expand Up @@ -79,7 +71,7 @@ $euiDefaultFontSize: 14px;
h5,
h6 {
margin-top: 0;
margin-bottom: $euiMarkdownSizeXS;
margin-bottom: $euiMarkdownSize;
}

h1 {
Expand Down Expand Up @@ -107,13 +99,13 @@ $euiDefaultFontSize: 14px;
}

h5 {
font-size: $euiMarkdownFontSize;
font-size: $euiMarkdownFontSizeS;
line-height: 1.142857em;
font-weight: 700;
}

h6 {
font-size: $euiMarkdownFontSizeS;
font-size: $euiMarkdownFontSizeXS;
line-height: 1.333333em;
font-weight: 700;
text-transform: uppercase;
Expand All @@ -122,7 +114,7 @@ $euiDefaultFontSize: 14px;
h1,
h2 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we get the header values closer to EuiText (doesn't need to be exact). For example. I don't know where the borders came from in this styling.

padding-bottom: .3em;
border-bottom: 1px solid $euiMarkdownAlphaLightShade;
border-bottom: $euiBorderThin;
}

// 3. Images
Expand All @@ -135,11 +127,7 @@ $euiDefaultFontSize: 14px;
// 4. Blockquotes
blockquote {
padding: 0 1em;
border-left: $euiMarkdownSizeXXS solid $euiMarkdownAlphaLightShade;
}

&--reversed blockquote {
border-left-color: $euiMarkdownAlphaLightShadeReversed;
border-left: $euiMarkdownSizeXXS solid $euiBorderColor;
}

// 5. Horizontal rules
Expand All @@ -149,7 +137,7 @@ $euiDefaultFontSize: 14px;
height: 2px;
padding: 0;
margin: $euiMarkdownSizeL 0;
background-color: $euiMarkdownAlphaLightShade;
background-color: $euiBorderColor;
border: none;
}

Expand Down Expand Up @@ -234,7 +222,7 @@ $euiDefaultFontSize: 14px;
display: block;
width: 100%;
overflow: auto;
border-left: 1px solid $euiMarkdownAlphaLightShade;
border-left: 1px solid $euiBorderThin;
border-spacing: 0;
border-collapse: collapse;
}
Expand All @@ -246,49 +234,39 @@ $euiDefaultFontSize: 14px;

table th,
table td {
padding: $euiMarkdownSizeXXS $euiMarkdownSizeS;
border-top: 1px solid $euiMarkdownAlphaLightShade;
border-bottom: 1px solid $euiMarkdownAlphaLightShade;
padding: $euiMarkdownSizeXXS $euiMarkdownSizeXS;
border-top: $euiBorderThin;
border-bottom: $euiBorderThin;

&:last-child {
border-right: 1px solid $euiMarkdownAlphaLightShade;
border-right: $euiBorderThin;
}
}

table tr {
background-color: transparent;
border-top: 1px solid $euiMarkdownAlphaLightShade;
border-top: $euiBorderThin;
}

// 8. Code
.euiMarkdownFormat__code {
// the markdown editor adds a EuiCodeBlock when consumers specify the language
// when no language is specified it gets the .euiMarkdownFormat__code styles
&__code {
@include euiCodeFont;
color: $euiCodeBlockColor;
font-size: $euiFontSizeXS;
font-size: $euiMarkdownFontSizeXS;
padding: $euiMarkdownSizeXXS 0;
margin-bottom: $euiMarkdownSizeXS;
border-radius: $euiMarkdownSizeXXS;
background: $euiCodeBlockBackgroundColor;
}

.euiMarkdownFormat__code::before,
.euiMarkdownFormat__code::after {
letter-spacing: -.2em;
content: '\00a0';
}

// code block
pre .euiMarkdownFormat__code {
// default styles for code blocks
pre &__code {
display: block;
padding: $euiSizeL;
padding: $euiMarkdownFontSizeL;
overflow: visible;
line-height: inherit;
word-wrap: normal;
white-space: pre;
}

pre .euiMarkdownFormat__code::before,
pre .euiMarkdownFormat__code::after {
content: normal;
}
}