Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 1.x] Make font consumption happen using CSS variables #821

Merged
merged 1 commit into from
Jun 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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