Path: blob/main/replay/frontend/src/mixins/typography.ts
1030 views
import { FONT_ROBOTO_REGULAR, FONT_ROBOTO_MEDIUM, FONT_ROBOTO_LIGHT } from '../constants';12export const getLetterSpacing = (fontSize: number, tracking: number) => tracking / fontSize;34export const robotoLight = () => `5font-family: Roboto;6font-weight: 300;7`;89export const robotoRegular = () => `10font-family: Roboto;11font-weight: 400;12`;1314export const robotoMedium = () => `15font-family: Roboto;16font-weight: 500;17`;1819export const h1 = () => `20${robotoLight()};21letter-spacing: ${getLetterSpacing(96, -1.5)}rem;22font-size: 96px;23`;2425export const h2 = () => `26${robotoLight()};27letter-spacing: ${getLetterSpacing(60, -0.5)}rem;28font-size: 60px;29`;3031export const h3 = () => `32${robotoRegular()};33letter-spacing: ${getLetterSpacing(48, 0)}rem;34font-size: 48px;35`;3637export const h4 = () => `38${robotoRegular()};39letter-spacing: ${getLetterSpacing(34, 0.25)}rem;40font-size: 34px;41`;4243export const h5 = () => `44${robotoRegular()};45letter-spacing: ${getLetterSpacing(24, 0)}rem;46font-size: 24px;47`;4849export const h6 = () => `50${robotoMedium()};51letter-spacing: ${getLetterSpacing(20, 0.15)}rem;52font-size: 20px;53`;5455export const subtitle1 = () => `56${robotoRegular()};57letter-spacing: ${getLetterSpacing(16, 0.15)}rem;58font-size: 16px;59`;6061export const subtitle2 = () => `62${robotoMedium()};63letter-spacing: ${getLetterSpacing(14, 0.1)}rem;64font-size: 14px;65`;6667export const body1 = () => `68${robotoRegular()};69letter-spacing: ${getLetterSpacing(16, 0.5)}rem;70font-size: 16px;71`;7273export const body2 = () => `74${robotoRegular()};75letter-spacing: ${getLetterSpacing(14, 0.25)}rem;76font-size: 14px;77`;7879export const button = () => `80${robotoMedium()};81letter-spacing: ${getLetterSpacing(14, 0.75)}rem;82font-size: 14px;83`;8485export const caption = () => `86${robotoRegular()};87letter-spacing: ${getLetterSpacing(12, 0.4)}rem;88font-size: 12px;89`;9091export const overline = () => `92${robotoRegular()};93letter-spacing: ${getLetterSpacing(10, 1.5)}rem;94font-size: 10px;95text-transform: uppercase;96`;9798export const maxLines = (count: number) => `99overflow: hidden;100text-overflow: ellipsis;101display: -webkit-box;102-webkit-line-clamp: ${count};103-webkit-box-orient: vertical;104`;105106export const injectFonts = () => {107const styleElement = document.createElement('style');108109styleElement.textContent = `110@font-face {111font-family: 'Roboto';112font-style: normal;113font-weight: 400;114src: url(${FONT_ROBOTO_REGULAR}) format('woff2');115}116@font-face {117font-family: 'Roboto';118font-style: normal;119font-weight: 500;120src: url(${FONT_ROBOTO_MEDIUM}) format('woff2');121}122@font-face {123font-family: 'Roboto';124font-style: normal;125font-weight: 300;126src: url(${FONT_ROBOTO_LIGHT}) format('woff2');127}128`;129130document.head.appendChild(styleElement);131};132133134