Instructions to use botezx/flagtldr with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Grok
How to use botezx/flagtldr with Grok:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
Download scripts/e2e/icon-render.mjs from botezx/flagtldr: direct link, hf CLI and curl.
- Browser
- Download file 4.47 kB
-
https://huggingface.co/botezx/flagtldr/resolve/main/scripts/e2e/icon-render.mjs
- Command line
-
hf download hf://botezx/flagtldr/scripts/e2e/icon-render.mjs
-
curl -L -o icon-render.mjs https://huggingface.co/botezx/flagtldr/resolve/main/scripts/e2e/icon-render.mjs
4.47 kB
| // Unreleased: render the FlagTLDR icon SVGs (docs/icon/) to PNGs with headless Chrome – no network, no extension. | |
| // node icon-render.mjs <chrome> [chosen] chosen = a-szczyt | b-lisc | c-kropla (installs it when given) | |
| // Outputs: docs/icon/variants/<v>.png (256 preview), docs/icon/comparison.png (16/32/48/128 on light + dark), | |
| // and with [chosen]: docs/icon/flagtldr.svg, extension/icons/icon{16,32,48,128}.png, | |
| // docs/store/assets/{icon-128,logo-300,promo-440x280}.png | |
| // (16/32/48 full bleed for the toolbar; 128 = 96 px artwork + 16 px transparent padding, Chrome Web Store guideline) | |
| import puppeteer from "puppeteer-core"; | |
| import { renderStoreIcons } from "./icon-assets.mjs"; | |
| import fs from "node:fs"; | |
| import path from "node:path"; | |
| import { fileURLToPath } from "node:url"; | |
| const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../.."); | |
| const DIR = path.join(ROOT, "docs", "icon"), VAR = path.join(DIR, "variants"), ICONS = path.join(ROOT, "extension", "icons"); | |
| const CHROME = process.env.CHROME || process.argv[2], CHOSEN = process.argv[3]; | |
| const variants = fs.readdirSync(VAR).filter((f) => f.endsWith(".svg")).sort().map((f) => f.replace(/\.svg$/, "")); | |
| const uri = (svg) => "data:image/svg+xml;base64," + Buffer.from(svg).toString("base64"); | |
| const svgOf = (v) => fs.readFileSync(path.join(VAR, v + ".svg"), "utf8"); | |
| const browser = await puppeteer.launch({ executablePath: CHROME, headless: true, args: ["--no-sandbox", "--force-color-profile=srgb"] }); | |
| try { | |
| const p = await browser.newPage(); | |
| async function png(file, html, w, h) { | |
| await p.setViewport({ width: w, height: h, deviceScaleFactor: 1 }); | |
| await p.setContent(`<html><body style="margin:0;background:transparent">${html}</body></html>`); | |
| await p.evaluate(() => Promise.all([...document.images].map((i) => i.decode()))); | |
| await p.screenshot({ path: file, omitBackground: true, clip: { x: 0, y: 0, width: w, height: h } }); | |
| console.log("[icon]", path.relative(ROOT, file)); | |
| } | |
| const img = (v, s, pad = 0) => `<img src="${uri(svgOf(v))}" width="${s - 2 * pad}" height="${s - 2 * pad}" style="display:block;margin:${pad}px">`; | |
| for (const v of variants) await png(path.join(VAR, v + ".png"), img(v, 256), 256, 256); | |
| const SIZES = [16, 32, 48, 128]; | |
| const names = { "a-szczyt": "A · Szczyt (góra o świcie)", "b-lisc": "B · Liść", "c-kropla": "C · Kropla" }; | |
| const panel = (v, bg, fg) => `<div style="display:flex;align-items:center;gap:22px;background:${bg};color:${fg};padding:16px 22px;border-radius:14px"> | |
| ${SIZES.map((s) => `<div style="display:flex;flex-direction:column;align-items:center;gap:6px;width:${Math.max(s, 36)}px">${img(v, s)}<span style="font:11px system-ui;opacity:.7">${s}px</span></div>`).join("")}</div>`; | |
| const sheet = `<div style="width:1000px;padding:28px;background:#f1f3f5;font-family:system-ui;box-sizing:border-box"> | |
| <div style="font:700 22px system-ui;margin-bottom:4px">FlagTLDR – warianty ikony</div> | |
| <div style="font:13px system-ui;color:#555;margin-bottom:18px">16 / 32 / 48 / 128 px w rzeczywistej wielkości (bez skalowania) · jasne i ciemne tło (np. pasek narzędzi Chrome)</div> | |
| ${variants.map((v) => `<div style="display:flex;align-items:center;gap:14px;margin-bottom:14px"> | |
| <div style="width:170px;font:600 15px system-ui;color:#0f1419">${names[v] || v}${v === CHOSEN ? "<br><span style='color:#047857'>✓ wybrany</span>" : ""}</div> | |
| ${panel(v, "#ffffff", "#0f1419")}${panel(v, "#202124", "#e8eaed")}</div>`).join("")} | |
| </div>`; | |
| await p.setViewport({ width: 1000, height: 100 }); | |
| await p.setContent(`<html><body style="margin:0">${sheet}</body></html>`); | |
| await p.evaluate(() => Promise.all([...document.images].map((i) => i.decode()))); | |
| const h = await p.evaluate(() => document.body.firstElementChild.getBoundingClientRect().height); | |
| await p.setViewport({ width: 1000, height: Math.ceil(h) }); | |
| await p.screenshot({ path: path.join(DIR, "comparison.png") }); console.log("[icon] docs/icon/comparison.png"); | |
| if (CHOSEN) { | |
| fs.copyFileSync(path.join(VAR, CHOSEN + ".svg"), path.join(DIR, "flagtldr.svg")); | |
| for (const s of [16, 32, 48]) await png(path.join(ICONS, `icon${s}.png`), img(CHOSEN, s), s, s); | |
| await png(path.join(ICONS, "icon128.png"), img(CHOSEN, 128, 16), 128, 128); | |
| await renderStoreIcons(browser, path.join(ROOT, "docs", "store", "assets")); | |
| } | |
| } finally { await browser.close(); } | |