const generator = document.getElementById("generator"); generator.innerHTML = `

Generator

Sizes
Base color
Fonts



Border style

`;

const generatorFields = {
  baseScale: document.getElementById("g_base-scale"),
  documentWidth: document.getElementById("g_document-width"),

  baseColor: {
    hue: document.getElementById("g_base-color_hue"),
    sat: document.getElementById("g_base-color_sat"),
  },

  fontFamily: document.getElementById("g_font-family"),
  fontWeight: document.getElementById("g_font-weight"),
  headerFontFamily: document.getElementById("g_header-font-family"),
  headerFontWeight: document.getElementById("g_header-font-weight"),

  borderWidth: document.getElementById("g_border-width"),
  borderStyle: document.getElementById("g_border-style"),
  borderRadius: document.getElementById("g_border-radius"),
};

const generatorOutputs = {
  view: document.getElementById("go_view"),
  code: document.getElementById("go_code"),
}

generatorFields.baseScale.addEventListener('change', preview);
generatorFields.documentWidth.addEventListener('change', preview);
generatorFields.baseColor.hue.addEventListener('input', preview);
generatorFields.baseColor.sat.addEventListener('input', preview);
generatorFields.fontFamily.addEventListener('change', preview);
generatorFields.fontWeight.addEventListener('input', preview);
generatorFields.headerFontFamily.addEventListener('change', preview);
generatorFields.headerFontWeight.addEventListener('input', preview);
generatorFields.borderWidth.addEventListener('change', preview);
generatorFields.borderStyle.addEventListener('change', preview);
generatorFields.borderRadius.addEventListener('change', preview);

function generateNormalizeCode() {
  return `:root {
    --base-scale: ${generatorFields.baseScale.value}rem;
    --document-width: ${generatorFields.documentWidth.value}em;

    --base-color: ${generatorFields.baseColor.hue.value}, ${generatorFields.baseColor.sat.value}%;

    --font-family: ${generatorFields.fontFamily.value};
    --font-weight: ${generatorFields.fontWeight.value};
    --header-font-family: ${generatorFields.headerFontFamily.value};
    --header-font-weight: ${generatorFields.headerFontWeight.value};

    --border-width: calc(${generatorFields.borderWidth.value}em / 16);
    --border-style: ${generatorFields.borderStyle.value};
    --border-radius: calc(${generatorFields.borderRadius.value}em / 16);
  }`
}

generatorOutputs.view.srcdoc = `

  
    
    Normalize Style
    
    
    
  
  
    

Hello, world!

This is a test.

Form


`; function preview() { const css = generateNormalizeCode(); generatorOutputs.view.contentDocument.getElementById("csshere").innerHTML = css; generatorOutputs.code.textContent = ` Normalize Style `; } generatorOutputs.view.addEventListener("load", preview);