Skip to content

Instantly share code, notes, and snippets.

View jacubsmith's full-sized avatar

Jake Smith jacubsmith

  • London
View GitHub Profile
@jacubsmith
jacubsmith / Render Styled
Last active February 18, 2021 15:26
Renders React element and Styled Components (Typescript) into plain HTML and CSS
import 'regenerator-runtime/runtime';
import React from 'react';
import fs from 'fs';
import path from 'path';
import ReactDomServer from 'react-dom/server';
import { ServerStyleSheet, ThemeProvider } from 'styled-components';
import theme from '../theme';
import Fallback from '../routes/Fallback';
const Fallback = () => (
// Convert pixels to ems
// eg. for a relational value of 12px write em(12) when the parent is 16px
// if the parent is another value say 24px write em(12, 24)
@function em($pxval, $base: $fzBase) {
@return ($pxval / $base) * 1em;
}