Repository navigation
Closed
Description
This is a draft document meant to start discussion
Problem
- EuiText and EuiMarkdownFormat are very closely related, but currently separate. Furthermore, Kibana utilizes its own markdown formatting which differs between the EUI components as well.
- EUI components often break when included within
EuiText, which we technical suggest not doing, but has proved to be needed over the years. As an example, giving a<p>a margin for everything withinEuiTextcan often break a<p>within another EUI component that has very specific sizing needs.
Requirements
Boiled down, we have the following top level needs if we were to share a component for the various use-cases:
- At a sass mixin / component prop level, we need to optionally support
empercentage styling in addition to defaults that are derived from$euiSizevariables. This is because markdown is used heavily in dynamic, user-created spaces like Canvas, which will require a backwards compatibility layer enforced through a parent font-sizing value of a parent container. - Weed to support modifier based selector sizing for the entire block. This should be supported by passing a
sizeprop onto the component similar to howEuiTextworks today. This would effect the size of the variables used. - Coloring needs to optionally be handled by opacity in addition to defaults derived from
$euiColorvariables. Again, needed for systems where the background color is different like canvas. This could be alternatively handled without opacity, and derived from a single font-color, but this likely wouldn't be achievable with CSS alone. The reason not to just use transparency for everything is that it can contribute to slowdowns in render painting. Usually we only need this alternative method in outliers where more targeted user-control exists. - The full syntax of Github flavored markdown needs to be provided. This means things like table alignment needs to account for naked dom selectors beyond what we currently support in
EuiText. - Needs to account for selectored HTML coming from other components to co-exist with naked HTML. Most of our attempts at making
EuiTextmagical have assuming that the child content is primarily naked HTML. There are pretty good times though when we want to includeEuiComponentsinsideEuiTextand we need to make sure that the margins work correctly. If possible, this should be handled as magically asEuiTextnormally operates, with some clever CSS beyond our current> *methods.
Relationship between EuiText and EuiMarkdownFormat
- EuiText should handle the css styling of naked HTML within an
.euiTextselector. - EuiMarkdownFormat should transform markdown syntax into HTML, and include
EuiTextas the styling mechanism for that HTML.
Pseduo-code sass ideas
At the sass level we probably should have something like:
@mixin euiTextStyle($sizingMethod, $colorMethod, $fontSizeScale, $reverseThemeLayout) {}
sizingMethodacceptsemorpixelas options, which then cascades to the types of units used through the document.colorMethodacceptssolidortranslucentas options, which then cascades to whether to use the flat default coloring, or use transparency values for the various color settings.reverseColorsFromThemeaccepts true / false. This is needed to handle instance where the background might be flipped against what it usually is.fontSizeScaletakes anumbervalue like.75or1.5and adjusts the font sizing and margins accordingly, usingemorpixelvalues as defined bysizingMethod. For the pixel method, it would use mutlipliers against the$euiFontSizebase.
.euiText {
@include euiTextStyle('pixel', 'solid', 1);
}
.euiText--small {
@include euiTextStyle('pixel', 'solid', .75);
}
.euiText--emSmall {
@include euiTextStyle('em', 'translucent', .75);
}
Pseudo-component ideas
On the React side we might see something like:
<EuiText size="small" />
// Would just pass the values down to an inner EuiText component
<EuiMarkdownFormat size="small" />
<EuiText size="small" sizingMethod="em" reverseColorsFromTheme colorMethod="translucent" />
// Which would work the same with EuiMarkdownFormat
<EuiMarkdownFormat size="small" sizingMethod="em" reverseColorsFromTheme colorMethod="translucent" />
Issues to solve
This method, since it's Sass heavy, will duplicate a lot of boilerplate selectors as written above. We might want to look at a more overwrite / cascade method to manage the compile size of the css.
Reacted by Elizabet Oliveira
Metadata
Metadata
Assignees
Labels
No labels
Activity
[-]Consolidate EuiText and EuiMarkdownFormat styling[/-][+][DRAFT] Consolidate EuiText and EuiMarkdownFormat styling[/+]cchaos commentedon Oct 15, 2020
One other thing to consider is how our baselines line up with our
4pxlayout grid.The Amsterdam (@hbharding) team has been discussing some line-height issues we're running into with the smaller Amsterdam font-size and that a
1.5rem->21pxline-height no longer lands on the layout grid. Testing a14pxfont size with a24pxline-height in paragraphs, however, is not an ideal line-height. So I, unfortunately, don't have any good suggestions.Perhaps, we just ensure that our titles which are what tends to sit horizontally next to other components do always line-up with the
4pxgrid no matter if they use EuiTitle or headings within EuiText.cchaos commentedon Dec 2, 2020
I would also like to add that any element that gets bottom margin applied should be caveated with
:not(:last-child). I continue to run into issues where I have text inside of a panel but there's extra space at the bottom causing the overall padding to be off. Example: