Multi-month samples, page breathing room (v4)
This commit is contained in:
35
app.js
35
app.js
@@ -160,24 +160,49 @@ function save(list) {
|
||||
/* Sample data relative to today so every view has content on first run. */
|
||||
function seedSamples() {
|
||||
var t = todayStr();
|
||||
var first = t.slice(0, 8) + "01";
|
||||
var tp = t.split("-");
|
||||
function monthFirst(offset) {
|
||||
return toStr(new Date(+tp[0], +tp[1] - 1 + offset, 1));
|
||||
}
|
||||
function monthDay(offset, day) {
|
||||
return toStr(new Date(+tp[0], +tp[1] - 1 + offset, Math.min(day, 28)));
|
||||
}
|
||||
function mk(desc, amount, cat, date, freq) {
|
||||
return { id: uid(), description: desc, amount: amount, category: cat, date: date, frequency: freq || "once", lastLogged: null, createdAt: Date.now() };
|
||||
}
|
||||
return [
|
||||
/* this month */
|
||||
mk("Groceries", 54.2, "Food", t),
|
||||
mk("Bus pass", 28.0, "Transport", t, "monthly"),
|
||||
mk("Coffee", 4.5, "Food", addDaysStr(t, -1)),
|
||||
mk("Pharmacy", 12.75, "Health", addDaysStr(t, -2)),
|
||||
mk("Electricity bill", 85.4, "Utilities", addDaysStr(t, -3), "monthly"),
|
||||
mk("Movie night", 16.0, "Entertainment", addDaysStr(t, -5)),
|
||||
mk("Gym", 35.0, "Health", addDaysStr(t, -6), "monthly"),
|
||||
mk("Gym", 35.0, "Health", addDaysStr(t, -7), "monthly"),
|
||||
mk("Haircut", 25.0, "Beauty", addDaysStr(t, -6)),
|
||||
mk("New shoes", 79.99, "Shopping", addDaysStr(t, -8)),
|
||||
mk("Team lunch", 13.4, "Food", addDaysStr(t, -9), "weekly"),
|
||||
mk("Internet", 59.99, "Utilities", addDaysStr(t, -12), "monthly"),
|
||||
mk("Rent", 1200.0, "Household", first, "monthly"),
|
||||
mk("Concert ticket", 45.0, "Entertainment", addDaysStr(t, -20)),
|
||||
mk("Groceries", 62.1, "Food", addDaysStr(t, -33))
|
||||
mk("Rent", 1200.0, "Household", monthFirst(0), "monthly"),
|
||||
/* last month */
|
||||
mk("Rent", 1200.0, "Household", monthFirst(-1)),
|
||||
mk("Internet", 59.99, "Utilities", monthDay(-1, 12)),
|
||||
mk("Groceries", 48.7, "Food", monthDay(-1, 8)),
|
||||
mk("Concert ticket", 45.0, "Entertainment", monthDay(-1, 21)),
|
||||
mk("Skincare", 22.5, "Beauty", monthDay(-1, 17)),
|
||||
mk("Doctor visit", 60.0, "Health", monthDay(-1, 25)),
|
||||
/* two months ago */
|
||||
mk("Rent", 1200.0, "Household", monthFirst(-2)),
|
||||
mk("Electricity bill", 82.1, "Utilities", monthDay(-2, 10)),
|
||||
mk("Groceries", 51.3, "Food", monthDay(-2, 6)),
|
||||
mk("Bus pass", 28.0, "Transport", monthDay(-2, 2)),
|
||||
mk("Face cream", 18.75, "Beauty", monthDay(-2, 19)),
|
||||
mk("Dinner out", 34.5, "Food", monthDay(-2, 23)),
|
||||
/* three months ago */
|
||||
mk("Rent", 1200.0, "Household", monthFirst(-3)),
|
||||
mk("Groceries", 49.9, "Food", monthDay(-3, 11)),
|
||||
mk("Gym", 35.0, "Health", monthDay(-3, 5)),
|
||||
mk("Movie night", 14.0, "Entertainment", monthDay(-3, 16))
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -151,8 +151,14 @@ export function groupTitle(key, tab) {
|
||||
/* Sample data relative to today so every view has content on first run. */
|
||||
export function seedSamples() {
|
||||
const t = todayStr();
|
||||
const first = t.slice(0, 8) + "01";
|
||||
const tp = t.split("-");
|
||||
const now = Date.now();
|
||||
function monthFirst(offset) {
|
||||
return toDateStr(new Date(+tp[0], +tp[1] - 1 + offset, 1));
|
||||
}
|
||||
function monthDay(offset, day) {
|
||||
return toDateStr(new Date(+tp[0], +tp[1] - 1 + offset, Math.min(day, 28)));
|
||||
}
|
||||
function mk(desc, amount, cat, date, freq) {
|
||||
return {
|
||||
id: uid() + Math.floor(Math.random() * 1e6).toString(36),
|
||||
@@ -166,18 +172,37 @@ export function seedSamples() {
|
||||
};
|
||||
}
|
||||
return [
|
||||
/* this month */
|
||||
mk("Groceries", 54.2, "Food", t),
|
||||
mk("Bus pass", 28.0, "Transport", t, "monthly"),
|
||||
mk("Coffee", 4.5, "Food", addDaysStr(t, -1)),
|
||||
mk("Pharmacy", 12.75, "Health", addDaysStr(t, -2)),
|
||||
mk("Electricity bill", 85.4, "Utilities", addDaysStr(t, -3), "monthly"),
|
||||
mk("Movie night", 16.0, "Entertainment", addDaysStr(t, -5)),
|
||||
mk("Gym", 35.0, "Health", addDaysStr(t, -6), "monthly"),
|
||||
mk("Gym", 35.0, "Health", addDaysStr(t, -7), "monthly"),
|
||||
mk("Haircut", 25.0, "Beauty", addDaysStr(t, -6)),
|
||||
mk("New shoes", 79.99, "Shopping", addDaysStr(t, -8)),
|
||||
mk("Team lunch", 13.4, "Food", addDaysStr(t, -9), "weekly"),
|
||||
mk("Internet", 59.99, "Utilities", addDaysStr(t, -12), "monthly"),
|
||||
mk("Rent", 1200.0, "Household", first, "monthly"),
|
||||
mk("Concert ticket", 45.0, "Entertainment", addDaysStr(t, -20)),
|
||||
mk("Groceries", 62.1, "Food", addDaysStr(t, -33)),
|
||||
mk("Rent", 1200.0, "Household", monthFirst(0), "monthly"),
|
||||
/* last month */
|
||||
mk("Rent", 1200.0, "Household", monthFirst(-1)),
|
||||
mk("Internet", 59.99, "Utilities", monthDay(-1, 12)),
|
||||
mk("Groceries", 48.7, "Food", monthDay(-1, 8)),
|
||||
mk("Concert ticket", 45.0, "Entertainment", monthDay(-1, 21)),
|
||||
mk("Skincare", 22.5, "Beauty", monthDay(-1, 17)),
|
||||
mk("Doctor visit", 60.0, "Health", monthDay(-1, 25)),
|
||||
/* two months ago */
|
||||
mk("Rent", 1200.0, "Household", monthFirst(-2)),
|
||||
mk("Electricity bill", 82.1, "Utilities", monthDay(-2, 10)),
|
||||
mk("Groceries", 51.3, "Food", monthDay(-2, 6)),
|
||||
mk("Bus pass", 28.0, "Transport", monthDay(-2, 2)),
|
||||
mk("Face cream", 18.75, "Beauty", monthDay(-2, 19)),
|
||||
mk("Dinner out", 34.5, "Food", monthDay(-2, 23)),
|
||||
/* three months ago */
|
||||
mk("Rent", 1200.0, "Household", monthFirst(-3)),
|
||||
mk("Groceries", 49.9, "Food", monthDay(-3, 11)),
|
||||
mk("Gym", 35.0, "Health", monthDay(-3, 5)),
|
||||
mk("Movie night", 14.0, "Entertainment", monthDay(-3, 16)),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Petit+Formal+Script&family=Shadows+Into+Light+Two&family=Style+Script&family=Waterfall&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" href="styles.css?v=3">
|
||||
<link rel="stylesheet" href="styles.css?v=4">
|
||||
<link rel="manifest" href="manifest.json">
|
||||
<meta name="theme-color" content="#ff6fae">
|
||||
<meta name="mobile-web-app-capable" content="yes">
|
||||
@@ -167,7 +167,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="app.js?v=3"></script>
|
||||
<script src="app.js?v=4"></script>
|
||||
<button type="button" id="btnUpdate" class="update-pill" hidden>Update to latest version</button>
|
||||
<script>
|
||||
(function () {
|
||||
|
||||
@@ -121,7 +121,7 @@ body.nav-open .side { transform: none; }
|
||||
/* (Currency is INR-only; no picker.) */
|
||||
|
||||
/* Layout: single centered column; the sidebar is an off-canvas drawer. */
|
||||
.layout { display: grid; grid-template-columns: 1fr; gap: 18px; padding-top: 20px; padding-bottom: 40px; align-items: start; }
|
||||
.layout { display: grid; grid-template-columns: 1fr; gap: 18px; padding-top: 32px; padding-bottom: 88px; padding-bottom: calc(88px + env(safe-area-inset-bottom)); align-items: start; }
|
||||
.side { display: grid; gap: 14px; align-content: start; }
|
||||
.content { display: grid; gap: 18px; min-width: 0; max-width: 720px; width: 100%; margin: 0 auto; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user