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

Signed-off-by: Miki <miki@amazon.com>
  • Loading branch information
AMoo-Miki committed Jun 16, 2023
1 parent cfda69d commit 14c9d2a
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 10 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,15 +15,15 @@
// Our base fonts

@mixin ouiFont {
font-family: $ouiFontFamily;
font-family: var(--oui-font-family);
font-weight: $ouiFontWeightRegular;
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%;
font-kerning: normal;
}

@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: 'Source Sans 3', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol' !default;
$ouiCodeFontFamily: 'Source Code Pro', Consolas, Menlo, Courier, monospace !default;
// sass-lint:disable quotes
$ouiFontFamily: #{"'Source Sans 3', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'"} !default;
$ouiCodeFontFamily: #{"'Source Code Pro', 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
3 changes: 3 additions & 0 deletions src/themes/oui-cascadia/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 '../../../global_styling/utility/index';

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

// The reset file makes use of variables and mixins
@import 'reset/index';
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

// Redoing this mixin mainly to remove the letter-spacing
@mixin ouiFont {
font-family: $ouiFontFamily;
font-family: var(--oui-font-family);
font-weight: $ouiFontWeightRegular;
letter-spacing: normal;
-webkit-text-size-adjust: 100%;
Expand Down
4 changes: 2 additions & 2 deletions src/themes/oui-cascadia/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

0 comments on commit 14c9d2a

Please sign in to comment.