Skip to content

Commit

Permalink
[K7] Font sizing, weights, families and mixins (elastic#12879)
Browse files Browse the repository at this point in the history
Sets up mixins and placeholders for typography.
  • Loading branch information
snide authored and cjcenizal committed Aug 16, 2017
1 parent d5d1645 commit a6c35b7
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 10 deletions.
6 changes: 5 additions & 1 deletion style_guides/scss_style_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,8 @@ Our style guide is an extension of [Sass Guidelines by Hugo Giraudel](https://sa
## Syntax and formatting

The Sass Guidelines site recommends using RBG and HSL values to format colors, but we're using
hex values.
hex values.

## Dealing with extends

Don't extend classes. The only time use should use an extend is when you are extending a placeholder. Even then, do it rarely and only for code maintainability.
1 change: 1 addition & 0 deletions ui_framework/components/global_styles/mixins/_index.scss
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
@import 'naming';
@import 'responsive';
@import 'typography';
63 changes: 63 additions & 0 deletions ui_framework/components/global_styles/mixins/_typography.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Some mixins that help us deal with browser scaling of text more consistantly.
// Essentially, fonts across kui should scale agains the root html element, not
// against parent inheritance.


// Typography mixins

@function convertToRem($size) {
@return #{$size / $kuiFontSize}rem;
}

// Spit out rem and px. This helps out people who might be on older versions of IE (<11).

@mixin fontSize($size: $kuiFontSize) {
font-size: $size;
font-size: convertToRem($size);
}

%kuiFont {
font-family: $kuiFontFamily;
font-weight: $kuiFontWeightRegular;
}

%kuiCodeFont {
font-family: $kuiCodeFontFamily;
}

// Font sizing extends, using rem mixin

%kuiFontSize {
@include fontSize($kuiFontSize);
line-height: $kuiLineHeight;
}

%kuiFontSizeXS {
@include fontSize($kuiFontSizeXS);
line-height: $kuiLineHeight;
}

%kuiFontSizeS {
@include fontSize($kuiFontSizeS);
line-height: $kuiLineHeight;
}

%kuiFontSizeM {
@include fontSize($kuiFontSizeM);
line-height: $kuiLineHeight;
}

%kuiFontSizeL {
@include fontSize($kuiFontSizeL);
line-height: $kuiLineHeight * 1.5;
}

%kuiFontSizeXL {
@include fontSize($kuiFontSizeXL);
line-height: $kuiLineHeight * 2;
}

%kuiFontSizeXXL {
@include fontSize($kuiFontSizeXXL);
line-height: $kuiLineHeight * 3;
}
25 changes: 25 additions & 0 deletions ui_framework/components/global_styles/variables/_typography.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Font

// Families
$kuiFontFamily: "Roboto", Helvetica, Arial, sans-serif;
$kuiCodeFontFamily: "Roboto Mono", monospace;

// Font sizes
$kuiFontSize: $kuiSize;

$kuiFontSizeXS: 12px;
$kuiFontSizeS: 14px;
$kuiFontSizeM: $kuiFontSize;
$kuiFontSizeL: 24px;
$kuiFontSizeXL: 32px;
$kuiFontSizeXXL: 48px;

// Line height

$kuiLineHeight: 1.5 * $kuiFontSize;

// Font weights

$kuiFontWeightLight: 300;
$kuiFontWeightRegular: 400;
$kuiFontWeightMedium: 500;
13 changes: 5 additions & 8 deletions ui_framework/components/global_styles/variables/_z_index.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Z-Index


$kuiZLevel0: 0;
$kuiZLevel1: 1000;
$kuiZLevel2: 2000;
Expand All @@ -12,10 +11,8 @@ $kuiZLevel7: 7000;
$kuiZLevel8: 8000;
$kuiZLevel9: 9000;



$kuiZContent: 0;
$kuiZContentMenu: 2000;
$kuiZNavigation: 4000;
$kuiZMask: 6000;
$kuiZModal: 8000;
$kuiZContent: $kuiZLevel0;
$kuiZContentMenu: $kuiZLevel2;
$kuiZNavigation: $kuiZLevel4;
$kuiZMask: $kuiZLevel6;
$kuiZModal: $kuiZLevel8;
2 changes: 1 addition & 1 deletion ui_framework/src/global_styling/variables/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
@import 'size';
@import 'colors';
@import 'animations';
@import 'font';
@import 'typography';
@import 'borders';
@import 'shadows';
@import 'z_index';

0 comments on commit a6c35b7

Please sign in to comment.