updated tandoor widget
This commit is contained in:
@@ -788,138 +788,69 @@ data:
|
||||
tandoor_url: https://tandoor.dooplex.hu
|
||||
|
||||
template: |
|
||||
<style>
|
||||
.mealwrap { display:flex; flex-direction:column; gap:10px; }
|
||||
.mealmeta { opacity:.65; font-size:12px; display:flex; justify-content:space-between; align-items:center; }
|
||||
.mealscroller-wrap { position:relative; }
|
||||
.mealscroller { display:flex; gap:0; overflow-x:auto; scroll-snap-type:x mandatory; -webkit-overflow-scrolling:touch; scrollbar-width:none; -ms-overflow-style:none; }
|
||||
.mealscroller::-webkit-scrollbar { display:none; }
|
||||
.mealslide { min-width:100%; flex-shrink:0; scroll-snap-align:start; border-radius:14px; overflow:hidden; background:rgba(255,255,255,0.04); box-shadow:0 0 0 1px rgba(255,255,255,0.06) inset; }
|
||||
.mealimg { height:150px; background:rgba(0,0,0,0.15); display:flex; align-items:center; justify-content:center; overflow:hidden; position:relative; }
|
||||
.mealimg img { width:100%; height:100%; object-fit:cover; display:block; }
|
||||
.mealnoimg { opacity:.55; font-size:12px; padding:18px; text-align:center; }
|
||||
.mealname { padding:10px 12px 8px; font-weight:700; opacity:.95; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
|
||||
.mealactions { padding:0 12px 12px; display:flex; gap:10px; opacity:.8; font-size:12px; }
|
||||
.mealactions a { text-decoration:none; }
|
||||
.meallink { display:block; color:inherit; text-decoration:none; }
|
||||
/* Navigation arrows */
|
||||
.meal-nav { position:absolute; top:50%; transform:translateY(-50%); width:32px; height:32px; border-radius:50%; background:rgba(0,0,0,0.5); color:#fff; border:none; cursor:pointer; display:flex; align-items:center; justify-content:center; font-size:14px; z-index:10; opacity:0.7; transition:opacity 0.2s; }
|
||||
.meal-nav:hover { opacity:1; background:rgba(0,0,0,0.7); }
|
||||
.meal-nav.prev { left:8px; }
|
||||
.meal-nav.next { right:8px; }
|
||||
.meal-nav.hidden { display:none; }
|
||||
/* Pagination dots */
|
||||
.meal-dots { display:flex; justify-content:center; gap:6px; padding:8px 0 4px; }
|
||||
.meal-dot { width:8px; height:8px; border-radius:50%; background:rgba(255,255,255,0.25); cursor:pointer; transition:background 0.2s; }
|
||||
.meal-dot.active { background:rgba(255,255,255,0.8); }
|
||||
.meal-dot:hover { background:rgba(255,255,255,0.5); }
|
||||
</style>
|
||||
|
||||
{{ $tandoor := .Options.StringOr "tandoor_url" "https://tandoor.dooplex.hu" }}
|
||||
{{ $items := .JSON.Array "items" }}
|
||||
{{ $total := .JSON.Int "total_recipes" }}
|
||||
{{ $date := .JSON.String "date" }}
|
||||
{{ $count := len $items }}
|
||||
{{ $last := sub $count 1 }}
|
||||
|
||||
<div class="mealwrap">
|
||||
<div class="mealmeta">
|
||||
<style>
|
||||
.mw { display:flex; flex-direction:column; gap:6px; }
|
||||
.mw-meta { opacity:.65; font-size:12px; display:flex; justify-content:space-between; align-items:center; }
|
||||
.mw-box { position:relative; border-radius:14px; background:rgba(255,255,255,0.04); box-shadow:0 0 0 1px rgba(255,255,255,0.06) inset; overflow:hidden; }
|
||||
.mw-box input { display:none; }
|
||||
.mw-track { display:flex; transition:transform 0.3s ease; }
|
||||
.mw-s { min-width:100%; flex-shrink:0; }
|
||||
.mw-img { height:150px; background:rgba(0,0,0,0.15); overflow:hidden; }
|
||||
.mw-img img { width:100%; height:100%; object-fit:cover; }
|
||||
.mw-noimg { height:150px; display:flex; align-items:center; justify-content:center; opacity:.5; font-size:12px; }
|
||||
.mw-name { padding:10px 12px 6px; font-weight:700; opacity:.95; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
|
||||
.mw-acts { padding:0 12px 10px; display:flex; gap:10px; opacity:.8; font-size:12px; }
|
||||
.mw-acts a, .mw-link { text-decoration:none; color:inherit; display:block; }
|
||||
/* Arrows - hidden by default, shown on hover */
|
||||
.mw-p, .mw-n { position:absolute; top:75px; transform:translateY(-50%); width:26px; height:26px; border-radius:50%; background:rgba(0,0,0,0.6); color:#fff; align-items:center; justify-content:center; font-size:11px; cursor:pointer; z-index:5; display:none; }
|
||||
.mw-p { left:6px; }
|
||||
.mw-n { right:6px; }
|
||||
.mw-p:hover, .mw-n:hover { background:rgba(0,0,0,0.85); }
|
||||
/* Dots */
|
||||
.mw-dots { display:flex; justify-content:center; gap:5px; padding:3px 0 1px; }
|
||||
.mw-dot { width:6px; height:6px; border-radius:50%; background:rgba(255,255,255,0.2); cursor:pointer; }
|
||||
.mw-dot:hover { background:rgba(255,255,255,0.4); }
|
||||
/* Dynamic styles per slide */
|
||||
{{ range $i, $_ := $items }}
|
||||
#mr{{ $i }}:checked ~ .mw-track { transform:translateX(-{{ mul $i 100 }}%); }
|
||||
#mr{{ $i }}:checked ~ .mw-dots .mw-dot:nth-child({{ add $i 1 }}) { background:rgba(255,255,255,0.85); }
|
||||
{{ if gt $i 0 }}.mw-box:hover #mr{{ $i }}:checked ~ .mw-p[data-t="{{ sub $i 1 }}"] { display:flex; }{{ end }}
|
||||
{{ if lt $i $last }}.mw-box:hover #mr{{ $i }}:checked ~ .mw-n[data-t="{{ add $i 1 }}"] { display:flex; }{{ end }}
|
||||
{{ end }}
|
||||
</style>
|
||||
|
||||
<div class="mw">
|
||||
<div class="mw-meta">
|
||||
<span>Today's picks ({{ $count }} total)</span>
|
||||
<a href="{{ $tandoor }}" target="_blank" rel="noreferrer">Open Tandoor</a>
|
||||
</div>
|
||||
|
||||
{{ if lt $count 1 }}
|
||||
<div class="color-negative">No recipes returned.</div>
|
||||
{{ else }}
|
||||
<div class="mealscroller-wrap">
|
||||
<div class="mealscroller" id="mealScroller">
|
||||
{{ range $i, $r := $items }}
|
||||
{{ $name := $r.String "name" }}
|
||||
{{ $img := $r.String "image" }}
|
||||
{{ $url := $r.String "url" }}
|
||||
{{ $cook := $r.String "cook_url" }}
|
||||
|
||||
<div class="mealslide" data-index="{{ $i }}">
|
||||
<a class="meallink" href="{{ $url }}" target="_blank" rel="noreferrer">
|
||||
<div class="mealimg">
|
||||
{{ if $img }}<img src="{{ $img }}" alt="" loading="lazy" />{{ else }}<div class="mealnoimg">No image</div>{{ end }}
|
||||
</div>
|
||||
<div class="mealname">{{ $name }}</div>
|
||||
</a>
|
||||
<div class="mealactions">
|
||||
<a href="{{ $url }}" target="_blank" rel="noreferrer">Open</a>
|
||||
<a href="{{ $cook }}" target="_blank" rel="noreferrer">Cooked today ✔</a>
|
||||
</div>
|
||||
</div>
|
||||
{{ end }}
|
||||
{{ if lt $count 1 }}<div class="color-negative">No recipes.</div>{{ else }}
|
||||
<div class="mw-box">
|
||||
{{ range $i, $_ := $items }}<input type="radio" name="mr" id="mr{{ $i }}"{{ if eq $i 0 }} checked{{ end }}>{{ end }}
|
||||
<div class="mw-track">
|
||||
{{ range $r := $items }}{{ $img := $r.String "image" }}{{ $url := $r.String "url" }}{{ $cook := $r.String "cook_url" }}
|
||||
<div class="mw-s">
|
||||
<a class="mw-link" href="{{ $url }}" target="_blank">
|
||||
<div class="mw-img">{{ if $img }}<img src="{{ $img }}" alt="">{{ else }}<div class="mw-noimg">No image</div>{{ end }}</div>
|
||||
<div class="mw-name">{{ $r.String "name" }}</div>
|
||||
</a>
|
||||
<div class="mw-acts"><a href="{{ $url }}" target="_blank">Open</a> <a href="{{ $cook }}" target="_blank">Cooked today ✔</a></div>
|
||||
</div>
|
||||
{{ if gt $count 1 }}
|
||||
<button class="meal-nav prev" onclick="mealNav(-1)" aria-label="Previous">◀</button>
|
||||
<button class="meal-nav next" onclick="mealNav(1)" aria-label="Next">▶</button>
|
||||
{{ end }}
|
||||
</div>
|
||||
{{ if gt $count 1 }}
|
||||
<div class="meal-dots" id="mealDots">
|
||||
{{ range $i, $r := $items }}
|
||||
<span class="meal-dot{{ if eq $i 0 }} active{{ end }}" data-index="{{ $i }}" onclick="mealGo({{ $i }})"></span>
|
||||
{{ end }}
|
||||
</div>
|
||||
{{ range $i, $_ := $items }}{{ if gt $i 0 }}<label class="mw-p" for="mr{{ sub $i 1 }}" data-t="{{ sub $i 1 }}">◀</label>{{ end }}{{ if lt $i $last }}<label class="mw-n" for="mr{{ add $i 1 }}" data-t="{{ add $i 1 }}">▶</label>{{ end }}{{ end }}
|
||||
<div class="mw-dots">{{ range $i, $_ := $items }}<label class="mw-dot" for="mr{{ $i }}"></label>{{ end }}</div>
|
||||
{{ end }}
|
||||
</div>
|
||||
{{ end }}
|
||||
</div>
|
||||
|
||||
{{ if gt $count 1 }}
|
||||
<script>
|
||||
(function() {
|
||||
const scroller = document.getElementById('mealScroller');
|
||||
const dots = document.querySelectorAll('#mealDots .meal-dot');
|
||||
const prevBtn = scroller?.parentElement.querySelector('.meal-nav.prev');
|
||||
const nextBtn = scroller?.parentElement.querySelector('.meal-nav.next');
|
||||
const total = {{ $count }};
|
||||
let current = 0;
|
||||
|
||||
function updateUI() {
|
||||
dots.forEach((d, i) => d.classList.toggle('active', i === current));
|
||||
if (prevBtn) prevBtn.classList.toggle('hidden', current === 0);
|
||||
if (nextBtn) nextBtn.classList.toggle('hidden', current === total - 1);
|
||||
}
|
||||
|
||||
function scrollToIndex(i) {
|
||||
if (!scroller) return;
|
||||
const slide = scroller.children[i];
|
||||
if (slide) {
|
||||
scroller.scrollTo({ left: slide.offsetLeft, behavior: 'smooth' });
|
||||
current = i;
|
||||
updateUI();
|
||||
}
|
||||
}
|
||||
|
||||
window.mealNav = function(dir) {
|
||||
const next = Math.max(0, Math.min(total - 1, current + dir));
|
||||
scrollToIndex(next);
|
||||
};
|
||||
|
||||
window.mealGo = function(i) {
|
||||
scrollToIndex(i);
|
||||
};
|
||||
|
||||
// Track scroll position
|
||||
if (scroller) {
|
||||
scroller.addEventListener('scroll', function() {
|
||||
const scrollLeft = scroller.scrollLeft;
|
||||
const slideWidth = scroller.offsetWidth;
|
||||
const newCurrent = Math.round(scrollLeft / slideWidth);
|
||||
if (newCurrent !== current && newCurrent >= 0 && newCurrent < total) {
|
||||
current = newCurrent;
|
||||
updateUI();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
updateUI();
|
||||
})();
|
||||
</script>
|
||||
{{ end }}
|
||||
|
||||
- type: bookmarks
|
||||
title: Productivity Self-Hosted
|
||||
groups:
|
||||
|
||||
Reference in New Issue
Block a user