Highlight weekend days in dashboard activity chart
Add isoDow() helper to datetime.js and mark weekend columns in the 14-day activity chart on the dashboard (orange bar, muted day label).
This commit is contained in:
@@ -731,6 +731,8 @@ body{font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;b
|
||||
.bar{width:100%;max-width:28px;background:var(--accent);opacity:.35;border-radius:4px 4px 0 0;min-height:2px;transition:opacity .15s}
|
||||
.bar:hover{opacity:1}
|
||||
.bar.today{opacity:1}
|
||||
.bar-col.weekend .bar{background:#f97316}
|
||||
.bar-col.weekend .bar-day{color:#ea580c}
|
||||
.bar-day{font-size:.62rem;color:var(--muted);white-space:nowrap}
|
||||
.recent{display:grid;grid-template-columns:repeat(2,1fr);gap:2px 16px}
|
||||
.recent-item{display:flex;align-items:center;gap:12px;padding:8px 6px;border-radius:10px;transition:background .15s}
|
||||
|
||||
@@ -39,12 +39,13 @@ function renderActivity(activity) {
|
||||
const map = {};
|
||||
activity.forEach(a => { map[a.d] = a.n; });
|
||||
const days = last14days().map(iso => {
|
||||
return { iso, label: fmtDayMonthIso(iso), n: map[iso] || 0 };
|
||||
const dow = typeof isoDow === 'function' ? isoDow(iso) : -1;
|
||||
return { iso, label: fmtDayMonthIso(iso), n: map[iso] || 0, weekend: dow === 0 || dow === 6 };
|
||||
});
|
||||
const max = Math.max(1, ...days.map(x => x.n));
|
||||
const todayKey = todayIso();
|
||||
document.getElementById('activityChart').innerHTML = days.map(x => `
|
||||
<div class="bar-col" title="${x.iso} — ${x.n} ${plural(x.n, 'запись', 'записи', 'записей')}">
|
||||
<div class="bar-col ${x.weekend ? 'weekend' : ''}" title="${x.iso} — ${x.n} ${plural(x.n, 'запись', 'записи', 'записей')}">
|
||||
<div class="bar ${x.iso === todayKey ? 'today' : ''}" style="height:${Math.round(x.n / max * 100)}%"></div>
|
||||
<div class="bar-day">${x.label}</div>
|
||||
</div>`).join('');
|
||||
|
||||
@@ -105,6 +105,12 @@ function nowYear() {
|
||||
try { return new Intl.DateTimeFormat('en-CA', { timeZone: DateTime.tz, year: 'numeric' }).format(new Date()); } catch { return String(new Date().getFullYear()); }
|
||||
}
|
||||
|
||||
function isoDow(iso) {
|
||||
const p = dtIsoMatch(iso);
|
||||
if (!p) return -1;
|
||||
return new Date(Date.UTC(Number(p.y), Number(p.m) - 1, Number(p.d))).getUTCDay();
|
||||
}
|
||||
|
||||
function isoAddDays(iso, n) {
|
||||
const p = dtIsoMatch(iso);
|
||||
if (!p) return '';
|
||||
|
||||
Reference in New Issue
Block a user