@dloizides/logo-kit 0.1.1 → 0.1.3

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.d.ts CHANGED
@@ -148,6 +148,7 @@ interface MarkSvgOptions {
148
148
  overlay?: string;
149
149
  drawLayers?: ReadonlySet<string>;
150
150
  colourOverride?: string;
151
+ microWrap?: boolean;
151
152
  }
152
153
  /** Returns a standalone SVG of the mark in one mode, with optional motion style and overlay. */
153
154
  declare function markSvg(mark: Mark, palette: Palette, mode: Mode, opts: MarkSvgOptions): string;
package/dist/index.js CHANGED
@@ -363,11 +363,14 @@ function layerSvg(layer, index, colours, mode, opts = {}) {
363
363
  const path5 = (item, head2) => `<path${head2} ${paintAttrs(item, colours, opts.colourOverride)}${rule}${len} d="${layer.d}"/>`;
364
364
  const head = ` id="mark-${layer.name}" class="l${index}"`;
365
365
  const body = items.length === 1 && items[0] ? path5(items[0], head) : `<g${head}>${items.map((item) => path5(item, "")).join("")}</g>`;
366
- return layer.transform !== void 0 ? `<g transform="${layer.transform}">${body}</g>` : body;
366
+ const wrapped = opts.microWrap === true ? `<g class="lkm${index}">${body}</g>` : body;
367
+ return layer.transform !== void 0 ? `<g transform="${layer.transform}">${wrapped}</g>` : wrapped;
367
368
  }
368
369
  function markBody(mark, palette, mode, opts = {}) {
369
370
  const colours = mode === "dark" /* Dark */ ? palette.dark : palette.light;
370
- return `<g id="mark">${mark.layers.map((layer, i) => layerSvg(layer, i, colours, mode, opts)).join("")}</g>`;
371
+ const layers = mark.layers.map((layer, i) => layerSvg(layer, i, colours, mode, opts)).join("");
372
+ const body = opts.microWrap === true ? '<g class="lkmm">'.concat(layers, "</g>") : layers;
373
+ return `<g id="mark">${body}</g>`;
371
374
  }
372
375
  function markSvg(mark, palette, mode, opts) {
373
376
  const size = opts.size ?? DEFAULT_SIZE;
@@ -1172,19 +1175,22 @@ function presetFrames(beat, ctx) {
1172
1175
 
1173
1176
  // src/motion/motionCss.ts
1174
1177
  var REDUCED_MOTION = "@media (prefers-reduced-motion:reduce){*{animation:none!important}}";
1178
+ var sweepClass = (index, hover) => `${hover ? "lkms" : "lks"}${index}`;
1175
1179
  var selectorOf = (target, index, hover, sweep) => {
1176
- const root = hover ? "svg:hover" : "svg";
1180
+ if (sweep) {
1181
+ return `${hover ? "svg:hover" : "svg"} .${sweepClass(index, hover)}`;
1182
+ }
1177
1183
  if (target === MARK_TARGET) {
1178
- return `${root} #mark`;
1184
+ return hover ? "svg:hover .lkmm" : "svg #mark";
1179
1185
  }
1180
- return `${root} .${sweep ? "lks" : "l"}${index}`;
1186
+ return hover ? `svg:hover .lkm${index}` : `svg .l${index}`;
1181
1187
  };
1182
- function sweepOverlay(mark, index, beat, colour) {
1188
+ function sweepOverlay(mark, index, beat, colour, hover) {
1183
1189
  const layer = mark.layers[index];
1184
1190
  if (!layer) {
1185
1191
  return "";
1186
1192
  }
1187
- const attrs = [`class="lks${index}"`, `d="${layer.d}"`, 'fill="none"', `stroke="${colour}"`, `stroke-width="${beat.width ?? 2}"`, 'stroke-linecap="round"', 'pathLength="1"', `stroke-dasharray="${beat.share ?? 0.12} 1"`, 'opacity="0"'];
1193
+ const attrs = [`class="${sweepClass(index, hover)}"`, `d="${layer.d}"`, 'fill="none"', `stroke="${colour}"`, `stroke-width="${beat.width ?? 2}"`, 'stroke-linecap="round"', 'pathLength="1"', `stroke-dasharray="${beat.share ?? 0.12} 1"`, 'opacity="0"'];
1188
1194
  if (layer.transform !== void 0) {
1189
1195
  attrs.push(`transform="${layer.transform}"`);
1190
1196
  }
@@ -1221,7 +1227,7 @@ function addSlot(ctx, beat, b, slot) {
1221
1227
  ctx.drawLayers.add(slot.target);
1222
1228
  }
1223
1229
  if (sweep) {
1224
- ctx.overlay.push(sweepOverlay(ctx.mark, index, beat, ctx.colour(beat.colour)));
1230
+ ctx.overlay.push(sweepOverlay(ctx.mark, index, beat, ctx.colour(beat.colour), ctx.hover));
1225
1231
  }
1226
1232
  }
1227
1233
  function motionCss(mark, beats, palette, mode, hover) {
@@ -1239,7 +1245,7 @@ function motionCss(mark, beats, palette, mode, hover) {
1239
1245
  overlay: []
1240
1246
  };
1241
1247
  beats.forEach((beat, b) => schedule(beat, ctx.names).forEach((slot) => addSlot(ctx, beat, b, slot)));
1242
- return { style: render(ctx.rules, ctx.keyframes), overlay: ctx.overlay.join(""), drawLayers: ctx.drawLayers };
1248
+ return { style: render(ctx.rules, ctx.keyframes), overlay: ctx.overlay.join(""), drawLayers: ctx.drawLayers, microWrap: hover };
1243
1249
  }
1244
1250
 
1245
1251
  // src/motion/motionSvg.ts
@@ -1249,14 +1255,14 @@ function introSvg(mark, palette, mode, beats, opts) {
1249
1255
  }
1250
1256
  function microSvg(mark, palette, mode, beats, opts) {
1251
1257
  const m = motionCss(mark, beats, palette, mode, true);
1252
- return markSvg(mark, palette, mode, { ...opts, style: m.style, overlay: m.overlay, drawLayers: m.drawLayers });
1258
+ return markSvg(mark, palette, mode, { ...opts, style: m.style, overlay: m.overlay, drawLayers: m.drawLayers, microWrap: m.microWrap });
1253
1259
  }
1254
1260
  function animatedSvg(mark, palette, mode, motion, opts) {
1255
1261
  const intro = motionCss(mark, motion.intro, palette, mode, false);
1256
1262
  const micro = motionCss(mark, motion.micro, palette, mode, true);
1257
1263
  const style = `${intro.style.replace(REDUCED_MOTION, "")}${micro.style}`;
1258
1264
  const drawLayers = /* @__PURE__ */ new Set([...intro.drawLayers, ...micro.drawLayers]);
1259
- return markSvg(mark, palette, mode, { ...opts, style, overlay: intro.overlay + micro.overlay, drawLayers });
1265
+ return markSvg(mark, palette, mode, { ...opts, style, overlay: intro.overlay + micro.overlay, drawLayers, microWrap: true });
1260
1266
  }
1261
1267
 
1262
1268
  // src/motion/parseTiming.ts