@dloizides/poster-render 0.8.0 → 0.9.0

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.mjs CHANGED
@@ -180,7 +180,7 @@ var FONT_SETS = {
180
180
  ["classic" /* Classic */]: { display: '"Oswald", "Arial Narrow", sans-serif', script: '"Sacramento", cursive', body: '"Fredoka", sans-serif' },
181
181
  ["modern" /* Modern */]: { display: '"Bebas Neue", "Arial Narrow", sans-serif', script: '"Great Vibes", cursive', body: '"Montserrat", sans-serif' },
182
182
  ["elegant" /* Elegant */]: { display: '"Playfair Display", serif', script: '"Allura", cursive', body: '"Lato", sans-serif' },
183
- ["kizomba-sample" /* KizombaSample */]: { display: '"Anton", "Oswald", "Arial Narrow", sans-serif', script: '"Dancing Script", "Sacramento", cursive', body: '"Barlow Semi Condensed", "Fredoka", sans-serif' },
183
+ ["kizomba-sample" /* KizombaSample */]: { display: '"Anton", "Oswald", "Arial Narrow", sans-serif', script: '"Style Script", "Dancing Script", cursive', body: '"Barlow Semi Condensed", "Fredoka", sans-serif' },
184
184
  ["coastal" /* Coastal */]: { display: '"Fraunces", Georgia, serif', script: '"Allura", cursive', body: '"Jost", sans-serif' }
185
185
  };
186
186
 
@@ -229,7 +229,8 @@ var rowsSchema = {
229
229
  }
230
230
  },
231
231
  priceLabelScale: num(MIN_LABEL_SCALE, 1),
232
- venue: { type: "object", additionalProperties: false, properties: { body: { type: "boolean" }, bare: { type: "boolean" }, oneLine: { type: "boolean" } } },
232
+ venue: { type: "object", additionalProperties: false, properties: { body: { type: "boolean" }, bare: { type: "boolean" }, oneLine: { type: "boolean" }, pinSize: num(0, MAX_LENGTH), pinGap: num(0, MAX_GAP), pinShift: num(-MAX_GAP, MAX_GAP), centred: { type: "boolean" } } },
233
+ priceGap: num(-MAX_GAP, MAX_GAP),
233
234
  labelScale: num(MIN_LABEL_SCALE, MAX_ROW_SCALE),
234
235
  timeScale: num(MIN_LABEL_SCALE, MAX_ROW_SCALE),
235
236
  timeWeight: num(MIN_WEIGHT, MAX_WEIGHT),
@@ -901,6 +902,7 @@ function scheduleLines(doc, l, row, i) {
901
902
  const tied = r3?.labelScale === void 0 ? label : { ...label, sizeTie: label.sizeTie ?? LABEL_TIE };
902
903
  return [tied, l.time(row.time, SIZE.scheduleTime * (r3?.timeScale ?? 1), `schedule.${i}.time`)];
903
904
  }
905
+ var priceAmount = (doc, line) => doc.rows?.priceGap === void 0 ? line : { ...line, gapAfter: doc.rows.priceGap };
904
906
  function eventGroups(doc, l, u, options) {
905
907
  const b = doc.blocks;
906
908
  const groups = [];
@@ -913,7 +915,7 @@ function eventGroups(doc, l, u, options) {
913
915
  groups.push({ lines, gapAfter: GAP.row * u, keepWithNext: i < schedule2.length - 1, ...options.marks(icons2?.schedule, i, i === lastRow) });
914
916
  });
915
917
  prices.forEach((row, i) => {
916
- const lines = options.compact ? [l.strong(`${row.amount} ${row.label}`, SIZE.priceAmount, `prices.${i}.amount`)] : [l.strong(row.amount, SIZE.priceAmount, `prices.${i}.amount`), l.accent(row.label, SIZE.priceLabel * (doc.rows?.priceLabelScale ?? 1), `prices.${i}.label`)];
918
+ const lines = options.compact ? [l.strong(`${row.amount} ${row.label}`, SIZE.priceAmount, `prices.${i}.amount`)] : [priceAmount(doc, l.strong(row.amount, SIZE.priceAmount, `prices.${i}.amount`)), l.accent(row.label, SIZE.priceLabel * (doc.rows?.priceLabelScale ?? 1), `prices.${i}.label`)];
917
919
  groups.push({ lines, gapAfter: GAP.row * u, keepWithNext: i < prices.length - 1, ...options.marks(icons2?.prices, i, schedule2.length + i === lastRow) });
918
920
  });
919
921
  return groups;
