Public
HTTP (deprecated)
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Readme

Utilities for Classless CSS

Forked from Paul Kinlan's Classless CSS Demo

Usage

For projects that should be pretty in an unopinionated way

import { randomStyle } from "https://esm.town/v/stevekrouse/classless_css"; export default async function(req: Request): Promise<Response> { return new Response(`<h1>Welcome to Val Town!</h1>${randomStyle}`, { headers: { "Content-Type": "text/html", }, }); }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import frameworks from "https://esm.sh/gh/PaulKinlan/classless-css-demo@1a68518805/src/frameworks.ts";
import { randomize } from "https://esm.town/v/stevekrouse/randomize";
delete frameworks[""];
function absolutePath(url: string) {
if (url.startsWith("http")) return url;
else return `https://classless-css-demo.deno.dev` + url;
}
export const random = randomize(Object.entries(frameworks))[0][1];
export const randomURL = absolutePath(random.cssUrl);
export const randomStyle = `<link rel="stylesheet" href="${randomURL}">`;
export default function(req: Response) {
const url = new URL(req.url);
if (url.pathname === "/") {
// return a list of all the framework names as iframes
return new Response(
"<h1>Fork of Paul Kinlan's Classless CSS</h1>" + Object.entries(frameworks)
.map(
([name, data]) =>
`<div><iframe width="90%" style="padding:10px" src="https://classless-css-demo.deno.dev${data.htmlUrl}"></iframe></div>`)
.join(""),
{
headers: {
"Content-Type": "text/html",
},
},
);
}
const name = url.pathname.replace("/", "");
const framework = frameworks[name] || random;
const frameworkURL = absolutePath(framework.cssUrl);
const frameworkStyle = `<link rel="stylesheet" href="${frameworkURL}">`;
return new Response(`<h1>${framework.name} Classless Style!</h1>${frameworkStyle}`, {
headers: {
"Content-Type": "text/html",
},
});
}
stevekrouse-classless_css.web.val.run
February 16, 2024