mirror of
https://github.com/jdan/98.css.git
synced 2025-09-09 05:30:49 +02:00
helper code for rendering examples
This commit is contained in:
19
build.js
19
build.js
@@ -10,12 +10,29 @@ function getCurrentId() {
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function example(code) {
|
||||||
|
const magicBrackets = /\[\[(.*)\]\]/g;
|
||||||
|
const inline = code.replace(magicBrackets, "$1");
|
||||||
|
const escaped = code
|
||||||
|
.replace(magicBrackets, "")
|
||||||
|
.replace(/</g, "<")
|
||||||
|
.replace(/>/g, ">");
|
||||||
|
|
||||||
|
return `<div class="example">
|
||||||
|
${inline}
|
||||||
|
<details>
|
||||||
|
<summary>Show code</summary>
|
||||||
|
<pre><code>${escaped}</code></pre>
|
||||||
|
</details>
|
||||||
|
</div>`;
|
||||||
|
}
|
||||||
|
|
||||||
function buildDocs() {
|
function buildDocs() {
|
||||||
const template = fs.readFileSync("./docs/index.html.ejs", "utf-8");
|
const template = fs.readFileSync("./docs/index.html.ejs", "utf-8");
|
||||||
|
|
||||||
fs.writeFileSync(
|
fs.writeFileSync(
|
||||||
"./docs/index.html",
|
"./docs/index.html",
|
||||||
ejs.render(template, { getNewId, getCurrentId })
|
ejs.render(template, { getNewId, getCurrentId, example })
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -92,55 +92,31 @@
|
|||||||
They are given 12px of horizontal padding by default.
|
They are given 12px of horizontal padding by default.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="example">
|
<%- example(`<button>Click me</button>`) %>
|
||||||
<button>Click me</button>
|
|
||||||
|
|
||||||
<details>
|
|
||||||
<summary>Show code</summary>
|
|
||||||
<pre><code><button>Click me</button></code></pre>
|
|
||||||
</details>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
When buttons are clicked, the raised borders become sunken.
|
When buttons are clicked, the raised borders become sunken.
|
||||||
The following button is simulated to be in the pressed (active) state.
|
The following button is simulated to be in the pressed (active) state.
|
||||||
|
|
||||||
<div class="example">
|
|
||||||
<button class="active">I am being pressed</button>
|
|
||||||
|
|
||||||
<details>
|
|
||||||
<summary>Show code</summary>
|
|
||||||
<pre><code><button>I am being pressed</button></code></pre>
|
|
||||||
</details>
|
|
||||||
</div>
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<% /* [[ ... ]] is used to render contents that
|
||||||
|
will not appear in the "Show code" section */
|
||||||
|
%>
|
||||||
|
<%- example(`<button[[ class="active"]]>I am being pressed</button>`) %>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Disabled buttons maintain the same raised border, but have a "washed out"
|
Disabled buttons maintain the same raised border, but have a "washed out"
|
||||||
appearance in their label.
|
appearance in their label.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="example">
|
<%- example(`<button disabled>I cannot be clicked</button>`) %>
|
||||||
<button disabled>I cannot be clicked</button>
|
|
||||||
|
|
||||||
<details>
|
|
||||||
<summary>Show code</summary>
|
|
||||||
<pre><code><button disabled>I cannot be clicked</button></code></pre>
|
|
||||||
</details>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Button focus is communicated with a dotted border, set 4px within the contents of the button.
|
Button focus is communicated with a dotted border, set 4px within the contents of the button.
|
||||||
The following example is simulated to be focused.
|
The following example is simulated to be focused.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="example">
|
<%- example(`<button[[ class="focused"]]>I am focused</button>`) %>
|
||||||
<button class="focused">I am focused</button>
|
|
||||||
<details>
|
|
||||||
<summary>Show code</summary>
|
|
||||||
<pre><code><button>I am focused</button></code></pre>
|
|
||||||
</details>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user