Update style
This commit is contained in:
1 parent
917effe259
commit
f1dc11111d
7 files changed
+458
-27
No files matched your search
+45
-1
@@ -99,6 +99,26 @@ input::placeholder {
|
|||||||
color: var(--color-text-faint);
|
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,
|
button:focus-visible,
|
||||||
input:focus-visible,
|
input:focus-visible,
|
||||||
select:focus-visible,
|
select:focus-visible,
|
||||||
@@ -138,4 +158,28 @@ input[type="month"]::-webkit-calendar-picker-indicator {
|
|||||||
margin: auto;
|
margin: auto;
|
||||||
width: 50%;
|
width: 50%;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* ---- 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
+2
-2
@@ -63,10 +63,10 @@ export function CategoryGraphs({ data }: { data: Data<Date>[] }) {
|
|||||||
const sortedData = [...chartData].sort((a, b) => b.value - a.value);
|
const sortedData = [...chartData].sort((a, b) => b.value - a.value);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div key={String(key)} style={{ width: "100%" }}>
|
<div key={String(key)} className="chart-block" style={{ width: "100%" }}>
|
||||||
<h3 style={{ margin: `${theme.spacing.sm}px 0`, color: theme.colors.text }}>{String(key).toUpperCase()}</h3>
|
<h3 style={{ margin: `${theme.spacing.sm}px 0`, color: theme.colors.text }}>{String(key).toUpperCase()}</h3>
|
||||||
|
|
||||||
<Scrollbar style={{ display: "flex", alignItems: "flex-start", gap: theme.spacing.lg }}>
|
<Scrollbar className="chart-scroll" style={{ display: "flex", alignItems: "flex-start", gap: theme.spacing.lg, flexWrap: "wrap" }}>
|
||||||
<div style={{ flex: "1 1 0%", height: 340, minWidth: 240 }}>
|
<div style={{ flex: "1 1 0%", height: 340, minWidth: 240 }}>
|
||||||
<ResponsiveContainer width="100%" height="100%">
|
<ResponsiveContainer width="100%" height="100%">
|
||||||
<PieChart>
|
<PieChart>
|
||||||
|
|||||||
+74
-1
@@ -29,6 +29,9 @@ const Header = styled.header`
|
|||||||
|
|
||||||
@media (max-width: ${theme.breakpoints.mobile}) {
|
@media (max-width: ${theme.breakpoints.mobile}) {
|
||||||
padding: ${theme.spacing.sm}px ${theme.spacing.md}px;
|
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;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: ${theme.spacing.sm}px;
|
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" })`
|
const MonthInput = styled.input.attrs({ type: "month" })`
|
||||||
min-width: 150px;
|
min-width: 150px;
|
||||||
max-width: 200px;
|
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`
|
const Main = styled.main`
|
||||||
@@ -82,6 +130,14 @@ const SummaryGrid = styled.section`
|
|||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
|
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
|
||||||
gap: ${theme.spacing.md}px;
|
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 }>`
|
const StatCard = styled.div<{ hero?: boolean }>`
|
||||||
@@ -92,6 +148,11 @@ const StatCard = styled.div<{ hero?: boolean }>`
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: ${theme.spacing.xs}px;
|
gap: ${theme.spacing.xs}px;
|
||||||
|
min-width: 0;
|
||||||
|
|
||||||
|
@media (max-width: ${theme.breakpoints.mobileSmall}) {
|
||||||
|
padding: ${theme.spacing.md}px;
|
||||||
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const StatLabel = styled.span`
|
const StatLabel = styled.span`
|
||||||
@@ -142,6 +203,14 @@ const ErrorTitle = styled.h2`
|
|||||||
const fmtMoney = (n: number) =>
|
const fmtMoney = (n: number) =>
|
||||||
Math.abs(n).toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 2 });
|
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 }) {
|
export function Page(props: { storage: WebsiteStorage, logout: () => void }) {
|
||||||
const [month, setMonth] = useState("");
|
const [month, setMonth] = useState("");
|
||||||
const [data, setData] = useState<Data<Date>[]>([]);
|
const [data, setData] = useState<Data<Date>[]>([]);
|
||||||
@@ -300,7 +369,11 @@ export function Page(props: { storage: WebsiteStorage, logout: () => void }) {
|
|||||||
<MonthBadge>{month}</MonthBadge>
|
<MonthBadge>{month}</MonthBadge>
|
||||||
</Brand>
|
</Brand>
|
||||||
<Controls>
|
<Controls>
|
||||||
<MonthInput aria-label="Select month" value={month} onChange={(d: ChangeEvent<HTMLInputElement>) => setDate(d.target.value)} />
|
<MonthNav>
|
||||||
|
<button onClick={() => setDate(shiftMonth(month, -1))} aria-label="Previous month" title="Previous month">‹</button>
|
||||||
|
<MonthInput aria-label="Select month" value={month} onChange={(d: ChangeEvent<HTMLInputElement>) => setDate(d.target.value)} />
|
||||||
|
<button onClick={() => setDate(shiftMonth(month, 1))} aria-label="Next month" title="Next month">›</button>
|
||||||
|
</MonthNav>
|
||||||
<button onClick={undo} disabled={past.length === 0} aria-label="Undo" title="Undo (Ctrl+Z)">Undo</button>
|
<button onClick={undo} disabled={past.length === 0} aria-label="Undo" title="Undo (Ctrl+Z)">Undo</button>
|
||||||
<button onClick={redo} disabled={future.length === 0} aria-label="Redo" title="Redo (Ctrl+Y)">Redo</button>
|
<button onClick={redo} disabled={future.length === 0} aria-label="Redo" title="Redo (Ctrl+Y)">Redo</button>
|
||||||
<button onClick={() => setSuggestionsOpen(true)}>Suggestions</button>
|
<button onClick={() => setSuggestionsOpen(true)}>Suggestions</button>
|
||||||
|
|||||||
@@ -118,6 +118,12 @@ const IconButton = styled.button`
|
|||||||
&.danger {
|
&.danger {
|
||||||
color: #ffb3a7;
|
color: #ffb3a7;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media (max-width: ${theme.breakpoints.mobile}) {
|
||||||
|
min-width: 44px;
|
||||||
|
min-height: 44px;
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const RowInput = styled.input`
|
const RowInput = styled.input`
|
||||||
@@ -142,6 +148,11 @@ const Done = styled.button`
|
|||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
padding: 12px 16px;
|
padding: 12px 16px;
|
||||||
border-radius: ${theme.radius.md}px;
|
border-radius: ${theme.radius.md}px;
|
||||||
|
|
||||||
|
@media (max-width: ${theme.breakpoints.mobile}) {
|
||||||
|
flex: 1;
|
||||||
|
min-height: 48px;
|
||||||
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const Footer = styled.div`
|
const Footer = styled.div`
|
||||||
|
|||||||
+324
-22
@@ -130,6 +130,201 @@ const StyledTable = styled.table`
|
|||||||
input {
|
input {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
min-width: 0;
|
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;
|
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 {
|
td.totals-label {
|
||||||
text-align: right;
|
text-align: right;
|
||||||
color: ${theme.colors.textMuted};
|
color: ${theme.colors.textMuted};
|
||||||
@@ -198,6 +400,55 @@ const TableToolbar = styled.div`
|
|||||||
border-bottom: 1px solid ${theme.colors.border};
|
border-bottom: 1px solid ${theme.colors.border};
|
||||||
color: ${theme.colors.textFaint};
|
color: ${theme.colors.textFaint};
|
||||||
font-size: ${theme.font.sizes.xs};
|
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) => <option key={`${x}-${idx}`} value={x} />);
|
const autoOptions = (list?: string[]) => list?.map((x, idx) => <option key={`${x}-${idx}`} value={x} />);
|
||||||
@@ -316,7 +567,20 @@ export function Table({ month, data, onChange, autosuggestions, updateAutoSugges
|
|||||||
|
|
||||||
return <TableWrapper>
|
return <TableWrapper>
|
||||||
<TableToolbar>
|
<TableToolbar>
|
||||||
<span>Click a value to edit · Enter to save · Esc to cancel</span>
|
<MobileSort>
|
||||||
|
<label htmlFor="mobile-sort">Sort</label>
|
||||||
|
<select id="mobile-sort" value={`${sortBy.type}-${sortBy.acs ? "asc" : "desc"}`}
|
||||||
|
onChange={ev => {
|
||||||
|
const [type, dir] = ev.target.value.split("-");
|
||||||
|
sortByAction(type as SortType, dir === "asc");
|
||||||
|
}}>
|
||||||
|
{HEADERS.flatMap(k => [
|
||||||
|
<option key={`${k}-asc`} value={`${k}-asc`}>{k} ↑</option>,
|
||||||
|
<option key={`${k}-desc`} value={`${k}-desc`}>{k} ↓</option>,
|
||||||
|
])}
|
||||||
|
</select>
|
||||||
|
</MobileSort>
|
||||||
|
<span className="hint">Tap a value to edit · Enter to save</span>
|
||||||
</TableToolbar>
|
</TableToolbar>
|
||||||
<TableScroll>
|
<TableScroll>
|
||||||
<StyledTable>
|
<StyledTable>
|
||||||
@@ -368,12 +632,12 @@ export function Table({ month, data, onChange, autosuggestions, updateAutoSugges
|
|||||||
}
|
}
|
||||||
}} />;
|
}} />;
|
||||||
})}
|
})}
|
||||||
<TotalRow>
|
<TotalRow className="totals-row">
|
||||||
<td colSpan={4} className="totals-label">Total</td>
|
<td colSpan={4} className="totals-label" data-label="">Total</td>
|
||||||
<td className="amount">
|
<td className="amount" data-label="">
|
||||||
<Amount tone={amountTone(sum)}>{formatSigned(sum)}</Amount>
|
<Amount tone={amountTone(sum)}>{formatSigned(sum)}</Amount>
|
||||||
</td>
|
</td>
|
||||||
<td className="actions" />
|
<td className="actions" data-label="" />
|
||||||
</TotalRow>
|
</TotalRow>
|
||||||
<Add
|
<Add
|
||||||
modifySuggestions={modifySuggestions}
|
modifySuggestions={modifySuggestions}
|
||||||
@@ -502,14 +766,14 @@ function Row({ row, onUpdate, onRemove, autosuggestions, updateAutoSuggestions,
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<tr ref={rowRef} className={frozen ? "frozen" : ""}>
|
<tr ref={rowRef} className={frozen ? "frozen" : ""}>
|
||||||
<td>{editing?.field === "date" ? editableInput() : viewCell("date", row.date.toLocaleDateString())}</td>
|
<td data-label="Date">{editing?.field === "date" ? editableInput() : viewCell("date", row.date.toLocaleDateString())}</td>
|
||||||
<td>{editing?.field === "name" ? editableInput() : viewCell("name", row.name)}</td>
|
<td data-label="Name">{editing?.field === "name" ? editableInput() : viewCell("name", row.name)}</td>
|
||||||
<td>{editing?.field === "location" ? editableInput() : viewCell("location", row.location)}</td>
|
<td data-label="Location">{editing?.field === "location" ? editableInput() : viewCell("location", row.location)}</td>
|
||||||
<td>{editing?.field === "category" ? editableInput() : viewCell("category", row.category)}</td>
|
<td data-label="Category">{editing?.field === "category" ? editableInput() : viewCell("category", row.category)}</td>
|
||||||
<td className="amount">
|
<td className="amount" data-label="Amount">
|
||||||
{editing?.field === "amount" ? editableInput() : viewCell("amount", <Amount tone={amountTone(row.amount)}>{formatSigned(row.amount)}</Amount>)}
|
{editing?.field === "amount" ? editableInput() : viewCell("amount", <Amount tone={amountTone(row.amount)}>{formatSigned(row.amount)}</Amount>)}
|
||||||
</td>
|
</td>
|
||||||
<td className="actions">
|
<td className="actions" data-label="">
|
||||||
{confirm && <button className="danger" onClick={() => { onRemove(row); setConfirm(false); }} aria-label="Confirm delete" title="Confirm delete"><FontAwesomeIcon icon={faCheck} /></button>}
|
{confirm && <button className="danger" onClick={() => { onRemove(row); setConfirm(false); }} aria-label="Confirm delete" title="Confirm delete"><FontAwesomeIcon icon={faCheck} /></button>}
|
||||||
<button className="danger" onClick={() => setConfirm(!confirm)} aria-label="Delete" title="Delete"><FontAwesomeIcon icon={faTimes} /></button>
|
<button className="danger" onClick={() => setConfirm(!confirm)} aria-label="Delete" title="Delete"><FontAwesomeIcon icon={faTimes} /></button>
|
||||||
</td>
|
</td>
|
||||||
@@ -531,6 +795,20 @@ function Add({ month, onPost, autosuggestions, updateAutoSuggestions, modifySugg
|
|||||||
const [amount, setAmount] = useState("");
|
const [amount, setAmount] = useState("");
|
||||||
const [ canPost, setCanPost ] = useState(false);
|
const [ canPost, setCanPost ] = useState(false);
|
||||||
|
|
||||||
|
const dateRef = useRef<HTMLInputElement>(null);
|
||||||
|
const nameRef = useRef<HTMLInputElement>(null);
|
||||||
|
const locationRef = useRef<HTMLInputElement>(null);
|
||||||
|
const categoryRef = useRef<HTMLInputElement>(null);
|
||||||
|
const amountRef = useRef<HTMLInputElement>(null);
|
||||||
|
|
||||||
|
const previousInput: Record<EditField, React.RefObject<HTMLInputElement> | null> = {
|
||||||
|
date: null,
|
||||||
|
name: dateRef,
|
||||||
|
location: nameRef,
|
||||||
|
category: locationRef,
|
||||||
|
amount: categoryRef,
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setDate(defaultAddDate(month));
|
setDate(defaultAddDate(month));
|
||||||
}, [month]);
|
}, [month]);
|
||||||
@@ -562,9 +840,27 @@ function Add({ month, onPost, autosuggestions, updateAutoSuggestions, modifySugg
|
|||||||
setLocation("");
|
setLocation("");
|
||||||
setCategory("");
|
setCategory("");
|
||||||
setAmount("");
|
setAmount("");
|
||||||
|
nameRef.current?.focus();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const onKeyDown = (field: EditField) => (ev: React.KeyboardEvent<HTMLInputElement>) => {
|
||||||
|
if (ev.key === "Enter") {
|
||||||
|
post();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (ev.key !== "Backspace") return;
|
||||||
|
|
||||||
|
const el = ev.currentTarget;
|
||||||
|
const hasSelection = el.selectionStart !== el.selectionEnd;
|
||||||
|
if (el.value !== "" || hasSelection) return;
|
||||||
|
|
||||||
|
const target = previousInput[field];
|
||||||
|
if (!target?.current) return;
|
||||||
|
ev.preventDefault();
|
||||||
|
target.current.focus();
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const val = amount ? evaluateMathExpression(amount) ?? parseFloat(amount) : NaN;
|
const val = amount ? evaluateMathExpression(amount) ?? parseFloat(amount) : NaN;
|
||||||
setCanPost(!!(name && location && category && amount && !isNaN(val)));
|
setCanPost(!!(name && location && category && amount && !isNaN(val)));
|
||||||
@@ -580,59 +876,65 @@ function Add({ month, onPost, autosuggestions, updateAutoSuggestions, modifySugg
|
|||||||
return val !== null && !isNaN(val) ? val.toFixed(2) : null;
|
return val !== null && !isNaN(val) ? val.toFixed(2) : null;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
return <tr>
|
return <tr className="add-row">
|
||||||
<td>
|
<td data-label="Date">
|
||||||
<input
|
<input
|
||||||
type="date"
|
type="date"
|
||||||
aria-label="Date"
|
aria-label="Date"
|
||||||
|
ref={dateRef}
|
||||||
value={date}
|
value={date}
|
||||||
|
onKeyDown={onKeyDown("date")}
|
||||||
onChange={ev => sDate(ev.target.value)} />
|
onChange={ev => sDate(ev.target.value)} />
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td data-label="Name">
|
||||||
<input
|
<input
|
||||||
list="names"
|
list="names"
|
||||||
aria-label="Name"
|
aria-label="Name"
|
||||||
|
ref={nameRef}
|
||||||
onDoubleClick={() => editAutoSuggestions("name")}
|
onDoubleClick={() => editAutoSuggestions("name")}
|
||||||
value={name}
|
value={name}
|
||||||
onKeyDown={ev => ev.key === "Enter" && post()}
|
onKeyDown={onKeyDown("name")}
|
||||||
onChange={ev => setName(ev.target.value)}
|
onChange={ev => setName(ev.target.value)}
|
||||||
placeholder="Name" />
|
placeholder="Name" />
|
||||||
<datalist id="names">{autoOptions(names)}</datalist>
|
<datalist id="names">{autoOptions(names)}</datalist>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td data-label="Location">
|
||||||
<input
|
<input
|
||||||
aria-label="Location"
|
aria-label="Location"
|
||||||
|
ref={locationRef}
|
||||||
onDoubleClick={() => editAutoSuggestions("location")}
|
onDoubleClick={() => editAutoSuggestions("location")}
|
||||||
list="locations"
|
list="locations"
|
||||||
value={location}
|
value={location}
|
||||||
onKeyDown={ev => ev.key === "Enter" && post()}
|
onKeyDown={onKeyDown("location")}
|
||||||
onChange={ev => setLocation(ev.target.value)}
|
onChange={ev => setLocation(ev.target.value)}
|
||||||
placeholder="Location" />
|
placeholder="Location" />
|
||||||
<datalist id="locations">{autoOptions(locations)}</datalist>
|
<datalist id="locations">{autoOptions(locations)}</datalist>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td data-label="Category">
|
||||||
<input
|
<input
|
||||||
aria-label="Category"
|
aria-label="Category"
|
||||||
|
ref={categoryRef}
|
||||||
onDoubleClick={() => editAutoSuggestions("category")}
|
onDoubleClick={() => editAutoSuggestions("category")}
|
||||||
list="categories"
|
list="categories"
|
||||||
value={category}
|
value={category}
|
||||||
onKeyDown={ev => ev.key === "Enter" && post()}
|
onKeyDown={onKeyDown("category")}
|
||||||
onChange={ev => setCategory(ev.target.value)}
|
onChange={ev => setCategory(ev.target.value)}
|
||||||
placeholder="Category" />
|
placeholder="Category" />
|
||||||
<datalist id="categories">{autoOptions(categories)}</datalist>
|
<datalist id="categories">{autoOptions(categories)}</datalist>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td className="amount" data-label="Amount">
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
inputMode="decimal"
|
inputMode="decimal"
|
||||||
aria-label="Amount"
|
aria-label="Amount"
|
||||||
|
ref={amountRef}
|
||||||
value={amount}
|
value={amount}
|
||||||
onKeyDown={ev => ev.key === "Enter" && post()}
|
onKeyDown={onKeyDown("amount")}
|
||||||
onChange={ev => setAmount(ev.target.value)}
|
onChange={ev => setAmount(ev.target.value)}
|
||||||
placeholder="Amount" />
|
placeholder="Amount" />
|
||||||
<span style={{ display: "block", lineHeight: 1.4, fontSize: `${theme.font.sizes.xs}`, color: theme.colors.textMuted }}>{amountPreview?.trim() || "0"}</span>
|
<span style={{ display: "block", lineHeight: 1.4, fontSize: `${theme.font.sizes.xs}`, color: theme.colors.textMuted }}>{amountPreview?.trim() || "0"}</span>
|
||||||
</td>
|
</td>
|
||||||
<td className="actions">
|
<td className="actions" data-label="">
|
||||||
<button className="primary" disabled={!canPost} onClick={post} aria-label="Add transaction">
|
<button className="primary" disabled={!canPost} onClick={post} aria-label="Add transaction">
|
||||||
<FontAwesomeIcon icon={faCheck} /> Add
|
<FontAwesomeIcon icon={faCheck} /> Add
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@ const root = ReactDOM.createRoot(
|
|||||||
document.getElementById('root') as HTMLElement
|
document.getElementById('root') as HTMLElement
|
||||||
);
|
);
|
||||||
|
|
||||||
const baseUrl = "https://flog.lidcer.dev"
|
const baseUrl = origin
|
||||||
|
|
||||||
root.render(
|
root.render(
|
||||||
<React.StrictMode>
|
<React.StrictMode>
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ export const theme = {
|
|||||||
},
|
},
|
||||||
breakpoints: {
|
breakpoints: {
|
||||||
mobile: "640px",
|
mobile: "640px",
|
||||||
|
mobileSmall: "480px",
|
||||||
tablet: "960px",
|
tablet: "960px",
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
Reference in new issue
Block a user