@lacspace/logo 1.2.0 → 1.2.2
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/dist/index.cjs +47 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +47 -18
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -370,19 +370,48 @@ function resolveSeed(seed, fallback) {
|
|
|
370
370
|
}
|
|
371
371
|
|
|
372
372
|
// src/text.ts
|
|
373
|
-
var
|
|
374
|
-
|
|
375
|
-
|
|
373
|
+
var ADVANCE = {
|
|
374
|
+
" ": 0.3,
|
|
375
|
+
i: 0.29,
|
|
376
|
+
j: 0.29,
|
|
377
|
+
l: 0.29,
|
|
378
|
+
I: 0.34,
|
|
379
|
+
".": 0.3,
|
|
380
|
+
",": 0.3,
|
|
381
|
+
":": 0.3,
|
|
382
|
+
";": 0.3,
|
|
383
|
+
"'": 0.24,
|
|
384
|
+
"!": 0.32,
|
|
385
|
+
"|": 0.26,
|
|
386
|
+
"(": 0.36,
|
|
387
|
+
")": 0.36,
|
|
388
|
+
"[": 0.36,
|
|
389
|
+
"]": 0.36,
|
|
390
|
+
"{": 0.36,
|
|
391
|
+
"}": 0.36,
|
|
392
|
+
"-": 0.4,
|
|
393
|
+
"/": 0.4,
|
|
394
|
+
f: 0.38,
|
|
395
|
+
t: 0.4,
|
|
396
|
+
r: 0.44,
|
|
397
|
+
J: 0.5,
|
|
398
|
+
m: 0.92,
|
|
399
|
+
w: 0.86,
|
|
400
|
+
M: 0.98,
|
|
401
|
+
W: 0.98,
|
|
402
|
+
"@": 1,
|
|
403
|
+
"%": 0.95
|
|
404
|
+
};
|
|
376
405
|
function estimateTextWidth(text, fontSize, tracking = 0) {
|
|
377
406
|
let em = 0;
|
|
378
407
|
for (const ch of text) {
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
else if (
|
|
382
|
-
else if (
|
|
383
|
-
else em += 0.
|
|
408
|
+
const a = ADVANCE[ch];
|
|
409
|
+
if (a !== void 0) em += a;
|
|
410
|
+
else if (ch >= "A" && ch <= "Z") em += 0.72;
|
|
411
|
+
else if (ch >= "0" && ch <= "9") em += 0.58;
|
|
412
|
+
else em += 0.55;
|
|
384
413
|
}
|
|
385
|
-
return em * fontSize + Math.max(0, text.length - 1) * tracking;
|
|
414
|
+
return em * fontSize * 1.04 + Math.max(0, text.length - 1) * tracking;
|
|
386
415
|
}
|
|
387
416
|
function initials(name, max = 2) {
|
|
388
417
|
const words = name.replace(/[^\p{L}\p{N}\s]/gu, " ").split(/\s+/).filter(Boolean);
|
|
@@ -625,11 +654,12 @@ function fontImport(font) {
|
|
|
625
654
|
function inkColor(spec) {
|
|
626
655
|
return spec.background === "transparent" ? spec.palette.primary : spec.palette.on;
|
|
627
656
|
}
|
|
628
|
-
function wordmarkEl(spec, x, y, fontSize, anchor) {
|
|
657
|
+
function wordmarkEl(spec, x, y, fontSize, anchor, textLen) {
|
|
629
658
|
const isLuxe = spec.font.mood.includes("luxe") || spec.font.mood.includes("elegant");
|
|
630
659
|
const tracking = isLuxe ? fontSize * 0.04 : 0;
|
|
631
660
|
const ls = tracking ? ` letter-spacing="${nn2(tracking)}"` : "";
|
|
632
|
-
|
|
661
|
+
const tl = textLen ? ` textLength="${nn2(textLen)}" lengthAdjust="spacingAndGlyphs"` : "";
|
|
662
|
+
return `<text x="${nn2(x)}" y="${nn2(y)}" font-family="${spec.font.stack}" font-weight="${spec.font.weight}" font-size="${nn2(fontSize)}" fill="${inkColor(spec)}" text-anchor="${anchor}" dominant-baseline="middle"${ls}${tl}>${esc(spec.name)}</text>`;
|
|
633
663
|
}
|
|
634
664
|
function background(spec, w, h, defsId) {
|
|
635
665
|
if (spec.background === "transparent") return "";
|
|
@@ -657,7 +687,7 @@ function compose(spec, mark) {
|
|
|
657
687
|
const w2 = Math.round(tw2 + pad * 2);
|
|
658
688
|
const h2 = Math.round(fontSize2 * 1.5);
|
|
659
689
|
const tick = `<rect x="${pad - Math.round(spec.size * 0.03)}" y="${Math.round(h2 / 2 - fontSize2 * 0.36)}" width="${Math.round(spec.size * 0.014)}" height="${Math.round(fontSize2 * 0.72)}" rx="2" fill="${spec.palette.primary}"/>`;
|
|
660
|
-
const body2 = tick + wordmarkEl(spec, pad, h2 / 2, fontSize2, "start");
|
|
690
|
+
const body2 = tick + wordmarkEl(spec, pad, h2 / 2, fontSize2, "start", tw2);
|
|
661
691
|
return { svg: wrapSvg(spec, w2, h2, defs, body2), width: w2, height: h2 };
|
|
662
692
|
}
|
|
663
693
|
if (spec.layout === "icon-top" || spec.layout === "stacked") {
|
|
@@ -668,7 +698,7 @@ function compose(spec, mark) {
|
|
|
668
698
|
const w2 = Math.round(Math.max(markSize2, tw2) + pad * 2);
|
|
669
699
|
const h2 = Math.round(markSize2 + gap2 + fontSize2 * 1.3 + pad);
|
|
670
700
|
const markX = (w2 - markSize2) / 2;
|
|
671
|
-
const body2 = `<g transform="translate(${nn2(markX)} ${pad})">${mark.svg}</g>` + wordmarkEl(spec, w2 / 2, pad + markSize2 + gap2 + fontSize2 * 0.5, fontSize2, "middle");
|
|
701
|
+
const body2 = `<g transform="translate(${nn2(markX)} ${pad})">${mark.svg}</g>` + wordmarkEl(spec, w2 / 2, pad + markSize2 + gap2 + fontSize2 * 0.5, fontSize2, "middle", tw2);
|
|
672
702
|
return { svg: wrapSvg(spec, w2, h2, defs, body2), width: w2, height: h2 };
|
|
673
703
|
}
|
|
674
704
|
const markSize = spec.size;
|
|
@@ -677,7 +707,7 @@ function compose(spec, mark) {
|
|
|
677
707
|
const tw = estimateTextWidth(spec.name, fontSize, spec.font.mood.includes("luxe") ? fontSize * 0.04 : 0);
|
|
678
708
|
const w = Math.round(markSize + gap + tw + pad * 2);
|
|
679
709
|
const h = Math.round(markSize + pad * 2);
|
|
680
|
-
const body = `<g transform="translate(${pad} ${pad})">${mark.svg}</g>` + wordmarkEl(spec, pad + markSize + gap, h / 2, fontSize, "start");
|
|
710
|
+
const body = `<g transform="translate(${pad} ${pad})">${mark.svg}</g>` + wordmarkEl(spec, pad + markSize + gap, h / 2, fontSize, "start", tw);
|
|
681
711
|
return { svg: wrapSvg(spec, w, h, defs, body), width: w, height: h };
|
|
682
712
|
}
|
|
683
713
|
|
|
@@ -866,12 +896,11 @@ function animateLogo(input, opts = {}) {
|
|
|
866
896
|
const dur = opts.duration ?? 1500;
|
|
867
897
|
const iter = opts.loop ? "infinite" : "1";
|
|
868
898
|
const shimmer = opts.shimmer !== false;
|
|
869
|
-
const style = `<style>@keyframes lac-in{0%{opacity:0;transform:scale(.9)}
|
|
899
|
+
const style = `<style>@keyframes lac-in{0%{opacity:0;transform:translateY(${Math.round(h * 0.03)}px) scale(.9)}55%{opacity:1}100%{opacity:1;transform:none}}@keyframes lac-shim{0%{transform:translateX(${(-w * 0.55).toFixed(0)}px) skewX(-14deg)}50%,100%{transform:translateX(${(w * 1.15).toFixed(0)}px) skewX(-14deg)}}.lac-in{transform-box:fill-box;transform-origin:center;animation:lac-in ${dur}ms cubic-bezier(.2,.8,.2,1) ${iter} both}.lac-shim{transform-box:fill-box;transform-origin:center;opacity:.9;mix-blend-mode:overlay;animation:lac-shim ${Math.round(dur * 1.2)}ms ease ${Math.round(dur * 0.35)}ms ${iter} both}@media(prefers-reduced-motion:reduce){.lac-in{animation:none;opacity:1;transform:none}.lac-shim{display:none}}</style>`;
|
|
870
900
|
const shimDefs = shimmer ? `<linearGradient id="lac-shim-g" x1="0" y1="0" x2="1" y2="0"><stop offset="0" stop-color="#fff" stop-opacity="0"/><stop offset=".5" stop-color="#fff" stop-opacity=".55"/><stop offset="1" stop-color="#fff" stop-opacity="0"/></linearGradient>` : "";
|
|
871
901
|
const shimRect = shimmer ? `<rect class="lac-shim" x="0" y="0" width="${(w * 0.4).toFixed(0)}" height="${h}" fill="url(#lac-shim-g)"/>` : "";
|
|
872
|
-
let svg = result.svg.replace(
|
|
873
|
-
svg = svg.replace(
|
|
874
|
-
svg = svg.replace(/<\/svg>\s*$/, `${shimRect}</svg>`);
|
|
902
|
+
let svg = result.svg.replace(/(<svg\b[^>]*>)/, `$1${style}<defs>${shimDefs}</defs><g class="lac-in">`);
|
|
903
|
+
svg = svg.replace(/<\/svg>\s*$/, `</g>${shimRect}</svg>`);
|
|
875
904
|
return svg;
|
|
876
905
|
}
|
|
877
906
|
|