From bf8b13113a74cadd438ed88dc8dd4fb2546f180a Mon Sep 17 00:00:00 2001 From: James Mills <1290234+prologic@users.noreply.github.com> Date: Thu, 16 Mar 2023 17:45:05 +1000 Subject: [PATCH] Add pre and post hooks and live.js with navbar --- .zs/layout.html | 14 +- .zs/posthook | 12 + .zs/prehook | 3 + css/simple.css | 651 ++++++++++++++++++++++++++++++++++++++++++++++++ css/style.css | 11 + index.md | 19 +- js/live.js | 233 +++++++++++++++++ simple.css | 492 ------------------------------------ simple.min.css | 1 - 9 files changed, 929 insertions(+), 507 deletions(-) create mode 100755 .zs/posthook create mode 100755 .zs/prehook create mode 100644 css/simple.css create mode 100644 css/style.css create mode 100644 js/live.js delete mode 100644 simple.css delete mode 100644 simple.min.css diff --git a/.zs/layout.html b/.zs/layout.html index 6c08173..d5741d3 100644 --- a/.zs/layout.html +++ b/.zs/layout.html @@ -3,7 +3,8 @@ - + + @@ -13,8 +14,16 @@ +
+ +

zs starter template

+

A zs starter template

+
{{ content }}
-
+ diff --git a/.zs/posthook b/.zs/posthook new file mode 100755 index 0000000..0c2ceae --- /dev/null +++ b/.zs/posthook @@ -0,0 +1,12 @@ +#!/bin/sh + +set -e + +minify -o "$ZS_OUTDIR/css/simple.min.css" "$ZS_OUTDIR/css/simple.css" +rm "$ZS_OUTDIR/css/simple.css" + +minify -o "$ZS_OUTDIR/css/style.min.css" "$ZS_OUTDIR/css/style.css" +rm "$ZS_OUTDIR/css/style.css" + +minify -o "$ZS_OUTDIR/js/live.min.js" "$ZS_OUTDIR/js/live.js" +rm "$ZS_OUTDIR/js/live.js" diff --git a/.zs/prehook b/.zs/prehook new file mode 100755 index 0000000..c52d3c2 --- /dev/null +++ b/.zs/prehook @@ -0,0 +1,3 @@ +#!/bin/sh + +exit 0 diff --git a/css/simple.css b/css/simple.css new file mode 100644 index 0000000..60d747f --- /dev/null +++ b/css/simple.css @@ -0,0 +1,651 @@ +/* Global variables. */ +:root { + /* Set sans-serif & mono fonts */ + --sans-font: -apple-system, BlinkMacSystemFont, "Avenir Next", Avenir, + "Nimbus Sans L", Roboto, "Noto Sans", "Segoe UI", Arial, Helvetica, + "Helvetica Neue", sans-serif; + --mono-font: Consolas, Menlo, Monaco, "Andale Mono", "Ubuntu Mono", monospace; + --standard-border-radius: 5px; + + /* Default (light) theme */ + --bg: #fff; + --accent-bg: #f5f7ff; + --text: #212121; + --text-light: #585858; + --border: #898EA4; + --accent: #0d47a1; + --code: #d81b60; + --preformatted: #444; + --marked: #ffdd33; + --disabled: #efefef; +} + +/* Dark theme */ +@media (prefers-color-scheme: dark) { + :root { + color-scheme: dark; + --bg: #212121; + --accent-bg: #2b2b2b; + --text: #dcdcdc; + --text-light: #ababab; + --accent: #ffb300; + --code: #f06292; + --preformatted: #ccc; + --disabled: #111; + } + /* Add a bit of transparency so light media isn't so glaring in dark mode */ + img, + video { + opacity: 0.8; + } +} + +/* Reset box-sizing */ +*, *::before, *::after { + box-sizing: border-box; +} + +/* Reset default appearance */ +textarea, +select, +input, +progress { + appearance: none; + -webkit-appearance: none; + -moz-appearance: none; +} + +html { + /* Set the font globally */ + font-family: var(--sans-font); + scroll-behavior: smooth; +} + +/* Make the body a nice central block */ +body { + color: var(--text); + background-color: var(--bg); + font-size: 1.15rem; + line-height: 1.5; + display: grid; + grid-template-columns: 1fr min(45rem, 90%) 1fr; + margin: 0; +} +body > * { + grid-column: 2; +} + +/* Make the header bg full width, but the content inline with body */ +body > header { + background-color: var(--accent-bg); + border-bottom: 1px solid var(--border); + text-align: center; + padding: 0 0.5rem 2rem 0.5rem; + grid-column: 1 / -1; +} + +body > header h1 { + max-width: 1200px; + margin: 1rem auto; +} + +body > header p { + max-width: 40rem; + margin: 1rem auto; +} + +/* Add a little padding to ensure spacing is correct between content and header > nav */ +main { + padding-top: 1.5rem; +} + +body > footer { + margin-top: 4rem; + padding: 2rem 1rem 1.5rem 1rem; + color: var(--text-light); + font-size: 0.9rem; + text-align: center; + border-top: 1px solid var(--border); +} + +/* Format headers */ +h1 { + font-size: 3rem; +} + +h2 { + font-size: 2.6rem; + margin-top: 3rem; +} + +h3 { + font-size: 2rem; + margin-top: 3rem; +} + +h4 { + font-size: 1.44rem; +} + +h5 { + font-size: 1.15rem; +} + +h6 { + font-size: 0.96rem; +} + +/* Prevent long strings from overflowing container */ +p, h1, h2, h3, h4, h5, h6 { + overflow-wrap: break-word; +} + +/* Fix line height when title wraps */ +h1, +h2, +h3 { + line-height: 1.1; +} + +/* Reduce header size on mobile */ +@media only screen and (max-width: 720px) { + h1 { + font-size: 2.5rem; + } + + h2 { + font-size: 2.1rem; + } + + h3 { + font-size: 1.75rem; + } + + h4 { + font-size: 1.25rem; + } +} + +/* Format links & buttons */ +a, +a:visited { + color: var(--accent); +} + +a:hover { + text-decoration: none; +} + +button, +[role="button"], +input[type="submit"], +input[type="reset"], +input[type="button"], +label[type="button"] { + border: none; + border-radius: var(--standard-border-radius); + background-color: var(--accent); + font-size: 1rem; + color: var(--bg); + padding: 0.7rem 0.9rem; + margin: 0.5rem 0; +} + +button[disabled], +[role="button"][aria-disabled="true"], +input[type="submit"][disabled], +input[type="reset"][disabled], +input[type="button"][disabled], +input[type="checkbox"][disabled], +input[type="radio"][disabled], +select[disabled] { + cursor: not-allowed; +} + +input:disabled, +textarea:disabled, +select:disabled, +button[disabled] { + cursor: not-allowed; + background-color: var(--disabled); + color: var(--text-light) +} + +input[type="range"] { + padding: 0; +} + +/* Set the cursor to '?' on an abbreviation and style the abbreviation to show that there is more information underneath */ +abbr[title] { + cursor: help; + text-decoration-line: underline; + text-decoration-style: dotted; +} + +button:enabled:hover, +[role="button"]:not([aria-disabled="true"]):hover, +input[type="submit"]:enabled:hover, +input[type="reset"]:enabled:hover, +input[type="button"]:enabled:hover, +label[type="button"]:hover { + filter: brightness(1.4); + cursor: pointer; +} + +button:focus-visible:where(:enabled, [role="button"]:not([aria-disabled="true"])), +input:enabled:focus-visible:where( + [type="submit"], + [type="reset"], + [type="button"] +) { + outline: 2px solid var(--accent); + outline-offset: 1px; +} + +/* Format navigation */ +header > nav { + font-size: 1rem; + line-height: 2; + padding: 1rem 0 0 0; +} + +/* Use flexbox to allow items to wrap, as needed */ +header > nav ul, +header > nav ol { + align-content: space-around; + align-items: center; + display: flex; + flex-direction: row; + flex-wrap: wrap; + justify-content: center; + list-style-type: none; + margin: 0; + padding: 0; +} + +/* List items are inline elements, make them behave more like blocks */ +header > nav ul li, +header > nav ol li { + display: inline-block; +} + +header > nav a, +header > nav a:visited { + margin: 0 0.5rem 1rem 0.5rem; + border: 1px solid var(--border); + border-radius: var(--standard-border-radius); + color: var(--text); + display: inline-block; + padding: 0.1rem 1rem; + text-decoration: none; +} + +header > nav a:hover { + border-color: var(--accent); + color: var(--accent); + cursor: pointer; +} + +/* Reduce nav side on mobile */ +@media only screen and (max-width: 720px) { + header > nav a { + border: none; + padding: 0; + text-decoration: underline; + line-height: 1; + } +} + +/* Consolidate box styling */ +aside, details, pre, progress { + background-color: var(--accent-bg); + border: 1px solid var(--border); + border-radius: var(--standard-border-radius); + margin-bottom: 1rem; +} + +aside { + font-size: 1rem; + width: 30%; + padding: 0 15px; + margin-left: 15px; + float: right; +} + +/* Make aside full-width on mobile */ +@media only screen and (max-width: 720px) { + aside { + width: 100%; + float: none; + margin-left: 0; + } +} + +article, fieldset { + border: 1px solid var(--border); + padding: 1rem; + border-radius: var(--standard-border-radius); + margin-bottom: 1rem; +} + +article h2:first-child, +section h2:first-child { + margin-top: 1rem; +} + +section { + border-top: 1px solid var(--border); + border-bottom: 1px solid var(--border); + padding: 2rem 1rem; + margin: 3rem 0; +} + +/* Don't double separators when chaining sections */ +section + section, +section:first-child { + border-top: 0; + padding-top: 0; +} + +section:last-child { + border-bottom: 0; + padding-bottom: 0; +} + +details { + padding: 0.7rem 1rem; +} + +summary { + cursor: pointer; + font-weight: bold; + padding: 0.7rem 1rem; + margin: -0.7rem -1rem; + word-break: break-all; +} + +details[open] > summary + * { + margin-top: 0; +} + +details[open] > summary { + margin-bottom: 0.5rem; +} + +details[open] > :last-child { + margin-bottom: 0; +} + +/* Format tables */ +table { + border-collapse: collapse; + margin: 1.5rem 0; +} + +td, +th { + border: 1px solid var(--border); + text-align: left; + padding: 0.5rem; +} + +th { + background-color: var(--accent-bg); + font-weight: bold; +} + +tr:nth-child(even) { + /* Set every other cell slightly darker. Improves readability. */ + background-color: var(--accent-bg); +} + +table caption { + font-weight: bold; + margin-bottom: 0.5rem; +} + +/* Format forms */ +textarea, +select, +input { + font-size: inherit; + font-family: inherit; + padding: 0.5rem; + margin-bottom: 0.5rem; + color: var(--text); + background-color: var(--bg); + border: 1px solid var(--border); + border-radius: var(--standard-border-radius); + box-shadow: none; + max-width: 100%; + display: inline-block; +} +label { + display: block; +} +textarea:not([cols]) { + width: 100%; +} + +/* Add arrow to drop-down */ +select:not([multiple]) { + background-image: linear-gradient(45deg, transparent 49%, var(--text) 51%), + linear-gradient(135deg, var(--text) 51%, transparent 49%); + background-position: calc(100% - 15px), calc(100% - 10px); + background-size: 5px 5px, 5px 5px; + background-repeat: no-repeat; + padding-right: 25px; +} + +/* checkbox and radio button style */ +input[type="checkbox"], +input[type="radio"] { + vertical-align: middle; + position: relative; + width: min-content; +} + +input[type="checkbox"] + label, +input[type="radio"] + label { + display: inline-block; +} + +input[type="radio"] { + border-radius: 100%; +} + +input[type="checkbox"]:checked, +input[type="radio"]:checked { + background-color: var(--accent); +} + +input[type="checkbox"]:checked::after { + /* Creates a rectangle with colored right and bottom borders which is rotated to look like a check mark */ + content: " "; + width: 0.18em; + height: 0.32em; + border-radius: 0; + position: absolute; + top: 0.05em; + left: 0.17em; + background-color: transparent; + border-right: solid var(--bg) 0.08em; + border-bottom: solid var(--bg) 0.08em; + font-size: 1.8em; + transform: rotate(45deg); +} +input[type="radio"]:checked::after { + /* creates a colored circle for the checked radio button */ + content: " "; + width: 0.25em; + height: 0.25em; + border-radius: 100%; + position: absolute; + top: 0.125em; + background-color: var(--bg); + left: 0.125em; + font-size: 32px; +} + +/* Makes input fields wider on smaller screens */ +@media only screen and (max-width: 720px) { + textarea, + select, + input { + width: 100%; + } +} + +/* Set a height for color input */ +input[type="color"] { + height: 2.5rem; + padding: 0.2rem; +} + +/* do not show border around file selector button */ +input[type="file"] { + border: 0; +} + +/* Misc body elements */ +hr { + border: none; + height: 1px; + background: var(--border); + margin: 1rem auto; +} + +mark { + padding: 2px 5px; + border-radius: var(--standard-border-radius); + background-color: var(--marked); +} + +img, +video { + max-width: 100%; + height: auto; + border-radius: var(--standard-border-radius); +} + +figure { + margin: 0; + display: block; + overflow-x: auto; +} + +figcaption { + text-align: center; + font-size: 0.9rem; + color: var(--text-light); + margin-bottom: 1rem; +} + +blockquote { + margin: 2rem 0 2rem 2rem; + padding: 0.4rem 0.8rem; + border-left: 0.35rem solid var(--accent); + color: var(--text-light); + font-style: italic; +} + +cite { + font-size: 0.9rem; + color: var(--text-light); + font-style: normal; +} + +dt { + color: var(--text-light); +} + +/* Use mono font for code elements */ +code, +pre, +pre span, +kbd, +samp { + font-family: var(--mono-font); + color: var(--code); +} + +kbd { + color: var(--preformatted); + border: 1px solid var(--preformatted); + border-bottom: 3px solid var(--preformatted); + border-radius: var(--standard-border-radius); + padding: 0.1rem 0.4rem; +} + +pre { + padding: 1rem 1.4rem; + max-width: 100%; + overflow: auto; + color: var(--preformatted); +} + +/* Fix embedded code within pre */ +pre code { + color: var(--preformatted); + background: none; + margin: 0; + padding: 0; +} + +/* Progress bars */ +/* Declarations are repeated because you */ +/* cannot combine vendor-specific selectors */ +progress { + width: 100%; +} + +progress:indeterminate { + background-color: var(--accent-bg); +} + +progress::-webkit-progress-bar { + border-radius: var(--standard-border-radius); + background-color: var(--accent-bg); +} + +progress::-webkit-progress-value { + border-radius: var(--standard-border-radius); + background-color: var(--accent); +} + +progress::-moz-progress-bar { + border-radius: var(--standard-border-radius); + background-color: var(--accent); + transition-property: width; + transition-duration: 0.3s; +} + +progress:indeterminate::-moz-progress-bar { + background-color: var(--accent-bg); +} + +/* Classes for buttons and notices */ +.button, +.button:visited { + border: none; + border-radius: 5px; + background: var(--accent); + font-size: 1rem; + color: var(--bg); + padding: 0.7rem 0.9rem; + margin: 0.5rem 0; +} + +.button:hover, +.button:focus { + filter: brightness(1.4); + cursor: pointer; +} + +.notice { + background: var(--accent-bg); + border: 2px solid var(--border); + border-radius: 5px; + padding: 1.5rem; + margin: 2rem 0; +} \ No newline at end of file diff --git a/css/style.css b/css/style.css new file mode 100644 index 0000000..aa5adb9 --- /dev/null +++ b/css/style.css @@ -0,0 +1,11 @@ +.icon { + vertical-align: sub; + padding-right: 0.25rem; + display: inline-block; + width: 1em; + height: 1.3em; + margin-right: 0.2rem; + stroke-width: 0; + stroke: currentColor; + fill: currentColor; +} diff --git a/index.md b/index.md index b760198..89948fc 100644 --- a/index.md +++ b/index.md @@ -4,29 +4,24 @@ description: A starter template for the Zen Static (zs) site generator keywords: zen, static, zs, starter, template, site, website, template, generator, ssg --- -# zs starter template +This is a [zs](https://git.mills.io/prologic/zs) starter template. A live version of this site can be found [here](https://zs.mills.io). -This is a [zs](https://git.mills.io/prologic/zs) starter template. +## Features -It includes: - -- A basic index page +- A basic index page with the content you see here - A basic layout using [SimpleCSS](https://simplecss.org/) for style +- Uses [live.js](https://livejs.com/) to automatically reload pages when they change ## Quick Start ```console -git clone https://git.mills.io/prologic/zs.git -cd zs +git clone https://git.mills.io/prologic/zs-starter-template.git +cd zs-starter-template make dev ``` Open your browser to http://localhost:8000 -## Demo - -A demo of this starter template can be found here: https://zs.mills.io/ - ## License -`zs-starter-template` is licensed under the terms of the [WTFPL License](/LICENSE) +`zs-starter-template` is licensed under the terms of the [WTFPL License](/LICENSE) \ No newline at end of file diff --git a/js/live.js b/js/live.js new file mode 100644 index 0000000..1eccb58 --- /dev/null +++ b/js/live.js @@ -0,0 +1,233 @@ + /* + Live.js - One script closer to Designing in the Browser + Written for Handcraft.com by Martin Kool (@mrtnkl). + + Version 4. + Recent change: Made stylesheet and mimetype checks case insensitive. + + http://livejs.com + http://livejs.com/license (MIT) + @livejs + + Include live.js#css to monitor css changes only. + Include live.js#js to monitor js changes only. + Include live.js#html to monitor html changes only. + Mix and match to monitor a preferred combination such as live.js#html,css + + By default, just include live.js to monitor all css, js and html changes. + + Live.js can also be loaded as a bookmarklet. It is best to only use it for CSS then, + as a page reload due to a change in html or css would not re-include the bookmarklet. + To monitor CSS and be notified that it has loaded, include it as: live.js#css,notify +*/ +(function () { + + var headers = { "Etag": 1, "Last-Modified": 1, "Content-Length": 1, "Content-Type": 1 }, + resources = {}, + pendingRequests = {}, + currentLinkElements = {}, + oldLinkElements = {}, + interval = 1000, + loaded = false, + active = { "html": 1, "css": 1, "js": 1 }; + + var Live = { + + // performs a cycle per interval + heartbeat: function () { + if (document.body) { + // make sure all resources are loaded on first activation + if (!loaded) Live.loadresources(); + Live.checkForChanges(); + } + setTimeout(Live.heartbeat, interval); + }, + + // loads all local css and js resources upon first activation + loadresources: function () { + + // helper method to assert if a given url is local + function isLocal(url) { + var loc = document.location, + reg = new RegExp("^\\.|^\/(?!\/)|^[\\w]((?!://).)*$|" + loc.protocol + "//" + loc.host); + return url.match(reg); + } + + // gather all resources + var scripts = document.getElementsByTagName("script"), + links = document.getElementsByTagName("link"), + uris = []; + + // track local js urls + for (var i = 0; i < scripts.length; i++) { + var script = scripts[i], src = script.getAttribute("src"); + if (src && isLocal(src)) + uris.push(src); + if (src && src.match(/\blive.js#/)) { + for (var type in active) + active[type] = src.match("[#,|]" + type) != null + if (src.match("notify")) + alert("Live.js is loaded."); + } + } + if (!active.js) uris = []; + if (active.html) uris.push(document.location.href); + + // track local css urls + for (var i = 0; i < links.length && active.css; i++) { + var link = links[i], rel = link.getAttribute("rel"), href = link.getAttribute("href", 2); + if (href && rel && rel.match(new RegExp("stylesheet", "i")) && isLocal(href)) { + uris.push(href); + currentLinkElements[href] = link; + } + } + + // initialize the resources info + for (var i = 0; i < uris.length; i++) { + var url = uris[i]; + Live.getHead(url, function (url, info) { + resources[url] = info; + }); + } + + // add rule for morphing between old and new css files + var head = document.getElementsByTagName("head")[0], + style = document.createElement("style"), + rule = "transition: all .3s ease-out;" + css = [".livejs-loading * { ", rule, " -webkit-", rule, "-moz-", rule, "-o-", rule, "}"].join(''); + style.setAttribute("type", "text/css"); + head.appendChild(style); + style.styleSheet ? style.styleSheet.cssText = css : style.appendChild(document.createTextNode(css)); + + // yep + loaded = true; + }, + + // check all tracking resources for changes + checkForChanges: function () { + for (var url in resources) { + if (pendingRequests[url]) + continue; + + Live.getHead(url, function (url, newInfo) { + var oldInfo = resources[url], + hasChanged = false; + resources[url] = newInfo; + for (var header in oldInfo) { + // do verification based on the header type + var oldValue = oldInfo[header], + newValue = newInfo[header], + contentType = newInfo["Content-Type"]; + switch (header.toLowerCase()) { + case "etag": + if (!newValue) break; + // fall through to default + default: + hasChanged = oldValue != newValue; + break; + } + // if changed, act + if (hasChanged) { + Live.refreshResource(url, contentType); + break; + } + } + }); + } + }, + + // act upon a changed url of certain content type + refreshResource: function (url, type) { + switch (type.toLowerCase()) { + // css files can be reloaded dynamically by replacing the link element + case "text/css": + var link = currentLinkElements[url], + html = document.body.parentNode, + head = link.parentNode, + next = link.nextSibling, + newLink = document.createElement("link"); + + html.className = html.className.replace(/\s*livejs\-loading/gi, '') + ' livejs-loading'; + newLink.setAttribute("type", "text/css"); + newLink.setAttribute("rel", "stylesheet"); + newLink.setAttribute("href", url + "?now=" + new Date() * 1); + next ? head.insertBefore(newLink, next) : head.appendChild(newLink); + currentLinkElements[url] = newLink; + oldLinkElements[url] = link; + + // schedule removal of the old link + Live.removeoldLinkElements(); + break; + + // check if an html resource is our current url, then reload + case "text/html": + if (url != document.location.href) + return; + + // local javascript changes cause a reload as well + case "text/javascript": + case "application/javascript": + case "application/x-javascript": + document.location.reload(); + } + }, + + // removes the old stylesheet rules only once the new one has finished loading + removeoldLinkElements: function () { + var pending = 0; + for (var url in oldLinkElements) { + // if this sheet has any cssRules, delete the old link + try { + var link = currentLinkElements[url], + oldLink = oldLinkElements[url], + html = document.body.parentNode, + sheet = link.sheet || link.styleSheet, + rules = sheet.rules || sheet.cssRules; + if (rules.length >= 0) { + oldLink.parentNode.removeChild(oldLink); + delete oldLinkElements[url]; + setTimeout(function () { + html.className = html.className.replace(/\s*livejs\-loading/gi, ''); + }, 100); + } + } catch (e) { + pending++; + } + if (pending) setTimeout(Live.removeoldLinkElements, 50); + } + }, + + // performs a HEAD request and passes the header info to the given callback + getHead: function (url, callback) { + pendingRequests[url] = true; + var xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XmlHttp"); + xhr.open("HEAD", url, true); + xhr.onreadystatechange = function () { + delete pendingRequests[url]; + if (xhr.readyState == 4 && xhr.status != 304) { + xhr.getAllResponseHeaders(); + var info = {}; + for (var h in headers) { + var value = xhr.getResponseHeader(h); + // adjust the simple Etag variant to match on its significant part + if (h.toLowerCase() == "etag" && value) value = value.replace(/^W\//, ''); + if (h.toLowerCase() == "content-type" && value) value = value.replace(/^(.*?);.*?$/i, "$1"); + info[h] = value; + } + callback(url, info); + } + } + xhr.send(); + } + }; + + // start listening + if (document.location.protocol != "file:") { + if (!window.liveJsLoaded) + Live.heartbeat(); + + window.liveJsLoaded = true; + } + else if (window.console) + console.log("Live.js doesn't support the file protocol. It needs http."); +})(); \ No newline at end of file diff --git a/simple.css b/simple.css deleted file mode 100644 index bd62eaa..0000000 --- a/simple.css +++ /dev/null @@ -1,492 +0,0 @@ -/* Set the global variables for everything. Change these to use your own fonts and colours. */ -:root { - - /* Set sans-serif & mono fonts */ - --sans-font: -apple-system, BlinkMacSystemFont, "Avenir Next", Avenir, "Nimbus Sans L", Roboto, Noto, "Segoe UI", Arial, Helvetica, "Helvetica Neue", sans-serif; - --mono-font: Consolas, Menlo, Monaco, "Andale Mono", "Ubuntu Mono", monospace; - - /* Body font size. By default, effectively 18.4px, based on 16px as 'root em' */ - --base-fontsize: 1.15rem; - - /* Major third scale progression - see https://type-scale.com/ */ - --header-scale: 1.25; - - /* Line height is set to the "Golden ratio" for optimal legibility */ - --line-height: 1.618; - - /* Default (light) theme */ - --bg: #FFF; - --accent-bg: #F5F7FF; - --text: #212121; - --text-light: #585858; - --border: #D8DAE1; - --accent: #0D47A1; - --accent-light: #90CAF9; - --code: #D81B60; - --preformatted: #444; - --marked: #FFDD33; - --disabled: #EFEFEF; -} - -/* Dark theme */ -@media (prefers-color-scheme: dark) { - :root { - --bg: #212121; - --accent-bg: #2B2B2B; - --text: #DCDCDC; - --text-light: #ABABAB; - --border: #666; - --accent: #FFB300; - --accent-light: #FFECB3; - --code: #F06292; - --preformatted: #CCC; - --disabled: #111; - } - - img, video { - opacity: .6; - } -} - -html { - /* Set the font globally */ - font-family: var(--sans-font); -} - -/* Make the body a nice central block */ -body { - color: var(--text); - background: var(--bg); - font-size: var(--base-fontsize); - line-height: var(--line-height); - display: flex; - min-height: 100vh; - flex-direction: column; - flex: 1; - margin: 0 auto; - max-width: 45rem; - padding: 0 .5rem; - overflow-x: hidden; - word-break: break-word; - overflow-wrap: break-word; -} - -/* Make the header bg full width, but the content inline with body */ -header { - background: var(--accent-bg); - border-bottom: 1px solid var(--border); - text-align: center; - padding: 2rem .5rem; - width: 100vw; - position: relative; - box-sizing: border-box; - left: 50%; - right: 50%; - margin-left: -50vw; - margin-right: -50vw; -} - - -/* Remove margins for header text */ -header h1, -header p { - margin: 0; -} - -/* Fix line height when title wraps */ -h1, h2, h3 { - line-height: 1.1; -} - -/* Format navigation */ -nav { - font-size: 1rem; - line-height: 2; - padding: 1rem 0; -} - -nav a { - margin: 1rem 1rem 0 0; - border: 1px solid var(--border); - border-radius: 5px; - color: var(--text) !important; - display: inline-block; - padding: .1rem 1rem; - text-decoration: none; - transition: .4s; -} - -nav a:hover { - color: var(--accent) !important; - border-color: var(--accent); -} - -nav a.current:hover { - text-decoration: none; -} - -footer { - margin-top: 4rem; - padding: 2rem 1rem 1.5rem 1rem; - color: var(--text-light); - font-size: .9rem; - text-align: center; - border-top: 1px solid var(--border); -} - -/* Format headers */ -h1 { - font-size: calc(var(--base-fontsize) * var(--header-scale) * var(--header-scale) * var(--header-scale) * var(--header-scale)); - margin-top: calc(var(--line-height) * 1.5rem); -} - -h2 { - font-size: calc(var(--base-fontsize) * var(--header-scale) * var(--header-scale) * var(--header-scale)); - margin-top: calc(var(--line-height) * 1.5rem); -} - -h3 { - font-size: calc(var(--base-fontsize) * var(--header-scale) * var(--header-scale)); - margin-top: calc(var(--line-height) * 1.5rem); -} - -h4 { - font-size: calc(var(--base-fontsize) * var(--header-scale)); - margin-top: calc(var(--line-height) * 1.5rem); -} - -h5 { - font-size: var(--base-fontsize); - margin-top: calc(var(--line-height) * 1.5rem); -} - -h6 { - font-size: calc(var(--base-fontsize) / var(--header-scale)); - margin-top: calc(var(--line-height) * 1.5rem); -} - -/* Format links & buttons */ -a, -a:visited { - color: var(--accent); -} - -a:hover { - text-decoration: none; -} - -a button, -button, -input[type="submit"], -input[type="reset"], -input[type="button"] { - border: none; - border-radius: 5px; - background: var(--accent); - font-size: 1rem; - color: var(--bg); - padding: .7rem .9rem; - margin: .5rem 0; - transition: .4s; -} - -a button[disabled], -button[disabled], -input[type="submit"][disabled], -input[type="reset"][disabled], -input[type="button"][disabled], -input[type="checkbox"][disabled], -input[type="radio"][disabled], -select[disabled] { - cursor: default; - opacity: .5; - cursor: not-allowed; -} - -input:disabled, -textarea:disabled, -select:disabled { - cursor: not-allowed; - background-color: var(--disabled); -} - -input[type="range"] { - padding: 0; -} - -/* Set the cursor to '?' while hovering over an abbreviation */ -abbr { - cursor: help; -} - -button:focus, -button:enabled:hover, -input[type="submit"]:focus, -input[type="submit"]:enabled:hover, -input[type="reset"]:focus, -input[type="reset"]:enabled:hover, -input[type="button"]:focus, -input[type="button"]:enabled:hover, -input[type="checkbox"]:focus, -input[type="checkbox"]:enabled:hover, -input[type="radio"]:focus, -input[type="radio"]:enabled:hover{ - opacity: .8; - cursor: pointer; -} - -/* Format the expanding box */ -details { - background: var(--accent-bg); - border: 1px solid var(--border); - border-radius: 5px; - margin-bottom: 1rem; -} - -summary { - cursor: pointer; - font-weight: bold; - padding: .6rem 1rem; -} - -details[open] { - padding: .6rem 1rem .75rem 1rem; -} - -details[open] summary { - margin-bottom: .5rem; - padding: 0; -} - -details[open]>*:last-child { - margin-bottom: 0; -} - -/* Format tables */ -table { - border-collapse: collapse; - width: 100%; - margin: 1.5rem 0; -} - -td, -th { - border: 1px solid var(--border); - text-align: left; - padding: .5rem; -} - -th { - background: var(--accent-bg); - font-weight: bold; -} - -tr:nth-child(even) { - /* Set every other cell slightly darker. Improves readability. */ - background: var(--accent-bg); -} - -table caption { - font-weight: bold; - margin-bottom: .5rem; -} - -/* Lists */ -ol, -ul { - padding-left: 3rem; -} - -/* Format forms */ -textarea, -select, -input { - font-size: inherit; - font-family: inherit; - padding: .5rem; - margin-bottom: .5rem; - color: var(--text); - background: var(--bg); - border: 1px solid var(--border); - border-radius: 5px; - box-shadow: none; - box-sizing: border-box; - width: 60%; - -moz-appearance: none; - -webkit-appearance: none; - appearance: none; -} - -/* Add arrow to */ -select { - background-image: - linear-gradient(45deg, transparent 49%, var(--text) 51%), - linear-gradient(135deg, var(--text) 51%, transparent 49%); - background-position: - calc(100% - 20px), - calc(100% - 15px); - background-size: - 5px 5px, - 5px 5px; - background-repeat: no-repeat; -} - -select[multiple] { - background-image: none !important; -} - -/* checkbox and radio button style */ -input[type="checkbox"], input[type="radio"]{ - vertical-align: bottom; - position: relative; -} -input[type="radio"]{ - border-radius: 100%; -} - -input[type="checkbox"]:checked, -input[type="radio"]:checked { - background: var(--accent); -} - -input[type="checkbox"]:checked::after { - /* Creates a rectangle with colored right and bottom borders which is rotated to look like a check mark */ - content: ' '; - width: 0.1em; - height: 0.25em; - border-radius: 0; - position: absolute; - top: 0.05em; - left: 0.18em; - background: transparent; - border-right: solid var(--bg) 0.08em; - border-bottom: solid var(--bg) 0.08em; - font-size: 1.8em; - transform: rotate(45deg); -} -input[type="radio"]:checked::after { - /* creates a colored circle for the checked radio button */ - content: ' '; - width: .25em; - height: .25em; - border-radius: 100%; - position: absolute; - top: 0.125em; - background: var(--bg); - left: 0.125em; - font-size: 32px; -} - -/* Make the textarea wider than other inputs */ -textarea { - width: 80% -} - -/* Makes input fields wider on smaller screens */ -@media only screen and (max-width: 720px) { - textarea, - select, - input { - width: 100%; - } -} - -/* Ensures the checkbox and radio inputs do not have a set width like other input fields */ -input[type="checkbox"], input[type="radio"]{ - width: auto; -} - -/* do not show border around file selector button */ -input[type="file"] { - border: 0; -} - -/* Without this any HTML using
shows ugly borders and has additional padding/margin. (Issue #3) */ -fieldset { - border: 0; - padding: 0; - margin: 0; -} - -/* Misc body elements */ - -hr { - color: var(--border); - border-top: 1px; - margin: 1rem auto; -} - -mark { - padding: 2px 5px; - border-radius: 4px; - background: var(--marked); -} - -main img, main video { - max-width: 100%; - height: auto; - border-radius: 5px; -} - -figure { - margin: 0; -} - -figcaption { - font-size: .9rem; - color: var(--text-light); - text-align: center; - margin-bottom: 1rem; -} - -blockquote { - margin: 2rem 0 2rem 2rem; - padding: .4rem .8rem; - border-left: .35rem solid var(--accent); - opacity: .8; - font-style: italic; -} - -cite { - font-size: 0.9rem; - color: var(--text-light); - font-style: normal; -} - -/* Use mono font for code like elements */ -code, -pre, -pre span, -kbd, -samp { - font-size: 1.075rem; - font-family: var(--mono-font); - color: var(--code); -} - -kbd { - color: var(--preformatted); - border: 1px solid var(--preformatted); - border-bottom: 3px solid var(--preformatted); - border-radius: 5px; - padding: .1rem; -} - -pre { - padding: 1rem 1.4rem; - max-width: 100%; - overflow: auto; - overflow-x: auto; - color: var(--preformatted); - background: var(--accent-bg); - border: 1px solid var(--border); - border-radius: 5px; -} - -/* Fix embedded code within pre */ -pre code { - color: var(--preformatted); - background: none; - margin: 0; - padding: 0; -} diff --git a/simple.min.css b/simple.min.css deleted file mode 100644 index 38f8845..0000000 --- a/simple.min.css +++ /dev/null @@ -1 +0,0 @@ -:root{--sans-font:-apple-system,BlinkMacSystemFont,"Avenir Next",Avenir,"Nimbus Sans L",Roboto,Noto,"Segoe UI",Arial,Helvetica,"Helvetica Neue",sans-serif;--mono-font:Consolas,Menlo,Monaco,"Andale Mono","Ubuntu Mono",monospace;--base-fontsize:1.15rem;--header-scale:1.25;--line-height:1.618;--bg:#FFF;--accent-bg:#F5F7FF;--text:#212121;--text-light:#585858;--border:#D8DAE1;--accent:#0D47A1;--accent-light:#90CAF9;--code:#D81B60;--preformatted:#444;--marked:#FFDD33;--disabled:#EFEFEF}@media (prefers-color-scheme:dark){:root{--bg:#212121;--accent-bg:#2B2B2B;--text:#DCDCDC;--text-light:#ABABAB;--border:#666;--accent:#FFB300;--accent-light:#FFECB3;--code:#F06292;--preformatted:#CCC;--disabled:#111}img,video{opacity:.6}}html{font-family:var(--sans-font)}body{color:var(--text);background:var(--bg);font-size:var(--base-fontsize);line-height:var(--line-height);display:flex;min-height:100vh;flex-direction:column;flex:1;margin:0 auto;max-width:45rem;padding:0 .5rem;overflow-x:hidden;word-break:break-word;overflow-wrap:break-word}header{background:var(--accent-bg);border-bottom:1px solid var(--border);text-align:center;padding:2rem .5rem;width:100vw;position:relative;box-sizing:border-box;left:50%;right:50%;margin-left:-50vw;margin-right:-50vw}header h1,header p{margin:0}h1,h2,h3{line-height:1.1}nav{font-size:1rem;line-height:2;padding:1rem 0}nav a{margin:1rem 1rem 0 0;border:1px solid var(--border);border-radius:5px;color:var(--text)!important;display:inline-block;padding:.1rem 1rem;text-decoration:none;transition:.4s}nav a:hover{color:var(--accent)!important;border-color:var(--accent)}nav a.current:hover{text-decoration:none}footer{margin-top:4rem;padding:2rem 1rem 1.5rem 1rem;color:var(--text-light);font-size:.9rem;text-align:center;border-top:1px solid var(--border)}h1{font-size:calc(var(--base-fontsize) * var(--header-scale) * var(--header-scale) * var(--header-scale) * var(--header-scale));margin-top:calc(var(--line-height) * 1.5rem)}h2{font-size:calc(var(--base-fontsize) * var(--header-scale) * var(--header-scale) * var(--header-scale));margin-top:calc(var(--line-height) * 1.5rem)}h3{font-size:calc(var(--base-fontsize) * var(--header-scale) * var(--header-scale));margin-top:calc(var(--line-height) * 1.5rem)}h4{font-size:calc(var(--base-fontsize) * var(--header-scale));margin-top:calc(var(--line-height) * 1.5rem)}h5{font-size:var(--base-fontsize);margin-top:calc(var(--line-height) * 1.5rem)}h6{font-size:calc(var(--base-fontsize)/ var(--header-scale));margin-top:calc(var(--line-height) * 1.5rem)}a,a:visited{color:var(--accent)}a:hover{text-decoration:none}a button,button,input[type=button],input[type=reset],input[type=submit]{border:none;border-radius:5px;background:var(--accent);font-size:1rem;color:var(--bg);padding:.7rem .9rem;margin:.5rem 0;transition:.4s}a button[disabled],button[disabled],input[type=button][disabled],input[type=checkbox][disabled],input[type=radio][disabled],input[type=reset][disabled],input[type=submit][disabled],select[disabled]{cursor:default;opacity:.5;cursor:not-allowed}input:disabled,select:disabled,textarea:disabled{cursor:not-allowed;background-color:var(--disabled)}input[type=range]{padding:0}abbr{cursor:help}button:enabled:hover,button:focus,input[type=button]:enabled:hover,input[type=button]:focus,input[type=checkbox]:enabled:hover,input[type=checkbox]:focus,input[type=radio]:enabled:hover,input[type=radio]:focus,input[type=reset]:enabled:hover,input[type=reset]:focus,input[type=submit]:enabled:hover,input[type=submit]:focus{opacity:.8;cursor:pointer}details{background:var(--accent-bg);border:1px solid var(--border);border-radius:5px;margin-bottom:1rem}summary{cursor:pointer;font-weight:700;padding:.6rem 1rem}details[open]{padding:.6rem 1rem .75rem 1rem}details[open] summary{margin-bottom:.5rem;padding:0}details[open]>:last-child{margin-bottom:0}table{border-collapse:collapse;width:100%;margin:1.5rem 0}td,th{border:1px solid var(--border);text-align:left;padding:.5rem}th{background:var(--accent-bg);font-weight:700}tr:nth-child(even){background:var(--accent-bg)}table caption{font-weight:700;margin-bottom:.5rem}ol,ul{padding-left:3rem}input,select,textarea{font-size:inherit;font-family:inherit;padding:.5rem;margin-bottom:.5rem;color:var(--text);background:var(--bg);border:1px solid var(--border);border-radius:5px;box-shadow:none;box-sizing:border-box;width:60%;-moz-appearance:none;-webkit-appearance:none;appearance:none}select{background-image:linear-gradient(45deg,transparent 49%,var(--text) 51%),linear-gradient(135deg,var(--text) 51%,transparent 49%);background-position:calc(100% - 20px),calc(100% - 15px);background-size:5px 5px,5px 5px;background-repeat:no-repeat}select[multiple]{background-image:none!important}input[type=checkbox],input[type=radio]{vertical-align:bottom;position:relative}input[type=radio]{border-radius:100%}input[type=checkbox]:checked,input[type=radio]:checked{background:var(--accent)}input[type=checkbox]:checked::after{content:' ';width:.1em;height:.25em;border-radius:0;position:absolute;top:.05em;left:.18em;background:0 0;border-right:solid var(--bg) .08em;border-bottom:solid var(--bg) .08em;font-size:1.8em;transform:rotate(45deg)}input[type=radio]:checked::after{content:' ';width:.25em;height:.25em;border-radius:100%;position:absolute;top:.125em;background:var(--bg);left:.125em;font-size:32px}textarea{width:80%}@media only screen and (max-width:720px){input,select,textarea{width:100%}}input[type=checkbox],input[type=radio]{width:auto}input[type=file]{border:0}fieldset{border:0;padding:0;margin:0}hr{color:var(--border);border-top:1px;margin:1rem auto}mark{padding:2px 5px;border-radius:4px;background:var(--marked)}main img,main video{max-width:100%;height:auto;border-radius:5px}figure{margin:0}figcaption{font-size:.9rem;color:var(--text-light);text-align:center;margin-bottom:1rem}blockquote{margin:2rem 0 2rem 2rem;padding:.4rem .8rem;border-left:.35rem solid var(--accent);opacity:.8;font-style:italic}cite{font-size:.9rem;color:var(--text-light);font-style:normal}code,kbd,pre,pre span,samp{font-size:1.075rem;font-family:var(--mono-font);color:var(--code)}kbd{color:var(--preformatted);border:1px solid var(--preformatted);border-bottom:3px solid var(--preformatted);border-radius:5px;padding:.1rem}pre{padding:1rem 1.4rem;max-width:100%;overflow:auto;overflow-x:auto;color:var(--preformatted);background:var(--accent-bg);border:1px solid var(--border);border-radius:5px}pre code{color:var(--preformatted);background:0 0;margin:0;padding:0} \ No newline at end of file