@mccaskie-labs/workbench-site 0.15.2 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/frames.js +3 -3
- package/dist/hero-starts.d.ts +40 -0
- package/dist/hero-starts.js +986 -0
- package/dist/hero-styles.d.ts +473 -0
- package/dist/hero-styles.js +173 -0
- package/dist/hero.d.ts +220 -0
- package/dist/hero.js +173 -0
- package/dist/html.d.ts +6 -0
- package/dist/html.js +8 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/samples.js +15 -0
- package/dist/sections.d.ts +3 -0
- package/dist/sections.js +7 -4
- package/dist/styles.d.ts +14 -0
- package/dist/styles.js +5 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
export { frame, FOOTERS, FRAMES, HEADERS } from "./frames.js";
|
|
5
5
|
export { escape } from "./html.js";
|
|
6
6
|
export { account, callToAction, DESIGN_COOKIE, designModeOn, designModePost, designSwitch, details, enquiryList, needsYou, formSection, hero, HERO_ARRANGEMENTS, list, picture, text, } from "./sections.js";
|
|
7
|
+
export { designedHero, heroDesign, heroSettingsProblems, resolveHeroSettings, HERO_DESIGNS, HERO_HEIGHTS, HERO_MOTIONS, HERO_PANELS, HERO_PHONE_HEIGHTS, HERO_PLACES, HERO_SHADE_COLOURS, HERO_SHADE_FROM, HERO_SHADES, HERO_SHAPES, HERO_SIDES, HERO_SPLITS, HERO_WIDTHS, HERO_WORDS_WIDTHS, } from "./hero.js";
|
|
8
|
+
export { SITE_STYLES } from "./styles.js";
|
|
9
|
+
export { HERO_GROUPS, HERO_SAMPLE_SLOTS, HERO_STARTS, heroStart, heroStartsFor } from "./hero-starts.js";
|
|
7
10
|
export { recipeKeys, recipeProblems, TIERS } from "./recipe.js";
|
|
8
11
|
export { RECIPES } from "./recipes/index.js";
|
|
9
12
|
export { MAX_OWNER_LINE, MAX_OWNER_WORD, ownerWordKey, readOwnerWords, SITE_SETTINGS, siteAnswers, siteSettings } from "./owner-words.js";
|
package/dist/samples.js
CHANGED
|
@@ -6,7 +6,21 @@
|
|
|
6
6
|
import { FOOTERS, frame, FRAMES, HEADERS } from "./frames.js";
|
|
7
7
|
import { account, callToAction, designSwitch, details, enquiryList, formSection, hero, list, needsYou, picture, text } from "./sections.js";
|
|
8
8
|
import { SITE_STYLES } from "./styles.js";
|
|
9
|
+
import { designedHero, HERO_DESIGNS } from "./hero.js";
|
|
10
|
+
import { HERO_SAMPLE_SLOTS, HERO_STARTS } from "./hero-starts.js";
|
|
9
11
|
const PHOTO = { src: `data:image/svg+xml,${encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 160 90"><rect width="160" height="90" fill="#6b8f71"/></svg>')}`, alt: "The studio in morning light" };
|
|
12
|
+
const shade = (fill) => ({ src: `data:image/svg+xml,${encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 160 100"><rect width="160" height="100" fill="${fill}"/><circle cx="110" cy="40" r="18" fill="#f3d27a"/></svg>`)}`, alt: "" });
|
|
13
|
+
const HERO_PHOTOS = [shade("#4f6d7a"), shade("#7a5c4f"), shade("#5c7a4f"), shade("#6b4f7a")];
|
|
14
|
+
/** One sample per hero design, drawn from its first starting point with stand-in photos. */
|
|
15
|
+
const heroSamples = () => HERO_DESIGNS.map((design, i) => {
|
|
16
|
+
const start = HERO_STARTS.find((s) => s.design === design.id);
|
|
17
|
+
const motion = ["slow-zoom", "fade-in", "words-rise"][i % 3];
|
|
18
|
+
return {
|
|
19
|
+
id: `hero-${design.id}`,
|
|
20
|
+
title: `Hero: ${design.name}`,
|
|
21
|
+
html: () => designedHero({ ...start.words, pictures: start.photos.map((_, k) => HERO_PHOTOS[k % HERO_PHOTOS.length]), ...(start.tool ? { slot: HERO_SAMPLE_SLOTS[start.tool] } : {}), ...(i === 0 ? { phonePicture: HERO_PHOTOS[1], notice: { text: "Bookings close at 5 pm today.", link: { label: "Book now", href: "/book" } } } : {}) }, { ...start.settings, motion }),
|
|
22
|
+
};
|
|
23
|
+
});
|
|
10
24
|
const MENU = [
|
|
11
25
|
{ label: "Classes", href: "/classes" },
|
|
12
26
|
{ label: "Prices", href: "/prices" },
|
|
@@ -41,6 +55,7 @@ export const SITE_SAMPLES = {
|
|
|
41
55
|
prefix: SITE_STYLES.prefix,
|
|
42
56
|
samples: [
|
|
43
57
|
...FRAMES.map((f, i) => ({ id: `frame-${f}`, title: `A page in the ${f.replace("-", " ")} frame`, html: () => page(f, HEADERS[i % HEADERS.length], FOOTERS[i % FOOTERS.length], i === 0 ? "staging" : undefined) })),
|
|
58
|
+
...heroSamples(),
|
|
44
59
|
{ id: "hero-over", title: "A hero over its picture", html: () => hero({ heading: "Find your calm", arrangement: "over-picture", picture: PHOTO, action: { label: "Book", href: "/book" } }) },
|
|
45
60
|
{ id: "picture", title: "A picture with its caption", html: () => picture({ ...PHOTO, caption: "The garden room" }) },
|
|
46
61
|
{ id: "design-switch", title: "Design mode's switch", html: () => designSwitch({ on: false, live: false, words: { on: "Design mode is on in this browser.", off: "Try looks and layouts on your own pages. Only you see them until you keep them.", turnOn: "Turn on design mode", turnOff: "Turn it off", live: "Design mode is on your test site." } }) },
|
package/dist/sections.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type HeroSettings } from "./hero.ts";
|
|
1
2
|
/** A link drawn as a button. `href` is a path on this site, https, mailto or tel. */
|
|
2
3
|
export interface Action {
|
|
3
4
|
label: string;
|
|
@@ -19,6 +20,8 @@ export interface HeroOptions {
|
|
|
19
20
|
/** Defaults to "plain". The two picture arrangements need `picture`, and fall back to plain without one. */
|
|
20
21
|
arrangement?: HeroArrangement;
|
|
21
22
|
picture?: Picture;
|
|
23
|
+
/** Draws the hero in one of the hero designs instead (docs/hero-and-images.md), with these settings. */
|
|
24
|
+
design?: HeroSettings;
|
|
22
25
|
}
|
|
23
26
|
/** The top of a page: its big heading, a line or two under it and one button. The page's only h1. */
|
|
24
27
|
export declare function hero(o: HeroOptions): string;
|
package/dist/sections.js
CHANGED
|
@@ -4,14 +4,17 @@
|
|
|
4
4
|
// project restyles it from its own project.css. Tools draw their own sections
|
|
5
5
|
// (the free times, the order form) from their own packages; these are the
|
|
6
6
|
// general ones every site uses.
|
|
7
|
-
import {
|
|
7
|
+
import { designedHero } from "./hero.js";
|
|
8
|
+
import { escape, newTab, paragraphs, safeHref } from "./html.js";
|
|
8
9
|
/** How a hero is laid out: words alone, words over a picture, or words beside one. */
|
|
9
10
|
export const HERO_ARRANGEMENTS = ["plain", "over-picture", "beside-picture"];
|
|
10
|
-
const action = (a, quiet = false) => a ? `<p class="wb-site-actions"><a class="wb-site-button${quiet ? " wb-site-button-quiet" : ""}" href="${escape(safeHref(a.href))}">${escape(a.label)}</a></p>` : "";
|
|
11
|
+
const action = (a, quiet = false) => a ? `<p class="wb-site-actions"><a class="wb-site-button${quiet ? " wb-site-button-quiet" : ""}" href="${escape(safeHref(a.href))}"${newTab(safeHref(a.href))}>${escape(a.label)}</a></p>` : "";
|
|
11
12
|
const img = (p) => `<img class="wb-site-image" src="${escape(safeHref(p.src))}" alt="${escape(p.alt)}" loading="lazy">`;
|
|
12
13
|
const heading = (text, level = 2) => (text ? `<h${level} class="wb-site-heading">${escape(text)}</h${level}>` : "");
|
|
13
14
|
/** The top of a page: its big heading, a line or two under it and one button. The page's only h1. */
|
|
14
15
|
export function hero(o) {
|
|
16
|
+
if (o.design)
|
|
17
|
+
return designedHero({ heading: o.heading, ...(o.lead ? { lead: o.lead } : {}), ...(o.action ? { actions: [o.action] } : {}), ...(o.picture ? { pictures: [o.picture] } : {}) }, o.design);
|
|
15
18
|
const arrangement = o.picture ? (o.arrangement ?? "plain") : "plain";
|
|
16
19
|
const words = `<div class="wb-site-hero-words"><h1 class="wb-site-hero-heading">${escape(o.heading)}</h1>${o.lead ? paragraphs(o.lead, "wb-site-lead") : ""}${action(o.action)}</div>`;
|
|
17
20
|
const picture = arrangement !== "plain" && o.picture ? `<div class="wb-site-hero-picture">${img(o.picture)}</div>` : "";
|
|
@@ -25,7 +28,7 @@ export function text(o) {
|
|
|
25
28
|
export function list(o) {
|
|
26
29
|
const items = o.items
|
|
27
30
|
.map((i) => {
|
|
28
|
-
const title = i.href ? `<h3 class="wb-site-heading"><a class="wb-site-link" href="${escape(safeHref(i.href))}">${escape(i.title)}</a></h3>` : heading(i.title, 3);
|
|
31
|
+
const title = i.href ? `<h3 class="wb-site-heading"><a class="wb-site-link" href="${escape(safeHref(i.href))}"${newTab(safeHref(i.href))}>${escape(i.title)}</a></h3>` : heading(i.title, 3);
|
|
29
32
|
return `<li class="wb-site-item">${title}${i.body ? paragraphs(i.body, "wb-site-paragraph") : ""}</li>`;
|
|
30
33
|
})
|
|
31
34
|
.join("");
|
|
@@ -97,7 +100,7 @@ export function needsYou(o) {
|
|
|
97
100
|
.map((i) => {
|
|
98
101
|
const count = i.count === null ? "" : `<span class="wb-site-needs-count">${i.count}</span> `;
|
|
99
102
|
const unknown = i.count === null ? ` <span class="wb-site-needs-unknown">${escape(o.unavailable)}</span>` : "";
|
|
100
|
-
return `<li class="wb-site-needs-item"><a class="wb-site-needs-link" href="${escape(safeHref(i.href))}">${count}<span class="wb-site-needs-label">${escape(i.label)}</span></a>${unknown}</li>`;
|
|
103
|
+
return `<li class="wb-site-needs-item"><a class="wb-site-needs-link" href="${escape(safeHref(i.href))}"${newTab(safeHref(i.href))}>${count}<span class="wb-site-needs-label">${escape(i.label)}</span></a>${unknown}</li>`;
|
|
101
104
|
})
|
|
102
105
|
.join("")}</ul>`
|
|
103
106
|
: `<p class="wb-site-paragraph">${escape(o.none)}</p>`;
|
package/dist/styles.d.ts
CHANGED
|
@@ -17,6 +17,19 @@ interface StyleClass {
|
|
|
17
17
|
about: string;
|
|
18
18
|
css: string;
|
|
19
19
|
states?: readonly StyleState[];
|
|
20
|
+
/** Rules from 600px wide; the class's own rules are a phone's. */
|
|
21
|
+
wide?: readonly StyleState[];
|
|
22
|
+
/** Rules for movement, only on a device that hasn't asked for less motion. */
|
|
23
|
+
moving?: readonly StyleState[];
|
|
24
|
+
}
|
|
25
|
+
/** A named movement the `moving` rules play. */
|
|
26
|
+
interface StyleKeyframes {
|
|
27
|
+
name: string;
|
|
28
|
+
about: string;
|
|
29
|
+
steps: readonly {
|
|
30
|
+
at: string;
|
|
31
|
+
css: string;
|
|
32
|
+
}[];
|
|
20
33
|
}
|
|
21
34
|
/** Every class and variable the tool draws with. */
|
|
22
35
|
export interface ToolStyles {
|
|
@@ -27,6 +40,7 @@ export interface ToolStyles {
|
|
|
27
40
|
prefix: string;
|
|
28
41
|
variables: readonly StyleVariable[];
|
|
29
42
|
classes: readonly StyleClass[];
|
|
43
|
+
keyframes?: readonly StyleKeyframes[];
|
|
30
44
|
}
|
|
31
45
|
/** The style hooks of the site's frames and sections. */
|
|
32
46
|
export declare const SITE_STYLES: ToolStyles;
|
package/dist/styles.js
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
// project's public/styles/workbench.css; the project restyles them in its own
|
|
9
9
|
// project.css by the same names. The names are public: renaming one is a
|
|
10
10
|
// breaking change.
|
|
11
|
+
import { HERO_CLASSES, HERO_KEYFRAMES, HERO_VARIABLES } from "./hero-styles.js";
|
|
11
12
|
const v = (name) => `var(--wb-site-${name})`;
|
|
12
13
|
const focus = { selector: ":focus-visible", about: "Has focus", css: `outline:2px solid ${v("focus")};outline-offset:2px` };
|
|
13
14
|
/** The style hooks of the site's frames and sections. */
|
|
@@ -36,10 +37,11 @@ export const SITE_STYLES = {
|
|
|
36
37
|
{ name: "--wb-site-width", value: "var(--wb-page-width, 72rem)", about: "The widest the header, footer and landing sections get (the theme's page width, from the site layout)" },
|
|
37
38
|
{ name: "--wb-site-reading", value: "42rem", about: "The width of a column frame, kept short enough to read" },
|
|
38
39
|
{ name: "--wb-site-section-space", value: "var(--wb-section-space, 2.5rem)", about: "The space above and below each section (the theme's section spacing, from the site layout)" },
|
|
40
|
+
...HERO_VARIABLES,
|
|
39
41
|
],
|
|
40
42
|
classes: [
|
|
41
43
|
{ name: "wb-site", element: "html", about: "A site page drawn by a frame", css: `background:${v("background")};color:${v("text")}` },
|
|
42
|
-
{ name: "wb-site-body", element: "body", about: "The page", css: `margin:0;min-height:100vh;display:flex;flex-direction:column;font-family:${v("font")};line-height:1.6;background:${v("background")};color:${v("text")}` },
|
|
44
|
+
{ name: "wb-site-body", element: "body", about: "The page", css: `margin:0;min-height:100vh;display:flex;flex-direction:column;font-family:${v("font")};line-height:1.6;overflow-x:clip;background:${v("background")};color:${v("text")}` },
|
|
43
45
|
{
|
|
44
46
|
name: "wb-site-header",
|
|
45
47
|
element: "header",
|
|
@@ -96,6 +98,7 @@ export const SITE_STYLES = {
|
|
|
96
98
|
{ name: "wb-site-hero-words", element: "div", about: "The hero's words", css: `position:relative;max-width:40rem` },
|
|
97
99
|
{ name: "wb-site-hero-heading", element: "h1", about: "The page's heading", css: `margin:0 0 calc(${v("space")} * .75);font-family:${v("font-heading")};font-size:clamp(2rem, 5vw, 3rem);line-height:1.15` },
|
|
98
100
|
{ name: "wb-site-hero-picture", element: "div", about: "The hero's picture", css: `min-width:0` },
|
|
101
|
+
...HERO_CLASSES,
|
|
99
102
|
{ name: "wb-site-lead", element: "p", about: "The line or two under the page's heading", css: `margin:0 0 ${v("space")};font-size:1.2rem;color:${v("muted")}` },
|
|
100
103
|
{ name: "wb-site-actions", element: "p", about: "Where a section's button sits", css: `margin:calc(${v("space")} * 1.5) 0 0` },
|
|
101
104
|
{
|
|
@@ -158,4 +161,5 @@ export const SITE_STYLES = {
|
|
|
158
161
|
{ name: "wb-site-footer-link", element: "a", about: "A footer link", css: `color:${v("muted")}`, states: [{ selector: ":hover", about: "Under the pointer", css: `color:${v("text")}` }, focus] },
|
|
159
162
|
{ name: "wb-site-footer-note", element: "p", about: "A line in the footer", css: `margin:${v("space")} 0 0` },
|
|
160
163
|
],
|
|
164
|
+
keyframes: HERO_KEYFRAMES,
|
|
161
165
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mccaskie-labs/workbench-site",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"description": "A Workbench project's standard pages: page recipes, the builder that turns them into thin page files calling Workbench's tools, and the page frames and sections they are drawn with (wb-site-*, restylable, on the project's theme tokens).",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|