Skip to content

Commit

Permalink
Updating euiTitle mixin to add rem valued line-heights
Browse files Browse the repository at this point in the history
- The mixin also recommends using the same prop names as EuiTitle as arguments (ie β€œxs”, β€œm”, β€œl”)
- Added another mid-way font weight
- Updated docs
  • Loading branch information
cchaos committed Apr 4, 2018
1 parent a649065 commit 1aa1725
Show file tree
Hide file tree
Showing 14 changed files with 96 additions and 83 deletions.
13 changes: 13 additions & 0 deletions src-docs/src/views/title/title.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,46 @@ import React from 'react';
import {
EuiTitle,
EuiHorizontalRule,
EuiSpacer,
EuiCode,
} from '../../../../src/components';

export default () => (
<div>
<EuiTitle size="l">
<h1>This is a large title, only one should exist per page</h1>
</EuiTitle>
<EuiCode>size=&quot;l&quot;</EuiCode>

<EuiSpacer />
<EuiTitle>
<h2>This is the default size for title</h2>
</EuiTitle>
<EuiCode>size=&quot;m&quot;</EuiCode>

<EuiSpacer />
<EuiTitle size="s">
<h3>This is a small title</h3>
</EuiTitle>
<EuiCode>size=&quot;s&quot;</EuiCode>

<EuiSpacer />
<EuiTitle size="xs">
<h4>This is an extra small title</h4>
</EuiTitle>
<EuiCode>size=&quot;xs&quot;</EuiCode>

<EuiSpacer />
<EuiTitle size="xxs">
<h5>This is an extra extra small title</h5>
</EuiTitle>
<EuiCode>size=&quot;xxs&quot;</EuiCode>

<EuiSpacer />
<EuiTitle size="xxxs">
<h6>This is an extra extra extra small title and should only be used when the title is inconsequential (like a label)</h6>
</EuiTitle>
<EuiCode>size=&quot;xxxs&quot;</EuiCode>

<EuiHorizontalRule />

Expand Down
7 changes: 4 additions & 3 deletions src/components/call_out/_call_out.scss
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ $callOutTypes: (
* 3. Apply margin to all but last item in the flex.
*/
.euiCallOutHeader {
@include euiTitle($euiFontSize);
font-weight: 500;
@include euiTitle("xs");
font-weight: $euiFontWeightRegular;
display: flex;
align-items: baseline; /* 1 */

Expand All @@ -54,7 +54,8 @@ $callOutTypes: (

// smaller font size for headers in small callout
.euiCallOut--small & {
@include euiTitle($euiFontSizeS);
@include euiTitle("xxs");
font-weight: $euiFontWeightRegular;
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/components/description_list/_description_list.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
&.euiDescriptionList--row {

.euiDescriptionList__title {
@include euiTitle($euiFontSize);
@include euiTitle("xs");
margin-top: $euiSize;

// Make sure the first <dt> doesn't get a margine.
Expand All @@ -29,7 +29,7 @@
&.euiDescriptionList--compressed {

.euiDescriptionList__title {
@include euiTitle($euiFontSizeS);
@include euiTitle("xxs");
}

.euiDescriptionList__description {
Expand All @@ -54,7 +54,7 @@
}

.euiDescriptionList__title {
@include euiTitle($euiFontSize);
@include euiTitle("xs");
flex-basis: 50%;
padding-right: $euiSizeS;
}
Expand All @@ -76,7 +76,7 @@
&.euiDescriptionList--compressed {

.euiDescriptionList__title {
@include euiTitle($euiFontSizeS);
@include euiTitle("xxs");
}

.euiDescriptionList__description {
Expand Down
2 changes: 1 addition & 1 deletion src/components/modal/_modal.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ $euiModalBorderColor: tintOrShade($euiShadowColorLarge, 50%, 0%) !default; // ma
}

.euiModalHeader__title {
@include euiTitle($euiFontSizeXL);
@include euiTitle("m");
}

.euiModalBody {
Expand Down
3 changes: 2 additions & 1 deletion src/components/popover/_mixins.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@mixin euiPopoverTitle {
@include euiTitle($euiFontSize);
@include euiTitle("xs");
font-weight: $euiFontWeightMid;
background-color: $euiColorLightestShade;
padding: $euiSizeM;

Expand Down
2 changes: 1 addition & 1 deletion src/components/side_nav/_side_nav_item.scss
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
}

.euiSideNavItemButton__label {
@include euiTitle($euiFontSize);
@include euiTitle("xs");
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/components/steps/_steps.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
}

.euiStep__title {
font-weight: $euiFontWeightRegular;
font-weight: $euiFontWeightMid;

&::before {
content: attr(data-step-num); // Get the number from the data attribute
Expand All @@ -26,7 +26,7 @@

.euiStep__content {
border-left: $euiBorderThick;
padding: $euiSize;
padding: $euiSize $euiSize $euiSizeXL;
margin: $euiSizeS 0;

// Align the content's contents with the title
Expand Down
2 changes: 1 addition & 1 deletion src/components/steps/_steps_horizontal.scss
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@

.euiStepHorizontal__title {
display: block;
@include euiTitle($euiFontSize);
@include euiTitle("xs");
margin-top: $euiSizeS;
font-weight: $euiFontWeightRegular;

Expand Down
5 changes: 3 additions & 2 deletions src/components/table/_table.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@

.euiTableHeaderCell {
@include euiTableCell;

color: $euiTitleColor;
@include euiTitle("xxs");
font-weight: $euiFontWeightMedium;

.euiTableHeaderButton {
text-align: left;
font-weight: $euiFontWeightMedium;
}
}

Expand Down
37 changes: 14 additions & 23 deletions src/components/text/_text.scss
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
// This should only be used for .euiText, therefore it's not included in a separate mixin file
@mixin euiScaleText($baseFontSize) {
$baseLineHeightMultiplier: $baseFontSize/2;
line-height: convertToRem($baseLineHeightMultiplier*3);

p,
ul,
ol,
blockquote,
img {
margin-bottom: convertToRem($baseLineHeightMultiplier * 4);
margin-bottom: convertToRem($baseLineHeightMultiplier * 3);
}

ul, ol {
margin-left: convertToRem($baseLineHeightMultiplier * 4);
margin-left: convertToRem($baseLineHeightMultiplier * 3);
}

blockquote {
Expand All @@ -36,24 +37,19 @@
margin-top: convertToRem($baseLineHeightMultiplier * 4);
}

/**
* 1. Set line-height to a muliplier of the base line height without being under the font-size.
*/

h1 {
font-size: convertToRem($baseFontSize * nth($euiTextScale, 1));
line-height: convertToRem($baseLineHeightMultiplier * 6); /* 1 */
line-height: convertToRem($baseLineHeightMultiplier * 6);
}

h2 {
font-size: convertToRem($baseFontSize * nth($euiTextScale, 2));
line-height: convertToRem($baseLineHeightMultiplier * 5); /* 1 */
line-height: convertToRem($baseLineHeightMultiplier * 5);
}

h3 {
font-size: convertToRem($baseFontSize * nth($euiTextScale, 3));
line-height: convertToRem($baseLineHeightMultiplier * 4); /* 1 */
font-weight: $euiFontWeightMedium;
line-height: convertToRem($baseLineHeightMultiplier * 4);
}

h4 {
Expand All @@ -68,7 +64,6 @@
h6 {
font-size: convertToRem($baseFontSize * nth($euiTextScale, 7));
line-height: convertToRem($baseLineHeightMultiplier * 2);
text-transform: uppercase;
}

small {
Expand Down Expand Up @@ -134,44 +129,40 @@
}
}

/**
* 1. Customize font size to be a percentage of the .euiText container's base font size (easy scaling)
*/
h1 {
@include euiTitle($euiFontSizeXXL);
@include euiTitle("l");
}

h2 {
@include euiTitle($euiFontSizeXL);
@include euiTitle("m");
}

h3 {
@include euiTitle($euiFontSizeL);
font-weight: $euiFontWeightMedium;
@include euiTitle("s");
}

h4 {
@include euiTitle($euiFontSize);
@include euiTitle("xs");
}

h5 {
@include euiTitle($euiFontSizeS);
@include euiTitle("xxs");
}

h6 {
@include euiTitle($euiFontSizeXS);
@include euiTitle("xxxs");
text-transform: uppercase;
}

@include euiScaleText($euiFontSize);

&.euiText--small {
@include euiFontSizeS;
@include fontSize($euiFontSizeS);
@include euiScaleText($euiFontSizeS);
}

&.euiText--extraSmall {
@include euiFontSizeXS;
@include fontSize($euiFontSizeXS);
@include euiScaleText($euiFontSizeXS);
}

Expand Down
12 changes: 6 additions & 6 deletions src/components/title/_title.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,25 @@
}

.euiTitle--xxxsmall {
@include euiTitle($euiFontSizeXS);
@include euiTitle("xxxs");
}

.euiTitle--xxsmall {
@include euiTitle($euiFontSizeS);
@include euiTitle("xxs");
}

.euiTitle--xsmall {
@include euiTitle($euiFontSize);
@include euiTitle("xs");
}

.euiTitle--small {
@include euiTitle($euiFontSizeL);
@include euiTitle("s");
}

.euiTitle--medium {
@include euiTitle($euiFontSizeXL);
@include euiTitle("m");
}

.euiTitle--large {
@include euiTitle($euiFontSizeXXL);
@include euiTitle("l");
}
4 changes: 2 additions & 2 deletions src/components/toast/_toast.scss
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ $toastTypes: (
* 3. Account for close button.
*/
.euiToastHeader {
@include euiFontSizeM;
padding-right: $euiSizeL; /* 3 */

display: flex;
Expand All @@ -90,7 +89,8 @@ $toastTypes: (
}

.euiToastHeader__title {
@include euiTitle;
@include euiTitle("s");
font-weight: $euiFontWeightLight;
}

.euiToastHeader--withBody {
Expand Down
Loading

0 comments on commit 1aa1725

Please sign in to comment.