Skip to content

Commit

Permalink
Replace usage of $ouiFontFamily and $ouiCodeFontFamily with `--ou…
Browse files Browse the repository at this point in the history
…i-font-family` and `--oui-code-font-family` CSS variables (#814)

Signed-off-by: Miki <[email protected]>
  • Loading branch information
AMoo-Miki authored Jun 19, 2023
1 parent 27a5a29 commit a0e0bb5
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/components/suggest/_suggest_item.scss
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@

.ouiSuggestItem__label {
@include ouiTextTruncate;
font-family: $ouiCodeFontFamily;
font-family: var(--oui-code-font-family);
overflow: hidden;
text-overflow: ellipsis;
padding: $ouiSizeXS $ouiSizeS;
Expand Down
9 changes: 9 additions & 0 deletions src/global_styling/css_variables/_fonts.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*!
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

:root {
--oui-font-family: #{$ouiFontFamily};
--oui-code-font-family: #{$ouiCodeFontFamily};
}
6 changes: 6 additions & 0 deletions src/global_styling/css_variables/_index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/*!
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

@import 'fonts';
3 changes: 3 additions & 0 deletions src/global_styling/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,8 @@
// Utility classes provide one-off selectors for common css problems
@import 'utility/index';

// CSS variables of SCSS variables
@import 'css_variables/index';

// The reset file makes use of variables and mixins
@import 'reset/index';
4 changes: 2 additions & 2 deletions src/global_styling/mixins/_typography.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// Our base fonts

@mixin ouiFont {
font-family: $ouiFontFamily;
font-family: var(--oui-font-family);
font-weight: $ouiFontWeightRegular;
letter-spacing: -.005em;
-webkit-text-size-adjust: 100%;
Expand All @@ -24,7 +24,7 @@
}

@mixin ouiCodeFont {
font-family: $ouiCodeFontFamily;
font-family: var(--oui-code-font-family);
letter-spacing: normal;
}

Expand Down
4 changes: 2 additions & 2 deletions src/global_styling/reset/_reset.scss
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ time, mark, audio, video {
}

code, pre, kbd, samp {
font-family: $ouiCodeFontFamily;
font-family: var(--oui-code-font-family);
}

h1, h2, h3, h4, h5, h6, p {
Expand All @@ -51,7 +51,7 @@ h1, h2, h3, h4, h5, h6, p {
}

input, textarea, select, button {
font-family: $ouiFontFamily;
font-family: var(--oui-font-family);
}

em {
Expand Down
6 changes: 4 additions & 2 deletions src/global_styling/variables/_typography.scss
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@
}

// Families
$ouiFontFamily: 'Inter UI', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol' !default;
$ouiCodeFontFamily: 'Roboto Mono', Consolas, Menlo, Courier, monospace !default;
// sass-lint:disable quotes
$ouiFontFamily: #{"'Inter UI', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'"} !default;
$ouiCodeFontFamily: #{"'Roboto Mono', Consolas, Menlo, Courier, monospace"} !default;
// sass-lint:enable quotes

// Careful using ligatures. Code editors like ACE will often error because of width calculations
$ouiFontFeatureSettings: 'calt' 1, 'kern' 1, 'liga' 1 !default;
Expand Down

0 comments on commit a0e0bb5

Please sign in to comment.