mirror of
https://github.com/frainfreeze/the-monospace-web-pandoc
synced 2025-12-30 02:59:50 -08:00
add video and better text
This commit is contained in:
10
index.css
10
index.css
@@ -1,7 +1,7 @@
|
|||||||
:root {
|
:root {
|
||||||
--font-family: "Fira Code", monospace;
|
--font-family: "Fira Code", monospace;
|
||||||
--line-height: 1.25rem;
|
--line-height: 1.25rem;
|
||||||
--border-thickness: 1px;
|
--border-thickness: 2px;
|
||||||
--bold-weight: 700;
|
--bold-weight: 700;
|
||||||
|
|
||||||
font-family: var(--font-family);
|
font-family: var(--font-family);
|
||||||
@@ -74,7 +74,7 @@ hr {
|
|||||||
position: relative;
|
position: relative;
|
||||||
display: block;
|
display: block;
|
||||||
height: var(--line-height);
|
height: var(--line-height);
|
||||||
margin: calc(var(--line-height) * 2) 0 var(--line-height);
|
margin: calc(var(--line-height) * 1.5) 0;
|
||||||
border: none;
|
border: none;
|
||||||
color: #000;
|
color: #000;
|
||||||
}
|
}
|
||||||
@@ -82,7 +82,7 @@ hr:after {
|
|||||||
display: block;
|
display: block;
|
||||||
content: "";
|
content: "";
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: calc(var(--line-height) / 2 - var(--border-thickness));
|
||||||
left: 0;
|
left: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
border-top: calc(var(--border-thickness) * 3) double #000;
|
border-top: calc(var(--border-thickness) * 3) double #000;
|
||||||
@@ -165,7 +165,7 @@ p {
|
|||||||
hyphens: auto;
|
hyphens: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
img {
|
img, video {
|
||||||
--real-height: 100% / var(--ratio);
|
--real-height: 100% / var(--ratio);
|
||||||
|
|
||||||
display: block;
|
display: block;
|
||||||
@@ -277,5 +277,5 @@ li {
|
|||||||
}
|
}
|
||||||
|
|
||||||
body :not(.grid) {
|
body :not(.grid) {
|
||||||
background: rgba(255, 0, 0, 0.1);
|
/*background: rgba(255, 0, 0, 0.1);*/
|
||||||
}
|
}
|
||||||
|
|||||||
32
index.js
32
index.js
@@ -1,12 +1,32 @@
|
|||||||
// Set the ratio variable on each image.
|
// Set the ratio variable on each media.
|
||||||
document.querySelectorAll("img").forEach(img => {
|
document.querySelectorAll("img, video").forEach(media => {
|
||||||
function onLoaded() {
|
function onLoaded() {
|
||||||
const ratio = img.naturalWidth / img.naturalHeight;
|
var ratio = 1;
|
||||||
img.style.setProperty("--ratio", ratio);
|
switch (media.tagName) {
|
||||||
|
case "IMG":
|
||||||
|
ratio = media.naturalWidth / media.naturalHeight;
|
||||||
|
break;
|
||||||
|
case "VIDEO":
|
||||||
|
ratio = media.videoWidth / media.videoHeight;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (img.loaded) {
|
media.style.setProperty("--ratio", ratio);
|
||||||
|
}
|
||||||
|
switch (media.tagName) {
|
||||||
|
case "IMG":
|
||||||
|
if (media.loaded) {
|
||||||
onLoaded();
|
onLoaded();
|
||||||
} else {
|
} else {
|
||||||
img.addEventListener("load", onLoaded);
|
media.addEventListener("load", onLoaded);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "VIDEO":
|
||||||
|
if (media.readystate == 4) {
|
||||||
|
onLoaded();
|
||||||
|
} else {
|
||||||
|
media.style.setProperty("--ratio", 16/9); // default while loading
|
||||||
|
media.addEventListener("loadedmetadata", onLoaded);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
23
index.md
23
index.md
@@ -5,15 +5,20 @@ date: August 2024
|
|||||||
lang: en
|
lang: en
|
||||||
---
|
---
|
||||||
|
|
||||||
## Abstract
|
## Introduction
|
||||||
|
|
||||||
Monospace fonts are dear to many of us.
|
Monospace fonts are dear to many of us.
|
||||||
Some find them more readable, consistent, and beautiful, and than their proportional alternatives.
|
Some find them more readable, consistent, and beautiful, than their proportional alternatives.
|
||||||
Maybe we're just brainwashed from spending years in terminals?
|
Maybe we're just brainwashed from spending years in terminals?
|
||||||
Or are we hopelessly nostalgic?
|
Or are we hopelessly nostalgic?
|
||||||
In any case, I like them, and that's why I started experimenting with all-monospace Web.
|
I'm not sure.
|
||||||
|
But I like them, and that's why I started experimenting with all-monospace Web.
|
||||||
|
|
||||||
We use the monospace grid to align text and draw diagrams.
|
On this page, I use a monospace grid to align text and draw diagrams.
|
||||||
|
It's generated from a simple Markdown document (using Pandoc), and the CSS and a tiny bit of Javascript renders it on the grid.
|
||||||
|
The page is responsive, shrinking in character-sized steps.
|
||||||
|
Standard elements should _just work_, at least that's the goal.
|
||||||
|
It's semantic HTML, rendered as if we were back in the 70s.
|
||||||
|
|
||||||
## The Basics
|
## The Basics
|
||||||
|
|
||||||
@@ -142,6 +147,12 @@ Let's go wild and draw a chart!
|
|||||||
Socks Jeans Shirts USB Drives
|
Socks Jeans Shirts USB Drives
|
||||||
</pre></figure>
|
</pre></figure>
|
||||||
|
|
||||||
## Images
|
## Media
|
||||||
|
|
||||||

|
Media objects are supported, like images and video:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
.webm/11)](https://upload.wikimedia.org/wikipedia/commons/e/e0/The_Center_of_the_Web_%281914%29.webm)
|
||||||
|
|
||||||
|
They extend to the width of the page, and add appropriate padding in the bottom to maintain the monospace grid.
|
||||||
|
|||||||
Reference in New Issue
Block a user