Skip to content

Commit

Permalink
feat: remove Roboto and make it possible to define custom font, defau…
Browse files Browse the repository at this point in the history
…lt to system font

This feature contains the following changes:

docs(README.md): explain how font-related styles should be supplied
fix(index.html): remove Roboto & set examples to use our default font stack
  Before this commit, the documentation used to request Roboto be
  downloaded from Google Fonts. Some components used this font to
  render their UI, while some inherited their font from
  Kompendium's body font. Here we set the default font to our
  cross-browser font stack, and tell all components to render
  their UI with this font and the specified font-related styles
  instead. The following commits will make some components free
  from Roboto.
fix(badge): remove dependency on Roboto font
fix(banner): remove dependency on Roboto font
fix(button): remove dependency on Roboto font
fix(breadcrumbs): render divider properly without dependency to chosen font
  This ensures that the divider character is vertically &
  horizontally center-aligned.
fix(button-group): remove dependency on Roboto font
fix(checkbox): remove dependency on Roboto font
fix(chip-set): remove dependency on Roboto font
fix(code-editor): ensure usage of cross-browser font stack
  This component was only using `monospace` as `font-family`
  to render the code. However, we have a `mixin` which offers
  a better font stack and defaults to more aesthetically pleasing fonts.
  The font stack has `monospace` as its last fallback.
fix(collapsible-section): remove dependency on Roboto font
fix(dialog): remove dependency on Roboto font
fix(header): ensure optimal rendering of fonts
  As heading and subheading fonts are now using
  our font-stack, their `font-weight` had to be adjusted.
fix(helper-line): remove dependency on Roboto font
chore(style/internal): delete unused "helper-text" mixins
  Since we started using `limel-helper-line`, these mixins
  became obsolete. Previously, they were used in all
  components with the helper-line.
fix(input elements): remove dependency on Roboto font
  From now on these component will inherit its
  unspecified font-related styles:
  - input field
  - select
  - picker
  - chipset
  - slider
fix(list, menu): remove dependency on Roboto font
fix(select): ensure optimal rendering of fonts
  As heading is now using our font-stack,
  its `font-weight` had to be adjusted.
fix(select): remove dependency on Roboto font
fix(slider): remove dependency on Roboto font
fix(snackbar): remove dependency on Roboto font
fix(switch): remove dependency on Roboto font
fix(tab-bar): remove dependency on Roboto font
fix(table): remove dependency on Roboto font
fix(form): remove dependency on Roboto font
  Also, this commit ensures if `lime-typography.scss` has been
  imported anywhere that we have missed, or couldn't remove,
  the font-family that are coming from this file would not
  be automatically set to MDC's font stack.
fix(circular-progress): fit in longer values better in `small` & `x-small` sizes
  • Loading branch information
