Skip to content

Commit 961c5bb

Browse files
committed
Caption: add font weight, drop layout option
Adds caption font_weight (light/normal/medium/semibold/bold) and removes the layout option; captions are always stacked (one field per line).
1 parent 69a6cfd commit 961c5bb

2 files changed

Lines changed: 2 additions & 32 deletions

File tree

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,6 @@ caption: # overlay the photo's date and/or location
291291
date_format: medium # medium | full | month_year | year | numeric
292292
# | weekday | relative, or a custom token string
293293
# (YYYY, MMMM, MMM, MM, M, DD, D, dddd, ddd)
294-
layout: stacked # date+location: stacked (one per line) | inline
295-
# (same line). No effect with a single field.
296294
per_image: true # caption each half of a portrait pair separately
297295
color: '#ffffff' # any CSS color
298296
font_size: 14px # any CSS size

custom_components/album_slideshow/www/album-slideshow-card.js

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ const CAPTION_POSITIONS = new Set([
6161
"bottom-center",
6262
"bottom-right",
6363
]);
64-
const CAPTION_LAYOUTS = new Set(["stacked", "inline"]);
6564
// Named font weights surfaced in the editor, mapped to their CSS values.
6665
const CAPTION_WEIGHT_MAP = {
6766
light: 300,
@@ -203,8 +202,6 @@ function createAlbumSlideshowCardClass(Base) {
203202
if (show.length === 0) return null;
204203
let position = String(raw.position || "bottom-left").toLowerCase();
205204
if (!CAPTION_POSITIONS.has(position)) position = "bottom-left";
206-
let layout = String(raw.layout || "stacked").toLowerCase();
207-
if (!CAPTION_LAYOUTS.has(layout)) layout = "stacked";
208205
const color =
209206
typeof raw.color === "string" && raw.color.trim()
210207
? raw.color.trim()
@@ -218,7 +215,6 @@ function createAlbumSlideshowCardClass(Base) {
218215
return {
219216
show,
220217
position,
221-
layout,
222218
per_image: raw.per_image !== false,
223219
date_format: raw.date_format != null ? String(raw.date_format) : "medium",
224220
color,
@@ -345,17 +341,11 @@ function createAlbumSlideshowCardClass(Base) {
345341
}
346342
.cap-box {
347343
display: flex;
344+
flex-direction: column;
348345
max-width: 92%;
349346
line-height: 1.25;
350347
font-family: var(--paper-font-body1_-_font-family, sans-serif);
351348
}
352-
.cap-box.stacked { flex-direction: column; }
353-
.cap-box.inline {
354-
flex-direction: row;
355-
flex-wrap: wrap;
356-
align-items: baseline;
357-
gap: 0.15em 0.6em;
358-
}
359349
.cap-line { font-weight: inherit; }
360350
.cap-box.cap-shadow {
361351
text-shadow:
@@ -709,7 +699,7 @@ function createAlbumSlideshowCardClass(Base) {
709699
region.style.alignItems = align[v] || "flex-end";
710700

711701
const box = document.createElement("div");
712-
box.className = `cap-box ${cap.layout}`;
702+
box.className = "cap-box";
713703
if (cap.shadow) box.classList.add("cap-shadow");
714704
box.style.color = cap.color;
715705
box.style.fontSize = cap.font_size;
@@ -914,11 +904,6 @@ const CAPTION_POSITION_OPTIONS = [
914904
{ value: "bottom-right", label: "Bottom right" },
915905
];
916906

917-
const CAPTION_LAYOUT_OPTIONS = [
918-
{ value: "stacked", label: "Stacked (one per line)" },
919-
{ value: "inline", label: "Inline (same line)" },
920-
];
921-
922907
const CAPTION_WEIGHT_OPTIONS = [
923908
{ value: "light", label: "Light" },
924909
{ value: "normal", label: "Normal" },
@@ -951,7 +936,6 @@ const DEFAULTS = {
951936
const CAPTION_DEFAULTS = {
952937
show: ["date", "location"],
953938
position: "bottom-left",
954-
layout: "stacked",
955939
per_image: true,
956940
date_format: "medium",
957941
color: "#ffffff",
@@ -1309,12 +1293,6 @@ function createAlbumSlideshowCardEditorClass(Base) {
13091293
},
13101294
},
13111295
},
1312-
{
1313-
name: "caption_layout",
1314-
selector: {
1315-
select: { mode: "dropdown", options: CAPTION_LAYOUT_OPTIONS },
1316-
},
1317-
},
13181296
{ name: "caption_per_image", selector: { boolean: {} } },
13191297
{
13201298
type: "grid",
@@ -1380,7 +1358,6 @@ function createAlbumSlideshowCardEditorClass(Base) {
13801358
caption_enabled: enabled,
13811359
caption_show: show,
13821360
caption_position: c.position || CAPTION_DEFAULTS.position,
1383-
caption_layout: c.layout || CAPTION_DEFAULTS.layout,
13841361
caption_per_image: c.per_image !== false,
13851362
caption_date_format: c.date_format || CAPTION_DEFAULTS.date_format,
13861363
caption_color: c.color || CAPTION_DEFAULTS.color,
@@ -1433,7 +1410,6 @@ function createAlbumSlideshowCardEditorClass(Base) {
14331410
caption_enabled: "Show caption overlay",
14341411
caption_show: "Show",
14351412
caption_position: "Position",
1436-
caption_layout: "Layout",
14371413
caption_per_image: "Per-image captions on pairs",
14381414
caption_date_format: "Date format",
14391415
caption_color: "Text color",
@@ -1455,8 +1431,6 @@ function createAlbumSlideshowCardEditorClass(Base) {
14551431
"Pick a preset or type a custom format (YYYY, MMMM, MMM, MM, DD, D).",
14561432
caption_per_image:
14571433
"When a portrait pair is shown, caption each photo with its own date and location.",
1458-
caption_layout:
1459-
"How date and location stack when both are shown: stacked (one per line) or inline (same line). No effect with a single field.",
14601434
caption_color: "CSS color, e.g. #ffffff or white.",
14611435
caption_font_size: "CSS size, e.g. 14px, 1.1em.",
14621436
live_paused:
@@ -1667,8 +1641,6 @@ function createAlbumSlideshowCardEditorClass(Base) {
16671641
const cap = { show };
16681642
const pos = data.caption_position || CAPTION_DEFAULTS.position;
16691643
if (pos !== CAPTION_DEFAULTS.position) cap.position = pos;
1670-
const lay = data.caption_layout || CAPTION_DEFAULTS.layout;
1671-
if (lay !== CAPTION_DEFAULTS.layout) cap.layout = lay;
16721644
if (data.caption_per_image === false) cap.per_image = false;
16731645
const df = data.caption_date_format || CAPTION_DEFAULTS.date_format;
16741646
if (df !== CAPTION_DEFAULTS.date_format) cap.date_format = df;

0 commit comments

Comments
 (0)