@@ -930,6 +932,9 @@ function flankPriceGroups(doc, p, u) {
930
932
  const l = makers(p, u, styleContext(doc));
931
933
  return (doc.blocks.prices ?? []).map((row, i) => ({ lines: [l.strong(row.amount, SIZE.flankAmount, `prices.${i}.amount`), l.accent(row.label, SIZE.flankLabel, `prices.${i}.label`)], gapAfter: GAP.row * u }));
932
934
  }
935
+ function pinOf(look, u) {
936
+ return { size: look?.pinSize === void 0 ? void 0 : look.pinSize * u, gap: look?.pinGap === void 0 ? void 0 : look.pinGap * u, shift: look?.pinShift === void 0 ? void 0 : look.pinShift * u, centre: look?.centred };
937
+ }
933
938
  function bodyGroups(doc, p, u, options = {}) {
934
939
  const l = makers(p, u, styleContext(doc), doc.rows?.timeWeight);
935
940
  const b = doc.blocks;
@@ -941,7 +946,7 @@ function bodyGroups(doc, p, u, options = {}) {
941
946
  const look = doc.rows?.venue;
942
947
  const line = look?.body === true ? l.bodyVenue : l.venue;
943
948
  const venue = look?.oneLine === true ? [b.venue.join(" ")] : b.venue;
944
- groups.push({ lines: venue.map((v, i) => line(v, size, `venue.${i}`)), gapAfter: GAP.venue * u, rule: dividerOf(doc, p, u) ?? { color: p.accent, height: GAP.rule * u }, ruleBelow: true, icon: { color: p.icon ?? p.accent, glyph: p.background, bare: look?.bare }, keepWithNext });
949
+ groups.push({ lines: venue.map((v, i) => line(v, size, `venue.${i}`)), gapAfter: GAP.venue * u, rule: dividerOf(doc, p, u) ?? { color: p.accent, height: GAP.rule * u }, ruleBelow: true, icon: { color: p.icon ?? p.accent, glyph: p.background, bare: look?.bare, ...pinOf(look, u) }, keepWithNext });
945
950
  }
946
951
  groups.push(...isList ? listGroups(doc, l, u, options.dateScale ?? 1) : eventGroups(doc, l, u, { ...options, marks: rowMarks(doc, p, u) }));
947
952
  if (b.includes) {
@@ -971,7 +976,8 @@ var iconSize = (group, k) => {
971
976
  function groupBox(group, k, colW) {
972
977
  const pad = group.card ? group.card.pad * k : 0;
973
978
  const d = iconSize(group, k);
974
- const iconIndent = d > 0 ? d * (1 + ICON_GAP) : 0;
979
+ const gap = group.icon?.gap === void 0 ? d * ICON_GAP : group.icon.gap * k;
980
+ const iconIndent = d > 0 ? d + gap : 0;
975
981
  return { pad, d, iconIndent, avail: colW - 2 * pad - iconIndent };
976
982
  }
977
983
  function lineSize(line, width, k, avail) {
@@ -1058,7 +1064,7 @@ function placeIcon(group, box, out) {
1058
1064
  return bottom2;
1059
1065
  }
1060
1066
  const textH = bottom2 - top;
1061
- out?.icons.push({ rect: { x, y: top + Math.max(0, (textH - d) / 2), w: d, h: d }, color: group.icon.color, glyph: group.icon.glyph, kind: group.icon.kind, bare: group.icon.bare });
1067
+ out?.icons.push({ rect: { x, y: top + Math.max(0, (textH - d) / 2) + (group.icon.shift ?? 0), w: d, h: d }, color: group.icon.color, glyph: group.icon.glyph, kind: group.icon.kind, bare: group.icon.bare });
1062
1068
  return top + Math.max(textH, d);
1063
1069
  }
1064
1070
  function placeGroup(m, at, out) {
@@ -1072,6 +1078,10 @@ function placeGroup(m, at, out) {
1072
1078
  const { pad, d, iconIndent } = groupBox(group, k, col.w);
1073
1079
  const top = y;
1074
1080
  y += pad;
1081
+ if (group.icon?.centre === true) {
1082
+ const textH = group.lines.reduce((h, line, i) => h + (sizes[i] ?? 0) * LINE_HEIGHT + (i < group.lines.length - 1 ? (line.gapAfter ?? 0) * k : 0), 0);
1083
+ y += Math.max(0, (d - textH) / 2);
1084
+ }
1075
1085
  group.lines.forEach((line, i) => {
1076
1086
  const size = sizes[i] ?? 0;
1077
1087
  const indent = (indented(line) ? line.size * k * BULLET_INDENT : 0) + iconIndent;