Kiarokh authored and adrianschmidt committed Jan 5, 2024
1 parent 9711f52 commit aab0740
Show file tree
Hide file tree
Showing 31 changed files with 198 additions and 71 deletions.
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,25 @@ For a full list of components, along with live examples, please visit the [docum

#### 1. Font

The "Roboto" font is included for development purposes, but is not included in the published package. This font should be supplied by the consuming application. If not supplied, texts will fall back to suitable alternatives.
To achieve a blazing fast rendering, our components' user interface utilizes a default cross-browser sans-serif font stack. As web components typically inherit font-related styles such as `font-family`, `font-size`, and `color`, we recommend defining these styles at a higher level, such as the `<body>` element. This is because we do not specify these defaults on each individual component.

To maintain consistency with the look & feel demonstrated in this documentation, we suggest incorporating the following styles into your project:

```css
font-family: ui-sans-serif, system-ui, sans-serif;
font-size: 0.875rem;
font-style: normal;
font-weight: 400;
color: rgb(var(--contrast-1500));
```

💡 About the `color` specified above, read more on [our color system](/#/DesignGuidelines/color-system.md/).

Feel free to customize the font-family and related styles to suit your project's needs. For example, you might prefer a different typeface like below:

```css
font-family: 'Roboto', Arial, Verdana, sans-serif;
```

#### 2. Icons

Expand Down
2 changes: 0 additions & 2 deletions src/components/badge/badge.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
@use '../../style/functions';
@use '../../style/internal/lime-theme';
@use '../../style/internal/lime-typography';
@use '../../style/mixins';

/**
Expand All @@ -23,7 +22,6 @@
}

span {
@include lime-typography.base;
cursor: default;
box-sizing: border-box;

Expand Down
2 changes: 0 additions & 2 deletions src/components/banner/banner.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@use '../../style/internal/lime-theme';
@use '../../style/internal/lime-typography';
@use '../../style/internal/variables';
@use '../../style/functions';

Expand All @@ -9,7 +8,6 @@
*/

.lime-banner {
@include lime-typography.typography(body2);
min-height: variables.$lime-banner-height;
display: none;
background-color: rgba(var(--contrast-100), 0.7);
Expand Down
2 changes: 1 addition & 1 deletion src/components/banner/banner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class Banner {
<div class="lime-banner__surface">
<div class="lime-banner__content">
{this.renderIcon()}
<div class="mdc-typography--body2">{this.message}</div>
<div>{this.message}</div>
<div class="lime-banner__actions">
<slot name="buttons" />
</div>
Expand Down
4 changes: 4 additions & 0 deletions src/components/breadcrumbs/breadcrumbs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ ol {

&:after {
content: var(--limel-breadcrumbs-divider);
display: flex;
align-items: center;
justify-content: center;

width: var(--limel-breadcrumbs-gap);

position: absolute;
Expand Down
10 changes: 10 additions & 0 deletions src/components/button-group/button-group.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@
* @prop --button-group-background-color: Background color of the component. Defaults to `--contrast-400`
*/

.mdc-chip {
// As long as this component is depended on MDC,
// we need to force it to be font-agnostic.
// When MDC-dependency is removed, this block can also be removed.
// However, on removal of MDC-dependency, we should also make sure to check
// other font-related styles that might be set by MDC,
// such as `letter-spacing` or `font-size`.
font-family: inherit;
}

.mdc-chip {
@include mixins.is-flat-inset-clickable($background-color: transparent);
max-width: 100%;
Expand Down
16 changes: 12 additions & 4 deletions src/components/button/button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@

@include mixins.visualize-aria-expanded('button');

button.mdc-button {
// As long as this component is depended on MDC,
// we need to force it to be font-agnostic.
// When MDC-dependency is removed, this block can also be removed.
// However, on removal of MDC-dependency, we should also make sure to check
// other font-related styles that might be set by MDC,
// such as `letter-spacing` or `font-size`.
font-family: inherit;
}

button {
display: flex;
align-items: center;
Expand Down Expand Up @@ -76,11 +86,9 @@ button {
}

.label {
font-family: Roboto, sans-serif;
font-size: 0.875rem;
font-weight: 500;
letter-spacing: functions.pxToRem(1);
opacity: 1;
font-weight: 600;
letter-spacing: functions.pxToRem(0.5);
padding: 0 0.25rem;
}

Expand Down
1 change: 1 addition & 0 deletions src/components/callout/callout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,5 @@
.heading {
margin: 0;
font-size: 1rem;
font-weight: 600;
}
10 changes: 10 additions & 0 deletions src/components/checkbox/checkbox.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@
@include checkbox.core-styles;
@include form-field.core-styles;

.mdc-form-field {
// As long as this component is depended on MDC,
// we need to force it to be font-agnostic.
// When MDC-dependency is removed, this block can also be removed.
// However, on removal of MDC-dependency, we should also make sure to check
// other font-related styles that might be set by MDC,
// such as `letter-spacing` or `font-size`.
font-family: inherit;
}

.mdc-form-field {
display: flex;

Expand Down
10 changes: 10 additions & 0 deletions src/components/chip-set/chip-set.scss
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@ $scale-of-remove-chip-x-when-hovered: scale(0.7);
isolation: isolate;
}

.mdc-chip {
// As long as this component is depended on MDC,
// we need to force it to be font-agnostic.
// When MDC-dependency is removed, this block can also be removed.
// However, on removal of MDC-dependency, we should also make sure to check
// other font-related styles that might be set by MDC,
// such as `letter-spacing` or `font-size`.
font-family: inherit;
}

.mdc-chip {
@include mixins.is-elevated-inset-clickable();
max-width: 100%;
Expand Down
8 changes: 8 additions & 0 deletions src/components/circular-progress/circular-progress.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,19 @@
:host([size='x-small']) {
--circular-progress-size: 1.5rem;
font-weight: bold;

.value {
letter-spacing: functions.pxToRem(-1);
}
}

:host([size='small']) {
--circular-progress-size: 2rem;
font-weight: bold;

.value {
letter-spacing: functions.pxToRem(-0.5);
}
}

:host([size='medium']) {
Expand Down
5 changes: 3 additions & 2 deletions src/components/code-editor/code-editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

/**
* @prop --code-editor-max-height: Defines how tall the code editor can get before content becomes scrollable, defaults to `10rem`.
* @prop --code-editor-font-size: Defines the font size of the code, defaults to `0.875rem`.
* @prop --code-editor-font-size: Defines the font size of the code, defaults to `0.8125rem`.
*/

@mixin light-mode-styles {
Expand Down Expand Up @@ -122,7 +122,7 @@

:host {
display: flex;
font-size: var(--code-editor-font-size, 0.875rem); // 14px
font-size: var(--code-editor-font-size, 0.8125rem); // 13px
@include light-mode-styles;
}

Expand All @@ -148,6 +148,7 @@

.cm-s-lime {
&.CodeMirror {
@include mixins.font-family(monospace);
color: rgb(var(--code-editor-neutral-text-color));
background-color: rgb(var(--code-editor-background-color));
border-radius: 0.25rem;
Expand Down
4 changes: 2 additions & 2 deletions src/components/collapsible-section/collapsible-section.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@use '../../style/internal/lime-theme';
@use '../../style/internal/lime-typography';
@use '../../style/mixins';

/**
Expand Down Expand Up @@ -84,7 +83,8 @@ header {
}

.title {
@include lime-typography.typography(headline2);
font-size: 1rem;
font-weight: 300;
color: var(--mdc-theme-on-surface);

justify-self: flex-start;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

* {
box-sizing: border-box;
font-family: 'Roboto';
}
}

Expand Down
10 changes: 10 additions & 0 deletions src/components/dialog/dialog.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ $responsive-body-padding: 3vw; // 3% of viewport's width

@include dialog.core-styles;

.mdc-dialog__content {
// As long as this component is depended on MDC,
// we need to force it to be font-agnostic.
// When MDC-dependency is removed, this block can also be removed.
// However, on removal of MDC-dependency, we should also make sure to check
// other font-related styles that might be set by MDC,
// such as `letter-spacing` or `font-size`.
font-family: inherit;
}

.mdc-dialog {
@include dialog.max-width(16000px, dialog.$margin);

Expand Down
1 change: 0 additions & 1 deletion src/components/form/examples/map-component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
color: rgb(var(--contrast-1100));

font-size: 0.875rem;
font-family: 'Roboto';
}

iframe {
Expand Down
3 changes: 2 additions & 1 deletion src/components/header/header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,13 @@
.heading {
color: var(--header-heading-color, rgb(var(--contrast-1100)));
font-size: functions.pxToRem(17);
font-weight: 500;
}

.subheading {
color: var(--header-subheading-color, rgb(var(--contrast-900)));
font-size: functions.pxToRem(14);
font-weight: lighter;
font-weight: 400;
}

.subheading__supporting-text {
Expand Down
4 changes: 0 additions & 4 deletions src/components/helper-line/helper-line.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@

min-width: 0; // prevents overflowing, if component is placed in flex containers

font-family: Roboto, sans-serif;
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
font-size: 0.6875rem;
font-weight: 400;
letter-spacing: 0.0333333333em; // keeping this for now for consistency, until we get rid of all of them
line-height: normal;

color: rgb(var(--contrast-1200));
}
Expand Down
11 changes: 11 additions & 0 deletions src/components/list/list.scss
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@ $list-mdc-list-item: 0;

@include list.deprecated-core-styles;

.mdc-deprecated-list,
.mdc-deprecated-list-item__secondary-text {
// As long as this component is depended on MDC,
// we need to force it to be font-agnostic.
// When MDC-dependency is removed, this block can also be removed.
// However, on removal of MDC-dependency, we should also make sure to check
// other font-related styles that might be set by MDC,
// such as `letter-spacing` or `font-size`.
font-family: inherit;
}

.mdc-deprecated-list {
--mdc-theme-text-icon-on-background: var(
--icon-color,
Expand Down
4 changes: 4 additions & 0 deletions src/components/portal/portal.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/**
* @prop --limel-portal-font-family: Font family override for the portal. Because the portal is a direct descendant of the body element, any component placed in the portal inherits its font from the body element. If the body's font is not what should be used for the component in the portal, this property can be used to override the font.
*/

:host(limel-portal) {
display: block;
position: absolute;
Expand Down
2 changes: 2 additions & 0 deletions src/components/portal/portal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ export class Portal {
this.container = document.createElement('div');
this.container.setAttribute('id', this.containerId);
this.container.setAttribute('class', 'limel-portal--container');
this.container.style.fontFamily =
'var(--limel-portal-font-family, inherit)';
Object.assign(this.container, {
portalSource: this.host,
});
Expand Down
12 changes: 12 additions & 0 deletions src/components/select/select.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@
left: functions.pxToRem(16);
}

.mdc-select__anchor,
.mdc-floating-label,
.mdc-select__selected-text {
// As long as this component is depended on MDC,
// we need to force it to be font-agnostic.
// When MDC-dependency is removed, this block can also be removed.
// However, on removal of MDC-dependency, we should also make sure to check
// other font-related styles that might be set by MDC,
// such as `letter-spacing` or `font-size`.
font-family: inherit;
}

.mdc-select__dropdown-icon-graphic {
transition: transform 0.2s ease;
}
Expand Down
11 changes: 11 additions & 0 deletions src/components/slider/slider.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@
margin-top: functions.pxToRem(4);
}

.mdc-floating-label,
.mdc-slider .mdc-slider__value-indicator-text {
// As long as this component is depended on MDC,
// we need to force it to be font-agnostic.
// When MDC-dependency is removed, this block can also be removed.
// However, on removal of MDC-dependency, we should also make sure to check
// other font-related styles that might be set by MDC,
// such as `letter-spacing` or `font-size`.
font-family: inherit;
}

.slider__label {
padding-left: functions.pxToRem(20);
top: functions.pxToRem(
Expand Down
10 changes: 10 additions & 0 deletions src/components/snackbar/snackbar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@
gap: 0.75rem;
}

.mdc-snackbar__label {
// As long as this component is depended on MDC,
// we need to force it to be font-agnostic.
// When MDC-dependency is removed, this block can also be removed.
// However, on removal of MDC-dependency, we should also make sure to check
// other font-related styles that might be set by MDC,
// such as `letter-spacing` or `font-size`.
font-family: inherit;
}

.mdc-snackbar__label {
color: rgb(var(--contrast-100));
}
Expand Down
10 changes: 10 additions & 0 deletions src/components/switch/switch.scss
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@ label {
}
}

label {
// As long as this component is depended on MDC,
// we need to force it to be font-agnostic.
// When MDC-dependency is removed, this block can also be removed.
// However, on removal of MDC-dependency, we should also make sure to check
// other font-related styles that might be set by MDC,
// such as `letter-spacing` or `font-size`.
font-family: inherit;
}

.mdc-switch {
&.mdc-switch--selected,
&.mdc-switch.mdc-switch--unselected {
Expand Down
Loading

0 comments on commit aab0740

Please sign in to comment.