Release 1.2.0 with calmer snack planning and PDF exports
This commit is contained in:
+380
-9
@@ -853,6 +853,38 @@ legend {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.day-tile.has-selection {
|
||||
border-color: color-mix(in srgb, var(--accent) 34%, var(--line) 66%);
|
||||
box-shadow: 0 20px 36px rgba(94, 68, 49, 0.16);
|
||||
}
|
||||
|
||||
.day-tile.has-entries {
|
||||
position: relative;
|
||||
border-color: color-mix(in srgb, var(--accent) 24%, var(--line) 76%);
|
||||
background:
|
||||
linear-gradient(180deg, color-mix(in srgb, var(--surface) 90%, #ffe8d8 10%), color-mix(in srgb, var(--surface) 96%, #fff 4%));
|
||||
box-shadow: 0 18px 34px rgba(94, 68, 49, 0.14);
|
||||
}
|
||||
|
||||
.day-tile.has-entries::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
inset: 0 auto 0 0;
|
||||
width: 4px;
|
||||
background: linear-gradient(180deg, color-mix(in srgb, var(--accent-strong) 76%, white 24%), color-mix(in srgb, var(--accent) 72%, transparent 28%));
|
||||
opacity: 0.9;
|
||||
}
|
||||
|
||||
.day-tile.has-entries .day-tile-summary {
|
||||
background:
|
||||
linear-gradient(180deg, rgba(255, 236, 221, 0.28), rgba(255, 255, 255, 0));
|
||||
}
|
||||
|
||||
.day-tile.has-entries .status-pill {
|
||||
background: color-mix(in srgb, var(--mint-soft) 78%, var(--surface) 22%);
|
||||
border: 1px solid color-mix(in srgb, var(--mint-soft) 54%, var(--line) 46%);
|
||||
}
|
||||
|
||||
.day-tile > summary::-webkit-details-marker {
|
||||
display: none;
|
||||
}
|
||||
@@ -892,11 +924,85 @@ legend {
|
||||
height: 1.15rem;
|
||||
}
|
||||
|
||||
.day-tile.has-entries .day-tile-icon {
|
||||
background: linear-gradient(145deg, rgba(255, 255, 255, 0.98), color-mix(in srgb, var(--accent-soft) 68%, #fff 32%));
|
||||
box-shadow: 0 10px 22px rgba(94, 68, 49, 0.14);
|
||||
}
|
||||
|
||||
.day-tile-summary-text {
|
||||
margin: 0.2rem 0 0;
|
||||
color: color-mix(in srgb, var(--text) 84%, white 16%);
|
||||
font-size: 1.08rem;
|
||||
}
|
||||
|
||||
.day-tile.has-entries .day-tile-summary-text {
|
||||
color: color-mix(in srgb, var(--text) 90%, white 10%);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
[data-theme="dark"] .day-tile.has-entries {
|
||||
border-color: color-mix(in srgb, var(--accent) 30%, var(--line) 70%);
|
||||
background:
|
||||
linear-gradient(180deg, color-mix(in srgb, var(--surface) 96%, #3f3430 4%), color-mix(in srgb, var(--surface) 100%, #000 0%));
|
||||
box-shadow: 0 18px 38px rgba(0, 0, 0, 0.26);
|
||||
}
|
||||
|
||||
[data-theme="dark"] .day-tile.has-entries .day-tile-summary {
|
||||
background:
|
||||
linear-gradient(90deg, rgba(243, 177, 125, 0.10), rgba(243, 177, 125, 0.03) 38%, rgba(255, 255, 255, 0) 68%);
|
||||
}
|
||||
|
||||
[data-theme="dark"] .day-tile.has-entries .day-tile-icon {
|
||||
background: linear-gradient(145deg, rgba(255, 255, 255, 0.12), rgba(243, 177, 125, 0.16));
|
||||
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
|
||||
}
|
||||
|
||||
[data-theme="dark"] .day-tile.has-entries .status-pill {
|
||||
background: rgba(155, 198, 175, 0.20);
|
||||
border-color: rgba(155, 198, 175, 0.16);
|
||||
}
|
||||
|
||||
[data-theme="dark"] .day-tile.has-entries .day-tile-summary-text {
|
||||
color: #f3ece7;
|
||||
}
|
||||
|
||||
.day-tile-body {
|
||||
padding: 0 1.25rem 1.25rem;
|
||||
border-top: 1px solid var(--line);
|
||||
}
|
||||
|
||||
.snack-reveal-panel {
|
||||
padding: 1rem 1.1rem;
|
||||
}
|
||||
|
||||
.snack-reveal-actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.65rem;
|
||||
}
|
||||
|
||||
.snack-reveal-button {
|
||||
padding: 0.58rem 0.9rem;
|
||||
}
|
||||
|
||||
.week-card-snack-actions {
|
||||
display: grid;
|
||||
gap: 0.7rem;
|
||||
margin: 0.2rem 0 0.95rem;
|
||||
padding: 0.8rem 0.9rem;
|
||||
border-radius: 18px;
|
||||
border: 1px solid var(--line);
|
||||
background: color-mix(in srgb, var(--surface) 94%, var(--surface-strong) 6%);
|
||||
}
|
||||
|
||||
.week-card-snack-actions .eyebrow {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.week-card-empty-copy {
|
||||
margin-bottom: 0.95rem;
|
||||
}
|
||||
|
||||
.quick-add-row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
@@ -972,6 +1078,12 @@ legend {
|
||||
background: color-mix(in srgb, var(--surface-strong) 84%, #fff 16%);
|
||||
}
|
||||
|
||||
.selected-quick-action {
|
||||
background: linear-gradient(180deg, color-mix(in srgb, var(--accent-soft) 82%, #fff 18%), color-mix(in srgb, var(--surface-strong) 82%, #fff 18%));
|
||||
border-color: color-mix(in srgb, var(--accent) 36%, var(--line) 64%);
|
||||
box-shadow: 0 16px 30px rgba(94, 68, 49, 0.12);
|
||||
}
|
||||
|
||||
.template-list-card,
|
||||
.week-template-row {
|
||||
display: grid;
|
||||
@@ -1148,24 +1260,99 @@ legend {
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.week-card-count {
|
||||
font-size: 1.25rem;
|
||||
font-family: var(--font-heading);
|
||||
margin: 0.8rem 0 0.2rem;
|
||||
}
|
||||
|
||||
.week-card-actions {
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
.export-menu {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.export-menu > summary {
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.export-menu > summary::-webkit-details-marker {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.export-menu-trigger::after {
|
||||
content: "▾";
|
||||
font-size: 0.8rem;
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.export-menu[open] .export-menu-trigger {
|
||||
background: var(--accent-soft);
|
||||
}
|
||||
|
||||
.export-menu-panel {
|
||||
position: absolute;
|
||||
top: calc(100% + 0.45rem);
|
||||
right: 0;
|
||||
z-index: 14;
|
||||
min-width: 13.5rem;
|
||||
display: grid;
|
||||
gap: 0.15rem;
|
||||
padding: 0.45rem;
|
||||
border-radius: 18px;
|
||||
border: 1px solid var(--line);
|
||||
background: color-mix(in srgb, var(--surface) 96%, #fff 4%);
|
||||
box-shadow: var(--shadow);
|
||||
}
|
||||
|
||||
.export-menu-panel a {
|
||||
display: block;
|
||||
padding: 0.8rem 0.9rem;
|
||||
border-radius: 14px;
|
||||
color: var(--text);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.export-menu-panel a:hover {
|
||||
background: var(--accent-soft);
|
||||
}
|
||||
|
||||
.week-card {
|
||||
position: relative;
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
.week-card.has-open-picker {
|
||||
z-index: 6;
|
||||
}
|
||||
|
||||
.week-slot {
|
||||
position: relative;
|
||||
padding: 0.85rem;
|
||||
border-radius: 18px;
|
||||
background: color-mix(in srgb, var(--surface-strong) 80%, #fff 20%);
|
||||
background: linear-gradient(180deg, color-mix(in srgb, var(--surface-strong) 84%, #fff 16%), color-mix(in srgb, var(--surface) 90%, #fff 10%));
|
||||
border: 1px solid var(--line);
|
||||
transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
|
||||
}
|
||||
|
||||
.week-slot.has-entries {
|
||||
border-color: color-mix(in srgb, var(--accent) 24%, var(--line) 76%);
|
||||
background:
|
||||
linear-gradient(180deg, color-mix(in srgb, var(--surface) 90%, #ffe8d8 10%), color-mix(in srgb, var(--surface) 96%, #fff 4%));
|
||||
box-shadow: 0 18px 34px rgba(94, 68, 49, 0.12);
|
||||
}
|
||||
|
||||
.week-slot.has-entries::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
inset: 0 auto 0 0;
|
||||
width: 4px;
|
||||
border-radius: 18px 0 0 18px;
|
||||
background: linear-gradient(180deg, color-mix(in srgb, var(--accent-strong) 76%, white 24%), color-mix(in srgb, var(--accent) 72%, transparent 28%));
|
||||
opacity: 0.9;
|
||||
}
|
||||
|
||||
.week-slot.week-slot-snack.has-entries {
|
||||
background:
|
||||
linear-gradient(180deg, color-mix(in srgb, var(--surface) 92%, #ffe3cf 8%), color-mix(in srgb, var(--surface) 98%, #fff 2%));
|
||||
}
|
||||
|
||||
.week-slot.is-drag-over {
|
||||
background: var(--accent-soft);
|
||||
border-color: color-mix(in srgb, var(--accent) 60%, var(--line) 40%);
|
||||
@@ -1180,11 +1367,91 @@ legend {
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.week-slot-head-meta {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.45rem;
|
||||
}
|
||||
|
||||
.week-slot-count {
|
||||
min-width: 1.9rem;
|
||||
text-align: center;
|
||||
font-weight: 700;
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.week-slot.has-entries .week-slot-count {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-width: 2rem;
|
||||
height: 2rem;
|
||||
padding: 0 0.55rem;
|
||||
border-radius: 999px;
|
||||
border: 1px solid color-mix(in srgb, var(--mint-soft) 54%, var(--line) 46%);
|
||||
background: color-mix(in srgb, var(--mint-soft) 78%, var(--surface) 22%);
|
||||
color: color-mix(in srgb, var(--text) 86%, #173127 14%);
|
||||
}
|
||||
|
||||
.week-slot-add {
|
||||
width: 1.9rem;
|
||||
height: 1.9rem;
|
||||
display: inline-grid;
|
||||
place-items: center;
|
||||
padding: 0;
|
||||
border-radius: 999px;
|
||||
border: 1px solid var(--line);
|
||||
background: var(--accent-soft);
|
||||
color: var(--text);
|
||||
font-weight: 700;
|
||||
font-size: 1.15rem;
|
||||
line-height: 1;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.week-slot-add:hover {
|
||||
background: color-mix(in srgb, var(--accent-soft) 72%, #fff 28%);
|
||||
}
|
||||
|
||||
.week-slot-picker {
|
||||
position: absolute;
|
||||
top: calc(100% + 0.55rem);
|
||||
left: 0;
|
||||
right: 0;
|
||||
z-index: 12;
|
||||
display: grid;
|
||||
gap: 0.9rem;
|
||||
padding: 0.95rem;
|
||||
border-radius: 18px;
|
||||
border: 1px solid var(--line);
|
||||
background: color-mix(in srgb, var(--surface) 96%, #fff 4%);
|
||||
box-shadow: var(--shadow);
|
||||
}
|
||||
|
||||
.week-slot-picker[hidden] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.week-slot-picker-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
.week-slot-picker-close {
|
||||
padding: 0.5rem 0.85rem;
|
||||
}
|
||||
|
||||
.week-slot-picker-search {
|
||||
margin-bottom: 0.1rem;
|
||||
}
|
||||
|
||||
.plan-chip {
|
||||
padding: 0.7rem 0.8rem;
|
||||
border-radius: 16px;
|
||||
background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(255, 246, 239, 0.92));
|
||||
border: 1px solid var(--line);
|
||||
background: linear-gradient(180deg, color-mix(in srgb, var(--surface) 72%, #fff 28%), color-mix(in srgb, var(--accent-soft) 55%, var(--surface) 45%));
|
||||
border: 1px solid color-mix(in srgb, var(--accent) 18%, var(--line) 82%);
|
||||
cursor: grab;
|
||||
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
|
||||
}
|
||||
@@ -1203,11 +1470,115 @@ legend {
|
||||
transform: scale(0.98);
|
||||
}
|
||||
|
||||
.week-slot-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
margin-top: 0.65rem;
|
||||
}
|
||||
|
||||
.week-slot-copy {
|
||||
padding: 0.55rem 0.85rem;
|
||||
}
|
||||
|
||||
.plan-chip small,
|
||||
.week-slot-empty {
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.week-slot-empty {
|
||||
display: grid;
|
||||
justify-items: start;
|
||||
gap: 0.65rem;
|
||||
padding: 0.85rem;
|
||||
border-radius: 16px;
|
||||
border: 1px dashed color-mix(in srgb, var(--line) 74%, var(--accent) 26%);
|
||||
background: color-mix(in srgb, var(--surface) 92%, #fff 8%);
|
||||
}
|
||||
|
||||
.week-slot-empty p {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
[data-theme="dark"] .week-slot {
|
||||
background: linear-gradient(180deg, rgba(66, 57, 54, 0.96), rgba(58, 50, 48, 0.98));
|
||||
border-color: rgba(243, 177, 125, 0.14);
|
||||
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
|
||||
}
|
||||
|
||||
[data-theme="dark"] .week-card-snack-actions {
|
||||
background: rgba(47, 40, 38, 0.72);
|
||||
border-color: rgba(243, 177, 125, 0.10);
|
||||
}
|
||||
|
||||
[data-theme="dark"] .export-menu-panel {
|
||||
background: rgba(43, 37, 35, 0.98);
|
||||
border-color: rgba(243, 177, 125, 0.14);
|
||||
box-shadow: 0 22px 46px rgba(0, 0, 0, 0.34);
|
||||
}
|
||||
|
||||
[data-theme="dark"] .export-menu-panel a:hover {
|
||||
background: rgba(243, 177, 125, 0.10);
|
||||
}
|
||||
|
||||
[data-theme="dark"] .week-slot.has-entries {
|
||||
border-color: rgba(243, 177, 125, 0.18);
|
||||
background:
|
||||
linear-gradient(180deg, rgba(70, 60, 57, 0.98), rgba(58, 50, 48, 0.99));
|
||||
box-shadow: 0 18px 34px rgba(0, 0, 0, 0.24);
|
||||
}
|
||||
|
||||
[data-theme="dark"] .week-slot.week-slot-snack.has-entries {
|
||||
background:
|
||||
linear-gradient(180deg, rgba(75, 64, 60, 0.98), rgba(60, 52, 49, 0.99));
|
||||
}
|
||||
|
||||
[data-theme="dark"] .week-slot.has-entries .week-slot-count {
|
||||
border-color: rgba(155, 198, 175, 0.16);
|
||||
background: rgba(155, 198, 175, 0.20);
|
||||
color: #eef8f2;
|
||||
}
|
||||
|
||||
[data-theme="dark"] .week-slot.is-drag-over {
|
||||
background: linear-gradient(180deg, rgba(87, 71, 64, 0.98), rgba(72, 58, 53, 0.98));
|
||||
border-color: rgba(243, 177, 125, 0.24);
|
||||
}
|
||||
|
||||
[data-theme="dark"] .week-slot-add {
|
||||
background: rgba(243, 177, 125, 0.16);
|
||||
border-color: rgba(243, 177, 125, 0.18);
|
||||
color: #f7efe9;
|
||||
}
|
||||
|
||||
[data-theme="dark"] .week-slot-add:hover {
|
||||
background: rgba(243, 177, 125, 0.22);
|
||||
}
|
||||
|
||||
[data-theme="dark"] .week-slot-picker {
|
||||
background: rgba(43, 37, 35, 0.98);
|
||||
border-color: rgba(243, 177, 125, 0.14);
|
||||
box-shadow: 0 22px 46px rgba(0, 0, 0, 0.34);
|
||||
}
|
||||
|
||||
[data-theme="dark"] .plan-chip {
|
||||
background: linear-gradient(180deg, rgba(86, 72, 66, 0.98), rgba(72, 60, 56, 0.98));
|
||||
border-color: rgba(243, 177, 125, 0.18);
|
||||
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
|
||||
}
|
||||
|
||||
[data-theme="dark"] .week-slot-copy {
|
||||
background: rgba(255, 255, 255, 0.03);
|
||||
border-color: rgba(243, 177, 125, 0.12);
|
||||
}
|
||||
|
||||
[data-theme="dark"] .week-slot-copy:hover {
|
||||
background: rgba(243, 177, 125, 0.10);
|
||||
}
|
||||
|
||||
[data-theme="dark"] .week-slot-empty {
|
||||
background: rgba(58, 50, 48, 0.72);
|
||||
border-color: rgba(243, 177, 125, 0.16);
|
||||
}
|
||||
|
||||
.flash-stack {
|
||||
display: grid;
|
||||
gap: 0.7rem;
|
||||
|
||||
@@ -4,6 +4,38 @@
|
||||
return meta ? meta.getAttribute("content") : "";
|
||||
};
|
||||
|
||||
const scrollKey = "nouri-week-scroll";
|
||||
|
||||
const rememberScroll = () => {
|
||||
sessionStorage.setItem(scrollKey, String(window.scrollY));
|
||||
};
|
||||
|
||||
const restoreScroll = () => {
|
||||
const savedScroll = sessionStorage.getItem(scrollKey);
|
||||
if (!savedScroll) return;
|
||||
sessionStorage.removeItem(scrollKey);
|
||||
window.requestAnimationFrame(() => {
|
||||
window.scrollTo({ top: Number(savedScroll), left: 0, behavior: "auto" });
|
||||
});
|
||||
};
|
||||
|
||||
const postAndRefreshInPlace = async (form) => {
|
||||
const payload = new URLSearchParams(new FormData(form));
|
||||
const response = await fetch(form.action, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
|
||||
"X-Requested-With": "XMLHttpRequest",
|
||||
},
|
||||
body: payload.toString(),
|
||||
});
|
||||
if (!response.ok) {
|
||||
throw new Error("request failed");
|
||||
}
|
||||
rememberScroll();
|
||||
window.location.reload();
|
||||
};
|
||||
|
||||
const initWeekDragAndDrop = () => {
|
||||
const board = document.querySelector(".week-board");
|
||||
if (!board) return;
|
||||
@@ -75,7 +107,185 @@
|
||||
});
|
||||
};
|
||||
|
||||
const initWeekCopyForward = () => {
|
||||
document.querySelectorAll(".js-copy-forward-form").forEach((form) => {
|
||||
form.addEventListener("submit", async (event) => {
|
||||
event.preventDefault();
|
||||
try {
|
||||
await postAndRefreshInPlace(form);
|
||||
} catch (_error) {
|
||||
window.location.reload();
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const initWeekSlotPicker = () => {
|
||||
const board = document.querySelector(".week-board");
|
||||
if (!board) return;
|
||||
|
||||
const closeAllPickers = () => {
|
||||
board.querySelectorAll(".week-card").forEach((card) => {
|
||||
card.classList.remove("has-open-picker");
|
||||
});
|
||||
board.querySelectorAll(".week-slot").forEach((slot) => {
|
||||
slot.classList.remove("is-picker-open");
|
||||
});
|
||||
board.querySelectorAll(".week-slot-picker").forEach((picker) => {
|
||||
picker.hidden = true;
|
||||
});
|
||||
};
|
||||
|
||||
board.querySelectorAll("[data-week-slot-picker-open]").forEach((button) => {
|
||||
button.addEventListener("click", (event) => {
|
||||
event.preventDefault();
|
||||
const slot = button.closest(".week-slot");
|
||||
if (!slot) return;
|
||||
const picker = slot.querySelector(".week-slot-picker");
|
||||
if (!picker) return;
|
||||
const card = slot.closest(".week-card");
|
||||
const shouldOpen = picker.hidden;
|
||||
closeAllPickers();
|
||||
if (shouldOpen) {
|
||||
picker.hidden = false;
|
||||
slot.classList.add("is-picker-open");
|
||||
if (card) {
|
||||
card.classList.add("has-open-picker");
|
||||
}
|
||||
const filterInput = picker.querySelector("[data-filter-input]");
|
||||
if (filterInput instanceof HTMLInputElement) {
|
||||
filterInput.value = "";
|
||||
filterInput.dispatchEvent(new Event("input", { bubbles: true }));
|
||||
window.requestAnimationFrame(() => filterInput.focus());
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
board.querySelectorAll("[data-week-slot-picker-close]").forEach((button) => {
|
||||
button.addEventListener("click", () => {
|
||||
const slot = button.closest(".week-slot");
|
||||
if (!slot) return;
|
||||
const picker = slot.querySelector(".week-slot-picker");
|
||||
const card = slot.closest(".week-card");
|
||||
if (!picker) return;
|
||||
picker.hidden = true;
|
||||
slot.classList.remove("is-picker-open");
|
||||
if (card) {
|
||||
card.classList.remove("has-open-picker");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
board.querySelectorAll(".js-week-slot-submit").forEach((form) => {
|
||||
form.addEventListener("submit", async (event) => {
|
||||
event.preventDefault();
|
||||
try {
|
||||
await postAndRefreshInPlace(form);
|
||||
} catch (_error) {
|
||||
window.location.reload();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
document.addEventListener("click", (event) => {
|
||||
const target = event.target;
|
||||
if (!(target instanceof Element)) return;
|
||||
if (target.closest(".week-slot")) return;
|
||||
closeAllPickers();
|
||||
});
|
||||
};
|
||||
|
||||
const syncActionContainerVisibility = (container) => {
|
||||
if (!(container instanceof HTMLElement)) return;
|
||||
const hasVisibleButtons = Array.from(container.querySelectorAll("button")).some((button) => {
|
||||
return !button.hidden;
|
||||
});
|
||||
container.hidden = !hasVisibleButtons;
|
||||
};
|
||||
|
||||
const revealActionButton = (container, selector) => {
|
||||
if (!(container instanceof HTMLElement) || !selector) return;
|
||||
const button = container.querySelector(`button[data-target="${selector}"]`);
|
||||
if (!(button instanceof HTMLButtonElement)) return;
|
||||
button.hidden = false;
|
||||
container.hidden = false;
|
||||
};
|
||||
|
||||
const initDaySnackReveal = () => {
|
||||
document.querySelectorAll("[data-day-snack-open]").forEach((button) => {
|
||||
button.addEventListener("click", () => {
|
||||
const selector = button.getAttribute("data-target");
|
||||
if (!selector) return;
|
||||
const tile = document.querySelector(selector);
|
||||
if (!(tile instanceof HTMLDetailsElement)) return;
|
||||
tile.hidden = false;
|
||||
tile.open = true;
|
||||
button.hidden = true;
|
||||
tile.scrollIntoView({ block: "nearest", inline: "nearest" });
|
||||
syncActionContainerVisibility(button.closest("[data-day-snack-actions]"));
|
||||
});
|
||||
});
|
||||
|
||||
document.querySelectorAll("[data-day-snack-hide]").forEach((button) => {
|
||||
button.addEventListener("click", () => {
|
||||
const selector = button.getAttribute("data-target");
|
||||
if (!selector) return;
|
||||
const tile = document.querySelector(selector);
|
||||
if (!(tile instanceof HTMLDetailsElement)) return;
|
||||
tile.open = false;
|
||||
tile.hidden = true;
|
||||
revealActionButton(document.querySelector("[data-day-snack-actions]"), selector);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const initWeekSnackReveal = () => {
|
||||
document.querySelectorAll("[data-week-snack-slot-open]").forEach((button) => {
|
||||
button.addEventListener("click", () => {
|
||||
const selector = button.getAttribute("data-target");
|
||||
if (!selector) return;
|
||||
const slot = document.querySelector(selector);
|
||||
if (!(slot instanceof HTMLElement)) return;
|
||||
slot.hidden = false;
|
||||
button.hidden = true;
|
||||
syncActionContainerVisibility(button.closest("[data-week-snack-actions]"));
|
||||
const openButton = slot.querySelector("[data-week-slot-picker-open]");
|
||||
if (openButton instanceof HTMLButtonElement) {
|
||||
openButton.click();
|
||||
} else {
|
||||
slot.scrollIntoView({ block: "nearest", inline: "nearest" });
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
document.querySelectorAll("[data-week-snack-slot-hide]").forEach((button) => {
|
||||
button.addEventListener("click", () => {
|
||||
const selector = button.getAttribute("data-target");
|
||||
if (!selector) return;
|
||||
const slot = document.querySelector(selector);
|
||||
if (!(slot instanceof HTMLElement)) return;
|
||||
const picker = slot.querySelector(".week-slot-picker");
|
||||
if (picker instanceof HTMLElement) {
|
||||
picker.hidden = true;
|
||||
}
|
||||
slot.classList.remove("is-picker-open");
|
||||
slot.hidden = true;
|
||||
const card = slot.closest(".week-card");
|
||||
if (card) {
|
||||
card.classList.remove("has-open-picker");
|
||||
}
|
||||
revealActionButton(slot.closest(".week-card")?.querySelector("[data-week-snack-actions]"), selector);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
restoreScroll();
|
||||
initWeekDragAndDrop();
|
||||
initWeekCopyForward();
|
||||
initWeekSlotPicker();
|
||||
initDaySnackReveal();
|
||||
initWeekSnackReveal();
|
||||
});
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user