Skip to content

Instantly share code, notes, and snippets.

@SvenBudak
SvenBudak / color-scheme.service.ts
Last active January 20, 2022 16:54
Angular Service for setting class in <body> tag for prefers-color-scheme
import {Injectable, Renderer2, RendererFactory2} from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class ColorSchemeService {
private renderer: Renderer2;
private colorScheme: string;
// Define prefix for clearer and more readable class names in scss files
@import "rfs";
@import "functions/px-to-em";
// Typography
@mixin h1-style() {
@include rfs(48);
font-weight: 700;
line-height: em(56, 48);
}
h1, .h1-style {
@include h1-style();
}
h2, .h2-style {
@include h2-style();
}
h3, .h3-style {
@include h3-style();
$prefix: 'fs';
button, a {
&[#{$prefix}-size="normal"] {
padding: 0 32px;
font-size: 18px;
font-weight: 500;
line-height: 48px;
}