Skip to content

Commit d4aa8ad

Browse files
committed
feat(StatsRoute): Improve layout
1 parent b5d0e82 commit d4aa8ad

1 file changed

Lines changed: 42 additions & 33 deletions

File tree

src/app/routes/stats/stats-route.tsx

Lines changed: 42 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,8 @@ const StatsModeHeader = ({
127127
</h2>
128128
)
129129

130-
export const StatsRoute = () => {
130+
const StatsCharts = ({ mode }: { mode: Mode }) => {
131131
const timeEntries = useAtomValue(timeEntriesData)
132-
const [mode, setMode] = useState<Mode>("weekday")
133132

134133
const data = {
135134
weekday: () => getDayStats(timeEntries),
@@ -151,47 +150,57 @@ export const StatsRoute = () => {
151150

152151
if (Object.values(data).length < 2) {
153152
return (
154-
<div className="grid h-full place-items-center">
153+
<div className="max-w-90 text-center">
155154
<ContextInfo
156155
animateIcon="rotate"
157156
icon={ClockPlus}
158-
label="You need to add more data first, to be able to see stats."
159-
/>
157+
label="Insufficient data"
158+
>
159+
You will need to add more data first, to be able to see stats here.
160+
(at least 2 {mode}s)
161+
</ContextInfo>
160162
</div>
161163
)
162164
}
163165

164166
return (
165-
<div className={cn(vstack({}), "h-full px-10 pt-6")}>
166-
<StatsModeHeader mode={mode} onChange={setMode} />
167+
<div className={cn(vstack({ gap: 8 }), "w-full max-w-xl gap-10 *:h-48")}>
168+
<TimeStatsChart
169+
caption="Start time"
170+
timeStats={data}
171+
type="start"
172+
dotLabel={({ y }) => timeHelpers.fromMinutes(y)}
173+
tickLabel={tick}
174+
transformX={transform}
175+
/>
176+
<TimeStatsChart
177+
caption="End time"
178+
timeStats={data}
179+
type="end"
180+
dotLabel={({ y }) => timeHelpers.fromMinutes(y)}
181+
tickLabel={tick}
182+
transformX={transform}
183+
/>
184+
<TimeStatsChart
185+
caption="Work time"
186+
timeStats={data}
187+
type="total"
188+
dotLabel={({ y }) => `${(y / 60).toFixed(1)}h`}
189+
tickLabel={tick}
190+
transformX={transform}
191+
/>
192+
</div>
193+
)
194+
}
167195

168-
<div className="grid auto-rows-[10rem] grid-cols-[repeat(auto-fit,minmax(30rem,1fr))] gap-10 *:h-full">
169-
<TimeStatsChart
170-
caption="Start time"
171-
timeStats={data}
172-
type="start"
173-
dotLabel={({ y }) => timeHelpers.fromMinutes(y)}
174-
tickLabel={tick}
175-
transformX={transform}
176-
/>
177-
<TimeStatsChart
178-
caption="End time"
179-
timeStats={data}
180-
type="end"
181-
dotLabel={({ y }) => timeHelpers.fromMinutes(y)}
182-
tickLabel={tick}
183-
transformX={transform}
184-
/>
185-
<TimeStatsChart
186-
caption="Work time"
187-
timeStats={data}
188-
type="total"
189-
dotLabel={({ y }) => `${(y / 60).toFixed(1)}h`}
190-
tickLabel={tick}
191-
transformX={transform}
192-
/>
193-
</div>
196+
export const StatsRoute = () => {
197+
const [mode, setMode] = useState<Mode>("weekday")
194198

199+
return (
200+
<div className={cn(vstack({ align: "center" }), "min-h-full px-10 pt-20")}>
201+
<StatsModeHeader mode={mode} onChange={setMode} />
202+
<div className="pb-8" />
203+
<StatsCharts mode={mode} />
195204
<div className="pb-8" />
196205
</div>
197206
)

0 commit comments

Comments
 (0)