From f1dc11111d767ac1335c2601299b0f6bd0ba46bc Mon Sep 17 00:00:00 2001 From: Terncode Date: Sat, 17 Oct 2026 11:27:41 +0200 Subject: [PATCH] Update style --- src/Base.css | 46 +++++- src/Charts.tsx | 4 +- src/Page.tsx | 75 +++++++++- src/Suggestions.tsx | 11 ++ src/Table.tsx | 346 +++++++++++++++++++++++++++++++++++++++++--- src/index.tsx | 2 +- src/theme.ts | 1 + 7 files changed, 458 insertions(+), 27 deletions(-) diff --git a/src/Base.css b/src/Base.css index d3188f3..7d14a9d 100644 --- a/src/Base.css +++ b/src/Base.css @@ -99,6 +99,26 @@ input::placeholder { color: var(--color-text-faint); } +@media (max-width: 640px) { + /* Prevent iOS from zooming on focus (inputs default below 16px) */ + input, + select, + textarea { + font-size: 16px; + min-height: 44px; + } + + button { + min-height: 44px; + } + + a, + button, + [role="button"] { + -webkit-tap-highlight-color: transparent; + } +} + button:focus-visible, input:focus-visible, select:focus-visible, @@ -138,4 +158,28 @@ input[type="month"]::-webkit-calendar-picker-indicator { margin: auto; width: 50%; padding: 10px; -} \ No newline at end of file +} + + +/* ---- Mobile: charts ---- */ +@media (max-width: 640px) { + .chart-scroll { + flex-direction: column; + align-items: stretch !important; + } + + .chart-scroll > div:first-child { + flex: none !important; + height: 260px !important; + min-width: 0 !important; + width: 100% !important; + } + + .chart-scroll > div:last-child { + width: 100% !important; + max-height: 240px !important; + border-left: none !important; + border-top: 1px solid var(--color-border); + padding-top: 8px !important; + } +} diff --git a/src/Charts.tsx b/src/Charts.tsx index 7856929..8555e80 100644 --- a/src/Charts.tsx +++ b/src/Charts.tsx @@ -63,10 +63,10 @@ export function CategoryGraphs({ data }: { data: Data[] }) { const sortedData = [...chartData].sort((a, b) => b.value - a.value); return ( -
+

{String(key).toUpperCase()}

- +
diff --git a/src/Page.tsx b/src/Page.tsx index 6a8448d..32e1f0e 100644 --- a/src/Page.tsx +++ b/src/Page.tsx @@ -29,6 +29,9 @@ const Header = styled.header` @media (max-width: ${theme.breakpoints.mobile}) { padding: ${theme.spacing.sm}px ${theme.spacing.md}px; + flex-direction: column; + align-items: stretch; + gap: ${theme.spacing.sm}px; } `; @@ -55,11 +58,56 @@ const Controls = styled.div` display: flex; align-items: center; gap: ${theme.spacing.sm}px; + flex-wrap: wrap; + justify-content: flex-end; + + @media (max-width: ${theme.breakpoints.mobile}) { + width: 100%; + justify-content: space-between; + gap: ${theme.spacing.xs}px; + } `; const MonthInput = styled.input.attrs({ type: "month" })` min-width: 150px; max-width: 200px; + + @media (max-width: ${theme.breakpoints.mobile}) { + max-width: none; + min-height: 44px; + min-width: 130px; + flex: 1; + } +`; + +const MonthNav = styled.div` + display: flex; + align-items: center; + gap: ${theme.spacing.xs}px; + + button { + min-width: 40px; + padding-left: 10px; + padding-right: 10px; + font-size: 1.25rem; + line-height: 1; + } + + @media (max-width: ${theme.breakpoints.mobile}) { + flex: 1 1 100%; + order: -1; + + button { + min-width: 48px; + min-height: 44px; + font-size: 1.4rem; + } + + input { + flex: 1; + min-width: 0; + } + } `; const Main = styled.main` @@ -82,6 +130,14 @@ const SummaryGrid = styled.section` display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: ${theme.spacing.md}px; + + @media (max-width: ${theme.breakpoints.mobileSmall}) { + grid-template-columns: repeat(2, 1fr); + + > *:first-child { + grid-column: 1 / -1; + } + } `; const StatCard = styled.div<{ hero?: boolean }>` @@ -92,6 +148,11 @@ const StatCard = styled.div<{ hero?: boolean }>` display: flex; flex-direction: column; gap: ${theme.spacing.xs}px; + min-width: 0; + + @media (max-width: ${theme.breakpoints.mobileSmall}) { + padding: ${theme.spacing.md}px; + } `; const StatLabel = styled.span` @@ -142,6 +203,14 @@ const ErrorTitle = styled.h2` const fmtMoney = (n: number) => Math.abs(n).toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 2 }); +function shiftMonth(month: string, delta: number): string { + const fallback = getMonth(); + const match = /^(\d{4})-(\d{2})$/.exec(month || fallback); + if (!match) return fallback; + const d = new Date(Number(match[1]), Number(match[2]) - 1 + delta, 1); + return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}`; +} + export function Page(props: { storage: WebsiteStorage, logout: () => void }) { const [month, setMonth] = useState(""); const [data, setData] = useState[]>([]); @@ -300,7 +369,11 @@ export function Page(props: { storage: WebsiteStorage, logout: () => void }) { {month} - ) => setDate(d.target.value)} /> + + + ) => setDate(d.target.value)} /> + + diff --git a/src/Suggestions.tsx b/src/Suggestions.tsx index 3ae987e..2fa0013 100644 --- a/src/Suggestions.tsx +++ b/src/Suggestions.tsx @@ -118,6 +118,12 @@ const IconButton = styled.button` &.danger { color: #ffb3a7; } + + @media (max-width: ${theme.breakpoints.mobile}) { + min-width: 44px; + min-height: 44px; + padding: 10px; + } `; const RowInput = styled.input` @@ -142,6 +148,11 @@ const Done = styled.button` font-weight: 600; padding: 12px 16px; border-radius: ${theme.radius.md}px; + + @media (max-width: ${theme.breakpoints.mobile}) { + flex: 1; + min-height: 48px; + } `; const Footer = styled.div` diff --git a/src/Table.tsx b/src/Table.tsx index bf06213..03166d3 100644 --- a/src/Table.tsx +++ b/src/Table.tsx @@ -130,6 +130,201 @@ const StyledTable = styled.table` input { width: 100%; min-width: 0; + min-height: 36px; + } + + @media (max-width: ${theme.breakpoints.mobile}) { + font-size: 0.875rem; + + thead { + display: none; + } + + table, + tbody, + tr, + td { + display: block; + width: 100%; + } + + tbody tr { + position: relative; + border-bottom: 1px solid ${theme.colors.border}; + padding: ${theme.spacing.sm}px ${theme.spacing.md}px ${theme.spacing.md}px; + } + + tbody tr:last-child { + border-bottom: none; + } + + tbody tr.frozen td { + background: transparent; + box-shadow: none; + } + + tbody tr.frozen { + background: rgba(91, 157, 255, 0.12); + box-shadow: inset 3px 0 0 ${theme.colors.accent}; + } + + tbody td { + border-bottom: none; + display: flex; + align-items: center; + justify-content: space-between; + gap: ${theme.spacing.sm}px; + padding: ${theme.spacing.xs}px 0; + min-height: 40px; + } + + tbody td::before { + content: attr(data-label); + flex: 0 0 auto; + font-size: ${theme.font.sizes.xxs}; + font-weight: 700; + text-transform: uppercase; + letter-spacing: 0.06em; + color: ${theme.colors.textMuted}; + } + + tbody td[data-label=""]::before { + content: none; + } + + tbody td > * { + margin-left: auto; + min-width: 0; + max-width: 70%; + text-align: right; + } + + tbody td:not(.amount):not(.actions) > * { + text-align: left; + flex: 1; + max-width: none; + margin-left: 0; + } + + tbody td.amount { + text-align: right; + font-size: ${theme.font.sizes.md}; + } + + tbody td.amount::before { + margin-right: auto; + margin-left: 0; + } + + .actions, + td.actions { + display: flex; + justify-content: flex-end; + gap: ${theme.spacing.sm}px; + padding-top: ${theme.spacing.sm}px; + min-height: 0; + } + + .actions button { + margin-left: 0; + margin-right: 0; + min-width: 48px; + min-height: 44px; + flex: 1; + max-width: 140px; + } + + input { + min-height: 44px; + font-size: 16px; + text-align: left; + } + + button { + min-height: 44px; + } + + tr.add-row { + background: ${theme.colors.surfaceAlt}; + border: 1px solid ${theme.colors.border}; + border-radius: ${theme.radius.md}px; + padding: ${theme.spacing.md}; + margin-top: ${theme.spacing.md}; + display: flex !important; + flex-direction: column; + gap: ${theme.spacing.xs}px; + width: auto; + } + + tr.add-row td { + flex-direction: column; + align-items: stretch; + gap: ${theme.spacing.xs}px; + min-height: 0; + padding: ${theme.spacing.xs}px 0; + } + + tr.add-row td > * { + max-width: none; + text-align: left; + margin-left: 0; + width: 100%; + } + + tr.add-row td.actions { + justify-content: stretch; + padding-top: ${theme.spacing.sm}px; + } + + tr.add-row td.actions button { + max-width: none; + width: 100%; + flex: none; + } + + tr.totals-row { + display: flex !important; + align-items: center; + justify-content: space-between; + gap: ${theme.spacing.sm}px; + background: ${theme.colors.surfaceAlt}; + border-top: 2px solid ${theme.colors.borderStrong}; + padding-top: ${theme.spacing.sm}px; + margin-top: ${theme.spacing.sm}px; + } + + tr.totals-row td { + display: block; + border-top: none; + padding: 0; + min-height: 0; + width: auto; + } + + tr.totals-row td.totals-label { + text-align: left; + border-top: none; + padding-top: 0; + } + + tr.totals-row td.totals-label::before { + content: none; + } + + tr.totals-row td.amount { + border-top: none; + padding-top: 0; + justify-content: flex-end; + font-size: ${theme.font.sizes.md}; + } + + tr.totals-row td.amount::before { + content: none; + } + + tr.totals-row td.actions { + display: none; + } } `; @@ -152,6 +347,13 @@ const TotalRow = styled.tr` padding-bottom: ${theme.spacing.md}px; } + @media (max-width: ${theme.breakpoints.mobile}) { + td { + padding-top: ${theme.spacing.sm}px; + padding-bottom: ${theme.spacing.sm}px; + } + } + td.totals-label { text-align: right; color: ${theme.colors.textMuted}; @@ -198,6 +400,55 @@ const TableToolbar = styled.div` border-bottom: 1px solid ${theme.colors.border}; color: ${theme.colors.textFaint}; font-size: ${theme.font.sizes.xs}; + + .hint { + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + } + + @media (max-width: ${theme.breakpoints.mobile}) { + justify-content: space-between; + font-size: ${theme.font.sizes.xs}; + padding: ${theme.spacing.sm}px ${theme.spacing.md}px; + + .hint { + display: none; + } + } + + @media (max-width: ${theme.breakpoints.mobileSmall}) { + font-size: ${theme.font.sizes.xxs}; + padding: ${theme.spacing.sm}px; + } +`; + +const MobileSort = styled.div` + display: none; + + @media (max-width: ${theme.breakpoints.mobile}) { + display: flex; + align-items: center; + gap: ${theme.spacing.xs}px; + + label { + font-weight: 700; + text-transform: uppercase; + letter-spacing: 0.06em; + color: ${theme.colors.textMuted}; + font-size: ${theme.font.sizes.xxs}; + } + + select { + min-height: 44px; + font-size: 16px; + background: ${theme.colors.surfaceAlt}; + color: ${theme.colors.text}; + border: 1px solid ${theme.colors.border}; + border-radius: ${theme.radius.sm}px; + padding: 0 ${theme.spacing.sm}px; + } + } `; const autoOptions = (list?: string[]) => list?.map((x, idx) =>