diff --git a/pagerender.js b/pagerender.js index 0d8f69f..18e4a4b 100644 --- a/pagerender.js +++ b/pagerender.js @@ -10,7 +10,7 @@ const href = u => { const s = String(u || '').trim(); return /^https?:\/\/[^\s"' const PALETTE_NAMES = Object.keys(S.PALETTES).concat(['ink', 'ember']); // the three knobs a page carries, with safe fallbacks for anything stored by older code -function knobs(page) { const d = page.design || {}; return { pk: S.paletteKey(d.palette), design: S.designKey(d.design), layout: S.layoutKey(d.layout), niche: S.nicheKey(d.niche) }; } +function knobs(page) { const d = page.design || {}; return { pk: S.paletteKey(d.palette), design: S.designKey(d.design), layout: S.layoutKey(d.layout), niche: S.nicheKey(d.niche), hero: d.hero }; } function baseCss(k) { const P = S.PALETTES[k.pk], C = P.c, dkGround = k.design === 'dark' || k.design === 'ignition'; @@ -49,7 +49,7 @@ function ctaBtn(c, extra) { const u = href(c && c.url); const t = esc((c && c.te const headline = (k, t) => (k.design === 'ignition' ? S.blazeHeadline(t) : esc(t || '')); // the visual on the right of a split: the member's image, else the niche hero, else the procedural card function sideVisual(k, c) { - const img = href(c.image) || S.nicheHero(k.niche); + const img = href(c.image) || S.nicheHero(k.niche, k.hero); if (img) return '
' + esc(c.imageAlt || '') + '
'; return '
' + S.visualHtml(c.headline, c.bullets && c.bullets.length ? c.bullets : c.pros, c.price) + '
'; } @@ -62,7 +62,7 @@ function formArea(page, opts) { function render(page, opts) { opts = opts || {}; const k = knobs(page); const c = page.content || {}; const split = k.layout === 'split'; - const img = href(c.image) || S.nicheHero(k.niche); + const img = href(c.image) || S.nicheHero(k.niche, k.hero); const head = '' + esc(c.headline || page.title || 'Page') + '' + '' + (page.status !== 'published' ? '' : '') + (img ? '' : '') + '' diff --git a/pages.js b/pages.js index 408dd1e..44f3ab0 100644 --- a/pages.js +++ b/pages.js @@ -52,7 +52,8 @@ function designFrom(body, cur) { const palette = body.palette != null ? style.paletteKey(body.palette) : (body.niche != null && preset ? preset.palette : style.paletteKey(cur.palette)); const design = body.design != null ? style.designKey(body.design) : (body.niche != null && preset ? preset.design : style.designKey(cur.design)); const layout = body.layout != null ? style.layoutKey(body.layout) : style.layoutKey(cur.layout || (body.niche != null && preset ? 'split' : 'stack')); - return { palette, design, layout, niche }; + const hero = body.niche != null && body.niche !== cur.niche ? 0 : style.heroIndex(niche, body.hero != null ? body.hero : cur.hero); + return { palette, design, layout, niche, hero }; } async function create(owner, body) { if (J.db.pages.filter(p => p.owner === norm(owner)).length >= 200) return { error: 'That is a lot of pages. Remove some first.' }; @@ -68,7 +69,7 @@ async function update(owner, id, body) { if (body.remove) { J.db.pages = J.db.pages.filter(x => x !== p); J.save(); return { ok: true, removed: true }; } if (body.title != null) p.title = String(body.title).trim().slice(0, 100) || p.title; if (body.type != null && TYPES.includes(body.type)) p.type = body.type; - if (body.palette != null || body.design != null || body.layout != null || body.niche != null) p.design = designFrom(body, p.design || {}); + if (body.palette != null || body.design != null || body.layout != null || body.niche != null || body.hero != null) p.design = designFrom(body, p.design || {}); if (body.angle != null) p.angle = String(body.angle).slice(0, 160); if (body.content != null) { const c = sanitizeContent(Object.assign({}, p.content, body.content), p.type); if (p.type === 'squeeze' && c.formEmbed) { const why = formrestyle.problem(c.formEmbed); if (why) return { error: why }; } p.content = c; } if (body.status != null) { if (body.status === 'published') { if (!p.content.headline) return { error: 'Give the page a headline before publishing.' }; if (p.type !== 'squeeze' && !p.content.cta.url) return { error: 'Add the button link (where the page sends people) before publishing.' }; p.status = 'published'; } else p.status = 'draft'; } diff --git a/pagestyle.js b/pagestyle.js index 513c670..ff1d544 100644 --- a/pagestyle.js +++ b/pagestyle.js @@ -32,26 +32,29 @@ const DESIGNS = { ignition: { label: 'Ignition', blurb: 'Black ground, ray burst, hot headline' }, }; const LAYOUTS = { stack: { label: 'Stacked', blurb: 'Centred copy, image below the headline' }, split: { label: 'Split hero', blurb: 'Copy left, visual right' } }; -const NICHE_HERO_ORIGIN = 'https://mybrandedvoice.com'; +const HERO_COUNT = { 'health-wellness': 4, 'make-money-online': 4, 'personal-finance': 4, 'coaching-consulting': 4, 'self-improvement': 4, relationships: 4, gaming: 4 }; // /niches/-1..n.jpg (photographic, 1536x1024, textless) const NICHES = { - 'health-wellness': { label: 'Health & Wellness', design: 'light', palette: 'ocean', hero: '/marketing/niches/health-wellness.jpg', blurb: 'Fresh and calm: teal & sand, clean light pages' }, - 'make-money-online': { label: 'Make Money Online', design: 'ignition', palette: 'heritage', hero: '/marketing/niches/make-money-online.jpg', blurb: 'Launch heat: black ground, inferno orange' }, - 'personal-finance': { label: 'Personal Finance', design: 'dark', palette: 'midnight', hero: '/marketing/niches/personal-finance.jpg', blurb: 'Trustworthy: navy & amber, dramatic dark' }, - 'coaching-consulting': { label: 'Coaching & Consulting', design: 'editorial', palette: 'plum', hero: '/marketing/niches/coaching-consulting.jpg', blurb: 'Premium: magazine layout, aubergine & honey' }, - 'self-improvement': { label: 'Self-Improvement', design: 'light', palette: 'heritage', hero: '/marketing/niches/self-improvement.jpg', blurb: 'Uplifting: green & gold on clean white' }, - relationships: { label: 'Relationships', design: 'light', palette: 'plum', hero: '/marketing/niches/relationships.jpg', blurb: 'Warm: aubergine & honey, soft light pages' }, + 'health-wellness': { label: 'Health & Wellness', design: 'light', palette: 'ocean', blurb: 'Fresh and calm: teal & sand, clean light pages' }, + 'make-money-online': { label: 'Make Money Online', design: 'ignition', palette: 'heritage', blurb: 'Launch heat: black ground, inferno orange' }, + 'personal-finance': { label: 'Personal Finance', design: 'dark', palette: 'midnight', blurb: 'Trustworthy: navy & amber, dramatic dark' }, + 'coaching-consulting': { label: 'Coaching & Consulting', design: 'editorial', palette: 'plum', blurb: 'Premium: magazine layout, aubergine & honey' }, + 'self-improvement': { label: 'Self-Improvement', design: 'light', palette: 'heritage', blurb: 'Uplifting: green & gold on clean white' }, + relationships: { label: 'Relationships', design: 'light', palette: 'plum', blurb: 'Warm: aubergine & honey, soft light pages' }, + gaming: { label: 'Gaming', design: 'dark', palette: 'midnight', blurb: 'Night mode: navy & amber, glow hero' }, }; const paletteKey = n => { n = String(n || '').toLowerCase(); return PALETTES[n] ? n : LEGACY[n] || 'graphite'; }; const designKey = n => (DESIGNS[String(n || '').toLowerCase()] ? String(n).toLowerCase() : 'dark'); const layoutKey = n => (LAYOUTS[String(n || '').toLowerCase()] ? String(n).toLowerCase() : 'stack'); const nicheKey = n => (NICHES[String(n || '').toLowerCase()] ? String(n).toLowerCase() : ''); -const nicheHero = n => (NICHES[n] ? NICHE_HERO_ORIGIN + NICHES[n].hero : ''); +const nicheHeroes = n => (NICHES[n] ? Array.from({ length: HERO_COUNT[n] || 1 }, (_, i) => '/niches/' + n + '-' + (i + 1) + '.jpg') : []); +const heroIndex = (n, i) => { const L = nicheHeroes(n).length; i = Number(i); return L && Number.isInteger(i) && i >= 0 && i < L ? i : 0; }; +const nicheHero = (n, i) => { const h = nicheHeroes(n); return h.length ? h[heroIndex(n, i)] : ''; }; // what the editor shows: swatches, labels, blurbs const catalog = () => ({ palettes: Object.entries(PALETTES).map(([k, p]) => ({ key: k, label: p.label, sub: p.sub, swatch: [p.c.inkGreen, p.c.gold, p.c.green] })), designs: Object.entries(DESIGNS).map(([k, d]) => ({ key: k, label: d.label, blurb: d.blurb })), layouts: Object.entries(LAYOUTS).map(([k, l]) => ({ key: k, label: l.label, blurb: l.blurb })), - niches: Object.entries(NICHES).map(([k, n]) => ({ key: k, label: n.label, blurb: n.blurb, design: n.design, palette: n.palette, hero: NICHE_HERO_ORIGIN + n.hero })), + niches: Object.entries(NICHES).map(([k, n]) => ({ key: k, label: n.label, blurb: n.blurb, design: n.design, palette: n.palette, hero: nicheHero(k, 0), heroes: nicheHeroes(k) })), }); // ---- colour helpers ---- @@ -130,4 +133,4 @@ function visualHtml(offer, bullets, price) { return '
' + chip + '
' + esc(many ? '100%' : offer) + '' + esc(many ? offer : 'complete system') + '
' + (bullets.length ? '
' + ticks(bullets) + '
' : '') + '
'; } -module.exports = { FONT, SERIF, IGNITION_DISPLAY, PALETTES, DESIGNS, LAYOUTS, NICHES, paletteKey, designKey, layoutKey, nicheKey, nicheHero, catalog, rgba, hotRamp, blazeHeadline, kitCss, visualCss, visualHtml, esc }; +module.exports = { FONT, SERIF, IGNITION_DISPLAY, PALETTES, DESIGNS, LAYOUTS, NICHES, paletteKey, designKey, layoutKey, nicheKey, nicheHero, nicheHeroes, heroIndex, catalog, rgba, hotRamp, blazeHeadline, kitCss, visualCss, visualHtml, esc }; diff --git a/public/assets/pages-screen.js b/public/assets/pages-screen.js index 54a2011..de71e05 100644 --- a/public/assets/pages-screen.js +++ b/public/assets/pages-screen.js @@ -49,6 +49,7 @@ // the Look panel: niche preset, design, colours, layout. Each change saves at once and the gallery/preview refresh. const d = p.design || {}; const setLook = async patch => { try { await api('/api/my/pages/' + p.id, patch); load(true); } catch (e) { toast(e.message, true); } }; const ns = $('niche'); ns.innerHTML = '' + STYLES.niches.map(n => '').join(''); ns.onchange = () => setLook({ niche: ns.value }); + { const nn = STYLES.niches.find(n => n.key === d.niche); const row = $('heroRow'); if (nn && nn.heroes && nn.heroes.length > 1 && row) { row.hidden = false; $('heroes').innerHTML = nn.heroes.map((u, i) => '').join(''); $('heroes').querySelectorAll('button').forEach(b => b.addEventListener('click', () => setLook({ hero: Number(b.dataset.h) }))); } else if (row) row.hidden = true; } $('designs').innerHTML = STYLES.designs.map(x => '').join(''); $('designs').querySelectorAll('button').forEach(b => b.addEventListener('click', () => setLook({ design: b.dataset.d }))); $('pal').innerHTML = STYLES.palettes.map(x => '').join(''); diff --git a/public/niches/coaching-consulting-1.jpg b/public/niches/coaching-consulting-1.jpg new file mode 100644 index 0000000..241a784 Binary files /dev/null and b/public/niches/coaching-consulting-1.jpg differ diff --git a/public/niches/coaching-consulting-2.jpg b/public/niches/coaching-consulting-2.jpg new file mode 100644 index 0000000..ccf2859 Binary files /dev/null and b/public/niches/coaching-consulting-2.jpg differ diff --git a/public/niches/coaching-consulting-3.jpg b/public/niches/coaching-consulting-3.jpg new file mode 100644 index 0000000..3cd9814 Binary files /dev/null and b/public/niches/coaching-consulting-3.jpg differ diff --git a/public/niches/coaching-consulting-4.jpg b/public/niches/coaching-consulting-4.jpg new file mode 100644 index 0000000..9f77999 Binary files /dev/null and b/public/niches/coaching-consulting-4.jpg differ diff --git a/public/niches/gaming-1.jpg b/public/niches/gaming-1.jpg new file mode 100644 index 0000000..1a8975a Binary files /dev/null and b/public/niches/gaming-1.jpg differ diff --git a/public/niches/gaming-2.jpg b/public/niches/gaming-2.jpg new file mode 100644 index 0000000..5511b4c Binary files /dev/null and b/public/niches/gaming-2.jpg differ diff --git a/public/niches/gaming-3.jpg b/public/niches/gaming-3.jpg new file mode 100644 index 0000000..1cd34a3 Binary files /dev/null and b/public/niches/gaming-3.jpg differ diff --git a/public/niches/gaming-4.jpg b/public/niches/gaming-4.jpg new file mode 100644 index 0000000..ebf872d Binary files /dev/null and b/public/niches/gaming-4.jpg differ diff --git a/public/niches/health-wellness-1.jpg b/public/niches/health-wellness-1.jpg new file mode 100644 index 0000000..c1d7bca Binary files /dev/null and b/public/niches/health-wellness-1.jpg differ diff --git a/public/niches/health-wellness-2.jpg b/public/niches/health-wellness-2.jpg new file mode 100644 index 0000000..b297754 Binary files /dev/null and b/public/niches/health-wellness-2.jpg differ diff --git a/public/niches/health-wellness-3.jpg b/public/niches/health-wellness-3.jpg new file mode 100644 index 0000000..83e2a23 Binary files /dev/null and b/public/niches/health-wellness-3.jpg differ diff --git a/public/niches/health-wellness-4.jpg b/public/niches/health-wellness-4.jpg new file mode 100644 index 0000000..0887a43 Binary files /dev/null and b/public/niches/health-wellness-4.jpg differ diff --git a/public/niches/make-money-online-1.jpg b/public/niches/make-money-online-1.jpg new file mode 100644 index 0000000..73cf9db Binary files /dev/null and b/public/niches/make-money-online-1.jpg differ diff --git a/public/niches/make-money-online-2.jpg b/public/niches/make-money-online-2.jpg new file mode 100644 index 0000000..a25fa2b Binary files /dev/null and b/public/niches/make-money-online-2.jpg differ diff --git a/public/niches/make-money-online-3.jpg b/public/niches/make-money-online-3.jpg new file mode 100644 index 0000000..54061bd Binary files /dev/null and b/public/niches/make-money-online-3.jpg differ diff --git a/public/niches/make-money-online-4.jpg b/public/niches/make-money-online-4.jpg new file mode 100644 index 0000000..0f2191a Binary files /dev/null and b/public/niches/make-money-online-4.jpg differ diff --git a/public/niches/personal-finance-1.jpg b/public/niches/personal-finance-1.jpg new file mode 100644 index 0000000..e2bbe2a Binary files /dev/null and b/public/niches/personal-finance-1.jpg differ diff --git a/public/niches/personal-finance-2.jpg b/public/niches/personal-finance-2.jpg new file mode 100644 index 0000000..b5cef89 Binary files /dev/null and b/public/niches/personal-finance-2.jpg differ diff --git a/public/niches/personal-finance-3.jpg b/public/niches/personal-finance-3.jpg new file mode 100644 index 0000000..cb2c5f9 Binary files /dev/null and b/public/niches/personal-finance-3.jpg differ diff --git a/public/niches/personal-finance-4.jpg b/public/niches/personal-finance-4.jpg new file mode 100644 index 0000000..9eea9e7 Binary files /dev/null and b/public/niches/personal-finance-4.jpg differ diff --git a/public/niches/relationships-1.jpg b/public/niches/relationships-1.jpg new file mode 100644 index 0000000..1d691f4 Binary files /dev/null and b/public/niches/relationships-1.jpg differ diff --git a/public/niches/relationships-2.jpg b/public/niches/relationships-2.jpg new file mode 100644 index 0000000..197599b Binary files /dev/null and b/public/niches/relationships-2.jpg differ diff --git a/public/niches/relationships-3.jpg b/public/niches/relationships-3.jpg new file mode 100644 index 0000000..5a0ba8c Binary files /dev/null and b/public/niches/relationships-3.jpg differ diff --git a/public/niches/relationships-4.jpg b/public/niches/relationships-4.jpg new file mode 100644 index 0000000..0a93c66 Binary files /dev/null and b/public/niches/relationships-4.jpg differ diff --git a/public/niches/self-improvement-1.jpg b/public/niches/self-improvement-1.jpg new file mode 100644 index 0000000..5e6d5f7 Binary files /dev/null and b/public/niches/self-improvement-1.jpg differ diff --git a/public/niches/self-improvement-2.jpg b/public/niches/self-improvement-2.jpg new file mode 100644 index 0000000..78dd1ae Binary files /dev/null and b/public/niches/self-improvement-2.jpg differ diff --git a/public/niches/self-improvement-3.jpg b/public/niches/self-improvement-3.jpg new file mode 100644 index 0000000..c1d96a5 Binary files /dev/null and b/public/niches/self-improvement-3.jpg differ diff --git a/public/niches/self-improvement-4.jpg b/public/niches/self-improvement-4.jpg new file mode 100644 index 0000000..4eed876 Binary files /dev/null and b/public/niches/self-improvement-4.jpg differ diff --git a/public/pages.html b/public/pages.html index 96d1cd7..4af04aa 100644 --- a/public/pages.html +++ b/public/pages.html @@ -10,6 +10,7 @@