@dloizides/poster-render 0.12.0 → 0.13.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/CHANGELOG.md +4 -0
- package/dist/index.d.mts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +17 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.13.0
|
|
4
|
+
|
|
5
|
+
- FLIER-2 "Bullets on/off and line spacing": `FlierDoc.bullets` (default true; false drops the includes bullet dot and its indent), `LineStyle.spaceAbove` / `spaceBelow` (em of the line size, 0-2) added above / below a line, and a footer holding line breaks sets one footer line per text line. Docs without the new fields render pixel-identical (45 snapshots unchanged).
|
|
6
|
+
|
|
3
7
|
## 0.6.0
|
|
4
8
|
|
|
5
9
|
- FLIER-2 "Flier Studio follow-ups" D30 (sample parity, gap table `apps/flier-studio/docs/design/FLIER-2-sample-parity/gap.md`), all optional:
|
package/dist/index.d.mts
CHANGED
|
@@ -188,10 +188,11 @@ interface FlierDoc {
|
|
|
188
188
|
lineTies?: LineTie[];
|
|
189
189
|
rows?: RowTheme;
|
|
190
190
|
sectionOrder?: BodySection[];
|
|
191
|
+
bullets?: boolean;
|
|
191
192
|
}
|
|
192
193
|
/** A text line path such as "title", "venue.1", "schedule.0.time" or "items.2.date" (see LINE_KEY_PATTERN). */
|
|
193
194
|
type LineKey = string;
|
|
194
|
-
/** Optional per-line overrides of the theme; an absent field keeps the theme value. letterSpacing
|
|
195
|
+
/** Optional per-line overrides of the theme; an absent field keeps the theme value. letterSpacing, spaceAbove and spaceBelow are in em; widthScale widens or narrows the room the line may fill. */
|
|
195
196
|
interface LineStyle {
|
|
196
197
|
font?: string;
|
|
197
198
|
sizeScale?: number;
|
|
@@ -201,6 +202,8 @@ interface LineStyle {
|
|
|
201
202
|
italic?: boolean;
|
|
202
203
|
letterSpacing?: number;
|
|
203
204
|
align?: LineAlign;
|
|
205
|
+
spaceAbove?: number;
|
|
206
|
+
spaceBelow?: number;
|
|
204
207
|
}
|
|
205
208
|
/** Two lines drawn at one width (width) or one font size (size). */
|
|
206
209
|
interface LineTie {
|
package/dist/index.d.ts
CHANGED
|
@@ -188,10 +188,11 @@ interface FlierDoc {
|
|
|
188
188
|
lineTies?: LineTie[];
|
|
189
189
|
rows?: RowTheme;
|
|
190
190
|
sectionOrder?: BodySection[];
|
|
191
|
+
bullets?: boolean;
|
|
191
192
|
}
|
|
192
193
|
/** A text line path such as "title", "venue.1", "schedule.0.time" or "items.2.date" (see LINE_KEY_PATTERN). */
|
|
193
194
|
type LineKey = string;
|
|
194
|
-
/** Optional per-line overrides of the theme; an absent field keeps the theme value. letterSpacing
|
|
195
|
+
/** Optional per-line overrides of the theme; an absent field keeps the theme value. letterSpacing, spaceAbove and spaceBelow are in em; widthScale widens or narrows the room the line may fill. */
|
|
195
196
|
interface LineStyle {
|
|
196
197
|
font?: string;
|
|
197
198
|
sizeScale?: number;
|
|
@@ -201,6 +202,8 @@ interface LineStyle {
|
|
|
201
202
|
italic?: boolean;
|
|
202
203
|
letterSpacing?: number;
|
|
203
204
|
align?: LineAlign;
|
|
205
|
+
spaceAbove?: number;
|
|
206
|
+
spaceBelow?: number;
|
|
204
207
|
}
|
|
205
208
|
/** Two lines drawn at one width (width) or one font size (size). */
|
|
206
209
|
interface LineTie {
|
package/dist/index.js
CHANGED
|
@@ -102,6 +102,7 @@ var MAX_FONT = 40;
|
|
|
102
102
|
var MIN_SPACING = -0.1;
|
|
103
103
|
var MAX_SPACING = 0.5;
|
|
104
104
|
var MAX_TIES = 12;
|
|
105
|
+
var MAX_SPACE = 2;
|
|
105
106
|
var WEIGHTS = [100, 200, 300, 400, 500, 600, 700, 800, 900];
|
|
106
107
|
var lineKey = { type: "string", pattern: LINE_KEY_PATTERN };
|
|
107
108
|
var lineStyle = {
|
|
@@ -115,7 +116,9 @@ var lineStyle = {
|
|
|
115
116
|
weight: { type: "integer", enum: WEIGHTS },
|
|
116
117
|
italic: { type: "boolean" },
|
|
117
118
|
letterSpacing: { type: "number", minimum: MIN_SPACING, maximum: MAX_SPACING },
|
|
118
|
-
align: { type: "string", enum: Object.values(LineAlign) }
|
|
119
|
+
align: { type: "string", enum: Object.values(LineAlign) },
|
|
120
|
+
spaceAbove: { type: "number", minimum: 0, maximum: MAX_SPACE },
|
|
121
|
+
spaceBelow: { type: "number", minimum: 0, maximum: MAX_SPACE }
|
|
119
122
|
}
|
|
120
123
|
};
|
|
121
124
|
var lineStylesSchema = { type: "object", propertyNames: lineKey, additionalProperties: lineStyle };
|
|
@@ -358,6 +361,7 @@ var flierDocSchema = {
|
|
|
358
361
|
lineStyles: lineStylesSchema,
|
|
359
362
|
lineTies: lineTiesSchema,
|
|
360
363
|
rows: rowsSchema,
|
|
364
|
+
bullets: { type: "boolean" },
|
|
361
365
|
sectionOrder: { type: "array", maxItems: MAX_SECTIONS, items: { type: "string", enum: Object.values(BodySection) } },
|
|
362
366
|
items: {
|
|
363
367
|
type: "array",
|
|
@@ -808,10 +812,11 @@ function styled(line, key, sc) {
|
|
|
808
812
|
if (style === void 0 && widthTie === void 0 && sizeTie === void 0) {
|
|
809
813
|
return { ...line, key };
|
|
810
814
|
}
|
|
815
|
+
const size = line.size * (style?.sizeScale ?? 1);
|
|
811
816
|
return {
|
|
812
817
|
...line,
|
|
813
818
|
key,
|
|
814
|
-
size
|
|
819
|
+
size,
|
|
815
820
|
color: style?.color ?? line.color,
|
|
816
821
|
weight: style?.weight ?? line.weight,
|
|
817
822
|
family: style?.font,
|
|
@@ -820,6 +825,8 @@ function styled(line, key, sc) {
|
|
|
820
825
|
widthScale: style?.widthScale,
|
|
821
826
|
fixedSize: style?.sizeScale === void 0 ? void 0 : true,
|
|
822
827
|
align: style?.align,
|
|
828
|
+
spaceAbove: style?.spaceAbove === void 0 ? void 0 : style.spaceAbove * size,
|
|
829
|
+
spaceBelow: style?.spaceBelow === void 0 ? void 0 : style.spaceBelow * size,
|
|
823
830
|
widthTie,
|
|
824
831
|
sizeTie
|
|
825
832
|
};
|
|
@@ -867,14 +874,14 @@ var GAP = {
|
|
|
867
874
|
rule: 8,
|
|
868
875
|
divider: 24
|
|
869
876
|
};
|
|
870
|
-
var makers = (p, u, sc, timeWeight = SEMI) => ({
|
|
877
|
+
var makers = (p, u, sc, timeWeight = SEMI, bullets = true) => ({
|
|
871
878
|
display: (text2, size, key) => styled({ text: text2, role: "display", weight: BOLD, size: size * u, color: p.title }, key, sc),
|
|
872
879
|
venue: (text2, size, key) => styled({ text: text2, role: "display", weight: MEDIUM, size: size * u, color: p.ink }, key, sc),
|
|
873
880
|
bodyVenue: (text2, size, key) => styled({ text: text2, role: "body", weight: BOLD, size: size * u, color: p.ink }, key, sc),
|
|
874
881
|
script: (text2, size, key) => styled({ text: text2, role: "script", weight: SCRIPT, size: size * u, color: p.script ?? p.accent }, key, sc),
|
|
875
882
|
strong: (text2, size, key) => styled({ text: text2, role: "body", weight: BOLD, size: size * u, color: p.ink }, key, sc),
|
|
876
883
|
accent: (text2, size, key) => styled({ text: text2, role: "body", weight: SEMI, size: size * u, color: p.accent }, key, sc),
|
|
877
|
-
item: (text2, size, key) => styled({ text: text2, role: "body", weight: SEMI, size: size * u, color: p.ink, bullet: p.accent }, key, sc),
|
|
884
|
+
item: (text2, size, key) => styled({ text: text2, role: "body", weight: SEMI, size: size * u, color: p.ink, bullet: bullets ? p.accent : void 0 }, key, sc),
|
|
878
885
|
soft: (text2, size, key) => styled({ text: text2, role: "body", weight: MEDIUM, size: size * u, color: p.soft }, key, sc),
|
|
879
886
|
time: (text2, size, key) => styled({ text: text2, role: "body", weight: timeWeight, size: size * u, color: p.accent }, key, sc)
|
|
880
887
|
});
|
|
@@ -987,13 +994,14 @@ function joined(order, parts) {
|
|
|
987
994
|
});
|
|
988
995
|
}
|
|
989
996
|
function bodyGroups(doc, p, u, options = {}) {
|
|
990
|
-
const l = makers(p, u, styleContext(doc), doc.rows?.timeWeight);
|
|
997
|
+
const l = makers(p, u, styleContext(doc), doc.rows?.timeWeight, doc.bullets !== false);
|
|
991
998
|
const b = doc.blocks;
|
|
992
999
|
const isList = doc.layout === "list" /* List */;
|
|
993
1000
|
const [rows, prices] = isList ? listGroups(doc, l, u, options.dateScale ?? 1) : eventGroups(doc, l, u, { ...options, marks: rowMarks(doc, p, u) });
|
|
994
1001
|
const includeLines = b.includes ? [l.accent(b.includes.heading, SIZE.small, "includes.heading"), ...b.includes.items.map((item, i) => l.item(item, SIZE.small, `includes.items.${i}`))] : [];
|
|
995
1002
|
const includes = includeLines.length > 0 ? [{ lines: includeLines.flatMap((line) => wrapped(line, options.wrap)), gapAfter: GAP.includes * u, uniform: true }] : [];
|
|
996
|
-
const
|
|
1003
|
+
const footerLines = (b.footer ?? "").split("\n").filter((text2) => text2.trim() !== "");
|
|
1004
|
+
const footer = footerLines.length > 0 ? [{ lines: footerLines.flatMap((text2) => wrapped(l.soft(text2, SIZE.small, "footer"), options.wrap)), gapAfter: 0 }] : [];
|
|
997
1005
|
const parts = {
|
|
998
1006
|
["venue" /* Venue */]: venueGroups(doc, p, u, l),
|
|
999
1007
|
["schedule" /* Schedule */]: isList ? [] : rows,
|
|
@@ -1155,11 +1163,12 @@ function placeGroup(m, at, out) {
|
|
|
1155
1163
|
const top = y;
|
|
1156
1164
|
y += pad;
|
|
1157
1165
|
if (group.icon?.centre === true) {
|
|
1158
|
-
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);
|
|
1166
|
+
const textH = group.lines.reduce((h, line, i) => h + (sizes[i] ?? 0) * LINE_HEIGHT + ((line.spaceAbove ?? 0) + (line.spaceBelow ?? 0)) * k + (i < group.lines.length - 1 ? (line.gapAfter ?? 0) * k : 0), 0);
|
|
1159
1167
|
y += Math.max(0, (d - textH) / 2);
|
|
1160
1168
|
}
|
|
1161
1169
|
group.lines.forEach((line, i) => {
|
|
1162
1170
|
const size = sizes[i] ?? 0;
|
|
1171
|
+
y += (line.spaceAbove ?? 0) * k;
|
|
1163
1172
|
const indent = (indented(line) ? line.size * k * BULLET_INDENT : 0) + iconIndent;
|
|
1164
1173
|
const w = (m.widths[i] ?? 0) * size / line.size;
|
|
1165
1174
|
const x = lineX(line, { col, pad, indent, w });
|
|
@@ -1168,7 +1177,7 @@ function placeGroup(m, at, out) {
|
|
|
1168
1177
|
if (line.bullet && out) {
|
|
1169
1178
|
out.bullets.push({ x: col.x + pad + size * BULLET_RADIUS, y: y + size * LINE_HEIGHT / 2, r: size * BULLET_RADIUS, color: line.bullet });
|
|
1170
1179
|
}
|
|
1171
|
-
y += size * LINE_HEIGHT + (line.gapAfter ?? 0) * k;
|
|
1180
|
+
y += size * LINE_HEIGHT + ((line.gapAfter ?? 0) + (line.spaceBelow ?? 0)) * k;
|
|
1172
1181
|
});
|
|
1173
1182
|
y = placeIcon(group, { d, x: col.x + pad, top: top + pad, bottom: y }, out);
|
|
1174
1183
|
y += pad;
|