1+ ---
2+ title: Customise this site
3+ metadata:
4+ description: Write your own CSS to customise how this site looks.
5+ ---
6+
7+ {% extends ' src/_layouts/layout.njk' %}
8+
9+ {% block main %}
10+ <div class =" kim-!-margin-block-8-9" >
11+ <div class =" kimWrapper" >
12+ <h1 class =" kimHeading-xl" >
13+ {{ title }}
14+ </h1 >
15+ <div class =" kimGrid" >
16+ <div class =" kimGrid_column kimGrid_column-full defiant:kimGrid_column-oneThird" >
17+ <p class =" kimBody-l" >Write your own CSS to customise how this site looks.</p >
18+ <p class =" kimBody" >This code is stored on your device and is never sent to the server. JavaScript must be available for it to work.</p >
19+ <p class =" kimBody" >This is here as an experiment. I might get rid of it again at some point. 🤷</p >
20+ </div >
21+ <div class =" kimGrid_column kimGrid_column-full defiant:kimGrid_column-twoThirds" >
22+ <label for =" css" class =" kim-!-visually-hidden" >Write some CSS</label >
23+ <textarea class =" pageCodeEditor" id =" css" rows =" 30" cols =" 80" disabled >
24+ .kimPage {
25+ /** Force light or dark mode by uncommenting one of these. */
26+ /* color-scheme: light; */
27+ /* color-scheme: dark; */
28+
29+ /** Change body font by uncommenting and editing this. */
30+ /* --font-body: system-ui, sans-serif; */
31+ }</textarea >
32+ </div >
33+ </div >
34+ </div >
35+ {% endblock %}
36+
37+ {% css %}
38+ .pageCodeEditor {
39+ inline-size: 100%;
40+ margin-block-end: var(--space-5);
41+ padding: var(--space-3);
42+ border: var(--border-regular) solid var(--color-furniture);
43+ color: var(--color-text);
44+ background-color: var(--color-surface);
45+ font-family: var(--font-code);
46+ font-size: var(--size--1);
47+ resize: vertical;
48+ tab-size: 4;
49+ }
50+ .pageCodeEditor:focus-visible {
51+ outline: 3px solid var(--color-focus-text);
52+ box-shadow: 0 0 0 5px var(--color-focus-background);
53+ }
54+ {% endcss %}
55+
56+ {% block scripts %}
57+ {{ super () }}
58+ <script >
59+ const $cssEditor = document .getElementById (" css" );
60+ $cssEditor .disabled = false ;
61+
62+ $cssEditor .addEventListener (" input" , function () {
63+ localStorage .setItem (" customCSS" , $cssEditor .value );
64+ window .$cssElement .innerText = $cssEditor .value ;
65+ })
66+
67+ if (localStorage .getItem (" customCSS" )) {
68+ $cssEditor .value = localStorage .getItem (" customCSS" );
69+ }
70+ </script >
71+ {% endblock %}
0 commit comments