Commit ·
d593e73
1
Parent(s): eb7f98c
add usage guide, installer and starter files to the repo
Browse files- README.md +18 -1
- package/USAGE.md +94 -0
- package/examples/hello.dssl +39 -0
- package/install.sh +19 -0
README.md
CHANGED
|
@@ -62,7 +62,24 @@ This repo eats its own cooking. Everything you see on the website is styled by t
|
|
| 62 |
|
| 63 |
The site is live. No setup, no build, nothing to install: https://dssl-sable.vercel.app
|
| 64 |
|
| 65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
|
| 67 |
## Repo layout
|
| 68 |
|
|
|
|
| 62 |
|
| 63 |
The site is live. No setup, no build, nothing to install: https://dssl-sable.vercel.app
|
| 64 |
|
| 65 |
+
Want the engine on your own page? Two tags:
|
| 66 |
+
|
| 67 |
+
```html
|
| 68 |
+
<script type="module" src="/dssl/boot.js"></script>
|
| 69 |
+
<link rel="stylesheet/dssl" href="/styles/tokens.dssl">
|
| 70 |
+
```
|
| 71 |
+
|
| 72 |
+
Every `<link rel="stylesheet/dssl">` on the page gets fetched and applied automatically, and the engine keeps restyling the DOM live as elements come and go. That is the whole install.
|
| 73 |
+
|
| 74 |
+
Or grab it from a terminal:
|
| 75 |
+
|
| 76 |
+
```sh
|
| 77 |
+
curl -fsSL https://dssl-sable.vercel.app/install.sh | sh
|
| 78 |
+
```
|
| 79 |
+
|
| 80 |
+
That drops a `dssl-engine/` folder with the engine, a starter token set, a tiny example stylesheet and a usage guide (also in `package/` in this repo). Plain zip if you prefer: https://dssl-sable.vercel.app/dssl-engine.zip
|
| 81 |
+
|
| 82 |
+
Clone this repo if you want to read the engine. Everything runs in the browser.
|
| 83 |
|
| 84 |
## Repo layout
|
| 85 |
|
package/USAGE.md
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# DSSL engine — quickstart
|
| 2 |
+
|
| 3 |
+
DSSL is a style language that runs in the browser. You write `.dssl` files, add two tags to your page, and the engine does the rest. No compiler, no build step, no CSS output. The engine walks your DOM live and writes styles straight onto the elements it matches, including elements that show up later.
|
| 4 |
+
|
| 5 |
+
## 1. Get the engine
|
| 6 |
+
|
| 7 |
+
Copy the `dssl/` folder from this package into your project, or grab it fresh from a terminal:
|
| 8 |
+
|
| 9 |
+
```sh
|
| 10 |
+
curl -fsSL https://dssl-sable.vercel.app/install.sh | sh
|
| 11 |
+
```
|
| 12 |
+
|
| 13 |
+
That drops a `dssl-engine/` folder next to you with everything you need.
|
| 14 |
+
|
| 15 |
+
## 2. Wire it up
|
| 16 |
+
|
| 17 |
+
```html
|
| 18 |
+
<!doctype html>
|
| 19 |
+
<html data-dssl-reset>
|
| 20 |
+
<head>
|
| 21 |
+
<script type="module" src="/dssl/boot.js"></script>
|
| 22 |
+
<link rel="stylesheet/dssl" href="/styles/tokens.dssl">
|
| 23 |
+
<link rel="stylesheet/dssl" href="/examples/hello.dssl">
|
| 24 |
+
</head>
|
| 25 |
+
<body>
|
| 26 |
+
<h1>Styled by DSSL</h1>
|
| 27 |
+
</body>
|
| 28 |
+
</html>
|
| 29 |
+
```
|
| 30 |
+
|
| 31 |
+
What those lines do:
|
| 32 |
+
|
| 33 |
+
- `data-dssl-reset` (optional) turns on the small built-in reset.
|
| 34 |
+
- `boot.js` is the whole install. It boots the engine on page load.
|
| 35 |
+
- Every `<link rel="stylesheet/dssl">` is fetched and applied automatically, in the order you list them. Tokens first, then your styles.
|
| 36 |
+
- Inline styles work too: `<style type="text/dssl"> ... </style>`.
|
| 37 |
+
- When booting is done the page fires a `dssl-ready` event.
|
| 38 |
+
|
| 39 |
+
## 3. Write some DSSL
|
| 40 |
+
|
| 41 |
+
`examples/hello.dssl` in this package:
|
| 42 |
+
|
| 43 |
+
```dssl
|
| 44 |
+
body {
|
| 45 |
+
background: #f5f0e4
|
| 46 |
+
color: #26201a
|
| 47 |
+
padding: 40
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
.card {
|
| 51 |
+
background: #fdfaf2
|
| 52 |
+
border: 1 solid #ddd2bc
|
| 53 |
+
radius: 6
|
| 54 |
+
padding: 24
|
| 55 |
+
|
| 56 |
+
hover {
|
| 57 |
+
box-shadow: 0 6 18 #26201a/16
|
| 58 |
+
}
|
| 59 |
+
}
|
| 60 |
+
```
|
| 61 |
+
|
| 62 |
+
Bare numbers are pixels. States like `hover` are nested blocks. The engine keeps them working forever, even for elements added to the page later.
|
| 63 |
+
|
| 64 |
+
## The JavaScript API
|
| 65 |
+
|
| 66 |
+
`window.DSSL` is available after boot:
|
| 67 |
+
|
| 68 |
+
- `DSSL.load(urls)` fetch and apply one or more `.dssl` files (fetched in parallel, applied in order)
|
| 69 |
+
- `DSSL.apply(source, { name, scope })` apply a source string
|
| 70 |
+
- `DSSL.compile(source)` parse and resolve without touching the DOM, returns `ok`, `errors` and stats
|
| 71 |
+
- `DSSL.signal(name, value)` drive styles from JS with `@signal` conditions in your `.dssl`
|
| 72 |
+
- `DSSL.refresh()` force a full recompute
|
| 73 |
+
- `DSSL.replay(selector)` replay entrance motions on matching elements
|
| 74 |
+
- `DSSL.errors` the last reported errors (also grouped in the console, with did-you-mean hints)
|
| 75 |
+
- `DSSL.version` engine version
|
| 76 |
+
|
| 77 |
+
## Scoped engines
|
| 78 |
+
|
| 79 |
+
```js
|
| 80 |
+
DSSL.apply(source, { scope: '#widget' })
|
| 81 |
+
```
|
| 82 |
+
|
| 83 |
+
gives one subtree its own engine, its own tokens and its own cascade. The playground on the live site is built exactly this way.
|
| 84 |
+
|
| 85 |
+
## Files in this package
|
| 86 |
+
|
| 87 |
+
- `dssl/` the engine. `boot.js` is the entry, `index.js` the public API.
|
| 88 |
+
- `styles/tokens.dssl` the starter token set (colors, fonts, radii, shadows)
|
| 89 |
+
- `examples/hello.dssl` a tiny starter stylesheet
|
| 90 |
+
- `USAGE.md` this file
|
| 91 |
+
- `LICENSE` MIT
|
| 92 |
+
|
| 93 |
+
Live site: https://dssl-sable.vercel.app
|
| 94 |
+
Source and full language docs: https://huggingface.co/EHS-Studio/dssl
|
package/examples/hello.dssl
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// hello.dssl — a tiny starter stylesheet
|
| 2 |
+
// bare numbers are px, hover is a nested state, /14 at the end of a color is alpha
|
| 3 |
+
|
| 4 |
+
body {
|
| 5 |
+
background: #f5f0e4
|
| 6 |
+
color: #26201a
|
| 7 |
+
padding: 40
|
| 8 |
+
font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
h1 {
|
| 12 |
+
color: #7c2d2d
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
.card {
|
| 16 |
+
background: #fdfaf2
|
| 17 |
+
border: 1 solid #ddd2bc
|
| 18 |
+
radius: 6
|
| 19 |
+
padding: 24
|
| 20 |
+
box-shadow: 0 2 6 #26201a/14
|
| 21 |
+
transition: 200
|
| 22 |
+
|
| 23 |
+
hover {
|
| 24 |
+
box-shadow: 0 6 18 #26201a/16
|
| 25 |
+
}
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
button {
|
| 29 |
+
background: #7c2d2d
|
| 30 |
+
color: #f9efdd
|
| 31 |
+
padding: 10 18
|
| 32 |
+
radius: 6
|
| 33 |
+
border: 0
|
| 34 |
+
transition: 200
|
| 35 |
+
|
| 36 |
+
hover {
|
| 37 |
+
background: #5e1f1f
|
| 38 |
+
}
|
| 39 |
+
}
|
package/install.sh
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/sh
|
| 2 |
+
# DSSL engine installer
|
| 3 |
+
# curl -fsSL https://dssl-sable.vercel.app/install.sh | sh
|
| 4 |
+
set -e
|
| 5 |
+
BASE="https://dssl-sable.vercel.app"
|
| 6 |
+
ZIP="/tmp/dssl-engine-$$.zip"
|
| 7 |
+
|
| 8 |
+
command -v curl >/dev/null 2>&1 || { echo "DSSL installer: 'curl' is required."; exit 1; }
|
| 9 |
+
command -v unzip >/dev/null 2>&1 || { echo "DSSL installer: 'unzip' is required."; exit 1; }
|
| 10 |
+
|
| 11 |
+
echo "fetching the DSSL engine..."
|
| 12 |
+
curl -fsSL "$BASE/dssl-engine.zip" -o "$ZIP"
|
| 13 |
+
rm -rf dssl-engine
|
| 14 |
+
unzip -q "$ZIP" -d .
|
| 15 |
+
rm -f "$ZIP"
|
| 16 |
+
|
| 17 |
+
echo ""
|
| 18 |
+
echo "DSSL engine installed to ./dssl-engine"
|
| 19 |
+
echo "read dssl-engine/USAGE.md to wire it into a page."
|