Files
5xyourteam/tools/art.mjs
T
martbost f26ac15712 5xYourTeam The Draft v1 (phase 1, local only): weekly earned-order draft of holding-tank people, picks as adoptions (stub tank), coaching tools, cards, boards, trust pack
$10 one-time DraftPosition purchases (sponsor 25%, L2-5 5%, 10% Best Coach pot, 45% company) with keeper-signed hub-line
vouchers; pure draft engine with a mocked clock; no contact data anywhere; Telegram to an outbox unless TG_LIVE=1.
Unit 60/60, smoke 156/156 (Playwright 1280/390). Not deployed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 06:16:10 -06:00

104 lines
13 KiB
JavaScript

// Renders the site art with Playwright (local only, nothing is uploaded): the icon, the OG share image, the Telegram sale proof
// cards (public/art/proof/fx-proof-{navy,gold,field}.png), the promo kit (public/art/kit/fx-<angle>-<shape>.png, 3 angles x 7
// shapes, ad-blocker-neutral names), the five trading-card tiers and a sample coach card (public/art/cards/), and, with
// node tools/art.mjs --draftday http://127.0.0.1:3561 2026-11-16
// the Draft Day results card for that week from a running app (public/art/draftday/week-<monday>.png, the Telegram image).
// Copy facts come from config.js; the look is the approved draft-night mockup (navy, gold, red tag, Oswald + Inter).
import fs from 'node:fs';
import path from 'node:path';
import { createRequire } from 'node:module';
import { fileURLToPath } from 'node:url';
const require = createRequire(import.meta.url);
const APP = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
const PW = process.env.PLAYWRIGHT || 'D:/Projects/MarketingAgent/qa-tester/node_modules/playwright';
const { chromium } = require(PW);
const C = require(path.join(APP, 'config.js')).get();
const { SHAPES } = require(path.join(APP, 'promokit.js'));
const ART = path.join(APP, 'public', 'art');
for (const d of ['kit', 'proof', 'cards', 'draftday']) fs.mkdirSync(path.join(ART, d), { recursive: true });
const FONTS = '<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Oswald:wght@500;700&family=Inter:wght@400;600;700&display=swap">';
const BASE = `*{box-sizing:border-box;margin:0}html,body{width:100%;height:100%;overflow:hidden}
body{background:#0b1530;color:#fff;font-family:Inter,sans-serif;position:relative}
.wm{font-family:Oswald,Impact,sans-serif;font-weight:700;letter-spacing:1px;white-space:nowrap}.wm b{color:#ffc93c}
.d{font-family:Oswald,Impact,sans-serif;font-weight:700;text-transform:uppercase;line-height:.95}
.g{color:#ffc93c}.tag{display:inline-block;background:#ff4d4d;color:#fff;font-family:Oswald,sans-serif;letter-spacing:2px;white-space:nowrap}
.cta{display:inline-block;background:#ffc93c;color:#0b1530;font-family:Oswald,sans-serif;letter-spacing:1px;text-transform:uppercase;white-space:nowrap}
.stripes{position:absolute;inset:0;background:repeating-linear-gradient(90deg,transparent 0 9.5%,rgba(255,255,255,.045) 9.5% 10%);pointer-events:none}
.tc{border-style:solid;display:flex;flex-direction:column;color:#0b1530}.tc .t{font-family:Oswald,sans-serif;letter-spacing:3px;text-align:center}.tc .f{display:flex;align-items:center;justify-content:center;font-family:Oswald,sans-serif}`;
const WM = px => `<span class="wm" style="font-size:${px}px">5X<b>YOUR</b>TEAM</span>`;
const TIERS = { rookie: ['ROOKIE', '#e5e9f4', '#9aa6c4', '#0b1530', '#c6cde0', '#4a587e', 'Drafted'], starter: ['STARTER', '#eaf6ef', '#1f8a5b', '#fff', '#bfe3cf', '#1f5c40', 'Wallet linked'],
pro: ['PRO', '#e8eefc', '#2f5be0', '#fff', '#c3d2fa', '#1d3a96', 'Payouts switched on'], allstar: ['ALL-STAR', '#fff7df', '#ffc93c', '#0b1530', '#ffe8a3', '#7a5a00', 'First purchase'],
hof: ['HALL OF FAME', '#1a1030', '#ffc93c', '#0b1530', '#2a1a4a', '#ffc93c', 'Built a team of their own'] };
// one trading card at scale f (base 220 x 380)
function tcard(tier, name, team, f) {
const [lab, bg, bd, ink, face, fink, ms] = TIERS[tier];
const hof = tier === 'hof';
return `<div class="tc" style="width:${220 * f}px;height:${380 * f}px;background:${bg};border-width:${6 * f}px;border-color:${bd};${tier === 'allstar' ? `box-shadow:0 0 0 ${3 * f}px #0b1530,0 0 ${24 * f}px rgba(255,201,60,.6);` : hof ? `box-shadow:0 0 0 ${3 * f}px #ff4d4d;` : ''}color:${hof ? '#fff' : '#0b1530'}">
<div class="t" style="background:${hof ? 'linear-gradient(90deg,#ffc93c,#ff4d4d)' : bd};color:${ink};font-size:${15 * f}px;padding:${6 * f}px">${lab}</div>
<div class="f" style="height:${150 * f}px;background:${face};color:${fink};font-size:${48 * f}px">${name.slice(0, 2).toUpperCase()}</div>
<div style="padding:${12 * f}px;display:flex;flex-direction:column;gap:${4 * f}px;font-size:${13 * f}px"><b style="font-family:Oswald,sans-serif;font-size:${20 * f}px">@${name}</b><span>Team @${team}</span><span>${ms}</span></div></div>`;
}
const ANG = {
draft: { k: 'EVERY MONDAY', h1: 'Draft your team', h2: 'every Monday', s: 'Coaches draft people who joined the network without a sponsor. Draft order is earned.', cta: 'Get a position' },
coach: { k: 'EARN YOUR DRAFT SPOT', h1: 'Coach them up', h2: 'pick first', s: 'Get last week\'s picks going and you pick first next Monday. Coaching through site messages.', cta: 'Start coaching' },
cards: { k: 'TRADING CARDS', h1: 'Rookie to', h2: 'Hall of Fame', s: 'Your picks are cards that level up as they do. $' + C.position.usd + ' once, ' + C.position.picksOnBuy + ' picks today.', cta: 'See the cards' }
};
const fan = f => `<div style="display:flex;align-items:flex-end;gap:${8 * f}px">${tcard('starter', 'surfqueen', 'you', .55 * f)}${tcard('allstar', 'gamerdad', 'you', .68 * f)}${tcard('pro', 'lunaclicks', 'you', .55 * f)}</div>`;
function kitHtml(angle, shape, w, h) {
const a = ANG[angle]; const m = Math.min(w, h);
if (shape === 'tile') return `<body style="display:flex;flex-direction:column;justify-content:space-between;padding:8px;border:3px solid #ffc93c"><div class="stripes"></div>${WM(13)}<div class="d" style="font-size:24px">${angle === 'cards' ? 'Level' : angle === 'coach' ? 'Coach' : 'Draft'}<br><span class="g">${angle === 'cards' ? 'them up' : angle === 'coach' ? 'them up' : 'Monday'}</span></div><div style="font-size:9px;font-weight:700">5xyourteam.com</div></body>`;
if (shape === 'strip' || shape === 'leader') { const big = shape === 'leader';
return `<body style="display:flex;align-items:center;gap:${big ? 16 : 9}px;padding:0 ${big ? 16 : 9}px;border-bottom:4px solid #ffc93c"><div class="stripes"></div>${WM(big ? 24 : 15)}<div style="flex:1;min-width:0"><div style="font-family:Oswald,sans-serif;font-size:${big ? 12 : 9}px;letter-spacing:2px;color:#ffc93c">${a.k}</div><div class="d" style="font-size:${big ? 30 : 19}px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis">${a.h1} <span class="g">${a.h2}</span></div></div><span class="cta" style="font-size:${big ? 19 : 12}px;padding:${big ? '8px 14px' : '4px 8px'}">${a.cta}</span></body>`; }
if (shape === 'tower') return `<body style="display:flex;flex-direction:column;padding:14px 12px;gap:14px;border-top:6px solid #ffc93c"><div class="stripes"></div>${WM(19)}<span class="tag" style="font-size:10px;padding:3px 6px;align-self:flex-start">${a.k}</span><div class="d" style="font-size:32px">${a.h1}<br><span class="g">${a.h2}</span></div><div style="font-size:12px;color:#b8c4e0;line-height:1.35">${a.s}</div><div style="display:flex;justify-content:center">${tcard('allstar', 'gamerdad', 'you', .45)}</div><div style="margin-top:auto;text-align:center"><span class="cta" style="font-size:16px;padding:7px 8px;display:block">${a.cta}</span><div style="font-size:11px;margin-top:8px;font-weight:700">5xyourteam.com</div></div></body>`;
const f = m / 250; const wide = shape === 'social' || shape === 'square';
return `<body style="display:flex;flex-direction:column;border-top:${Math.round(6 * f)}px solid #ffc93c"><div class="stripes"></div>
<div style="flex:1;padding:${Math.round(16 * f)}px ${Math.round(18 * f)}px;display:flex;gap:${Math.round(18 * f)}px;align-items:center;${shape === 'square' ? 'flex-direction:column;justify-content:center' : ''}">
<div style="flex:1.2;min-width:0;display:flex;flex-direction:column;gap:${Math.round(8 * f)}px">
<div style="display:flex;align-items:center;gap:${Math.round(10 * f)}px">${WM(Math.round(17 * f))}<span class="tag" style="font-size:${Math.round(9 * f)}px;padding:${Math.round(2 * f)}px ${Math.round(6 * f)}px">${a.k}</span></div>
<div class="d" style="font-size:${Math.round((wide ? 40 : 34) * f)}px">${a.h1}<br><span class="g">${a.h2}</span></div>
<div style="font-size:${Math.round(11 * f)}px;color:#b8c4e0;line-height:1.35">${a.s}</div>
<div style="display:flex;align-items:center;gap:${Math.round(10 * f)}px;flex-wrap:wrap"><span class="cta" style="font-size:${Math.round(14 * f)}px;padding:${Math.round(5 * f)}px ${Math.round(12 * f)}px">${a.cta}</span><span style="font-size:${Math.round(9 * f)}px;font-weight:700">5xyourteam.com</span></div></div>
${wide ? `<div style="flex:1;min-width:0;display:flex;justify-content:center">${fan(shape === 'square' ? f * .8 : f * .75)}</div>` : ''}</div></body>`;
}
function proofHtml(v) {
const V = { navy: ['#0b1530', '#ffc93c'], gold: ['#13214a', '#ffc93c'], field: ['#0e3b2a', '#ffc93c'] }[v];
return `<body style="background:${V[0]};display:flex;flex-direction:column;padding:56px 64px;gap:26px;border:14px solid ${V[1]}"><div class="stripes"></div>
<div style="display:flex;justify-content:space-between;align-items:center">${WM(48)}<span class="tag" style="font-size:22px;padding:6px 14px">PAID ON-CHAIN</span></div>
<div class="d" style="font-size:92px">A coach just<br><span class="g">joined The Draft</span></div>
<div style="flex:1;display:flex;gap:44px;align-items:center">${tcard('rookie', 'newcoach', 'draft', 1.15)}<div style="display:flex;flex-direction:column;gap:22px;font-size:34px;font-weight:600"><span>Sponsor 25%</span><span>Levels 2-5: 5% each</span><span class="g">Best Coach pot 10%</span><span style="color:#b8c4e0;font-size:28px">Same transaction.<br>The contract keeps nothing.</span></div></div>
<div style="font-size:24px;font-weight:600;color:#b8c4e0">Every position and every payout: 5xyourteam.com/ledger</div></body>`;
}
const ogHtml = () => `<body style="display:flex;align-items:center;padding:56px 64px;gap:40px;border-bottom:10px solid #ffc93c"><div class="stripes"></div>
<div style="flex:1.2;display:flex;flex-direction:column;gap:22px">${WM(40)}<span class="tag" style="font-size:20px;padding:5px 12px;align-self:flex-start">THE DRAFT · EVERY MONDAY</span>
<div class="d" style="font-size:74px;white-space:nowrap">Draft your team<br><span class="g">every Monday</span></div>
<div style="font-size:24px;color:#b8c4e0">$${C.position.usd} once: ${C.position.picksOnBuy} picks today,<br>a draft spot every week.</div></div>
<div style="flex:1;display:flex;justify-content:center">${fan(1.25)}</div></body>`;
const iconHtml = () => `<body style="display:flex;align-items:center;justify-content:center;background:#0b1530;border:12px solid #ffc93c"><div class="d" style="font-size:96px;line-height:1">5<span class="g">X</span></div></body>`;
const tiersHtml = () => `<body style="display:flex;gap:20px;padding:30px;align-items:center;justify-content:center">${Object.keys(TIERS).map((t, i) => tcard(t, ['newbie77', 'surfqueen', 'lunaclicks', 'gamerdad', 'cryptomike'][i], 'martbost', 1)).join('')}</body>`;
const coachHtml = () => `<body style="display:flex;padding:0;background:#fff"><div style="flex:0 0 420px;background:#13214a;padding:40px;display:flex;flex-direction:column;gap:14px;border-left:14px solid #ffc93c"><span style="font-family:Oswald,sans-serif;letter-spacing:3px;color:#ffc93c">COACH</span><b class="wm" style="font-size:52px">@martbost</b><span style="color:#b8c4e0">Coach since November 2026</span>${WM(30)}</div><div style="flex:1;padding:40px;display:flex;gap:14px;align-items:center">${tcard('pro', 'lunaclicks', 'martbost', .8)}${tcard('starter', 'surfqueen', 'martbost', .8)}${tcard('rookie', 'newbie77', 'martbost', .8)}</div></body>`;
async function shot(browser, html, file, w, h, fonts) {
const pg = await browser.newPage({ viewport: { width: w, height: h } });
await pg.setContent('<!doctype html><html><head><meta charset="utf-8">' + (fonts ? FONTS : '') + '<style>' + BASE + '</style></head>' + html + '</html>', { waitUntil: 'load' });
await pg.evaluate(() => document.fonts && document.fonts.ready).catch(() => {});
await pg.screenshot({ path: file, clip: { x: 0, y: 0, width: w, height: h } }); await pg.close();
}
const browser = await chromium.launch();
const ddIdx = process.argv.indexOf('--draftday');
if (ddIdx > 0) {
const base = process.argv[ddIdx + 1], week = process.argv[ddIdx + 2];
const pg = await browser.newPage({ viewport: { width: 1080, height: 1080 } });
await pg.goto(base + '/draftday/' + week, { waitUntil: 'load' }); await pg.waitForSelector('body[data-ready="1"]', { timeout: 10000 }).catch(() => {});
await pg.evaluate(() => document.fonts && document.fonts.ready).catch(() => {});
const out = path.join(ART, 'draftday', 'week-' + week + '.png'); await pg.screenshot({ path: out, clip: { x: 0, y: 0, width: 1080, height: 1080 } });
console.log('draft day card', out); await browser.close(); process.exit(0);
}
await shot(browser, iconHtml(), path.join(ART, 'icon-192.png'), 192, 192, true);
await shot(browser, ogHtml(), path.join(ART, 'og-share.png'), 1200, 630, true);
for (const v of ['navy', 'gold', 'field']) await shot(browser, proofHtml(v), path.join(ART, 'proof', 'fx-proof-' + v + '.png'), 1080, 1080, true);
await shot(browser, tiersHtml(), path.join(ART, 'cards', 'fx-tiers.png'), 1280, 460, true);
await shot(browser, coachHtml(), path.join(ART, 'cards', 'fx-coach-card.png'), 1200, 420, true);
for (const angle of Object.keys(ANG)) for (const [shape, [w, h]] of Object.entries(SHAPES)) await shot(browser, kitHtml(angle, shape, w, h), path.join(ART, 'kit', 'fx-' + angle + '-' + shape + '.png'), w, h, true);
await browser.close();
console.log('art rendered');