Skip to content

Commit a40832d

Browse files
authored
fix(export): pdf export and styling (#72)
1 parent 25c9077 commit a40832d

File tree

5 files changed

+36
-40
lines changed

5 files changed

+36
-40
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "timetrack",
3-
"version": "5.10.0",
3+
"version": "5.10.1",
44
"description": "Simple desktop application to track your time spent on different projects.",
55
"main": "./out/main/index.js",
66
"author": {

src/database.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,7 @@ const getDataForPDFExport = async (
597597

598598
const res = await db
599599
.select({
600+
id: task.id,
600601
name: taskDefinition.name,
601602
projectName: project.name,
602603
companyName: company.name,
@@ -632,6 +633,7 @@ const getDataForPDFExport = async (
632633
const seconds = Math.max(0, t.durationSeconds ?? 0)
633634

634635
return {
636+
id: t.id,
635637
name: t.name,
636638
projectName: t.projectName,
637639
companyName: t.companyName,

src/global.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ type PDFTotalObject = {
1717
}
1818

1919
type PDFQueryResult = {
20+
id: number
2021
date: string
2122
description: string
2223
name: string

src/renderer/src/components/PDFDocument.svelte

Lines changed: 31 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -29,42 +29,29 @@
2929
})()
3030
</script>
3131

32-
<div class="space-y-4 print:space-y-2">
33-
<!-- Header -->
34-
<section class="hero bg-base-200 rounded-lg p-8 print:p-4 print:bg-white">
35-
<div class="hero-content text-center">
36-
<div>
37-
<h1 class="text-4xl font-bold print:text-2xl">
38-
<a href="https://timetrack.mwco.app">timetrack</a>
39-
</h1>
40-
</div>
41-
</div>
42-
</section>
43-
32+
<div class="space-y-2">
4433
<!-- Tasks List -->
45-
{#each pdfDocument as item (`${item.companyName}-${item.projectName}-${item.name}-${item.date}`)}
46-
<div
47-
class="card bg-base-200 shadow-xl print:bg-white print:shadow-none print:border print:border-gray-300"
48-
>
49-
<div class="card-body print:p-4">
50-
<h3 class="text-sm font-semibold text-base-content/70 print:text-xs">
34+
{#each pdfDocument as item (item.id)}
35+
<div class="card shadow-xl border">
36+
<div class="card-body p-4">
37+
<h3 class="font-semibold text-xs">
5138
{item.companyName}
5239
</h3>
53-
<h2 class="card-title print:text-xl">{item.projectName}</h2>
54-
<p class="text-lg font-semibold print:text-base">{item.name}</p>
40+
<h2 class="card-title text-xl">{item.projectName}</h2>
41+
<p class="font-semibold text-base">{item.name}</p>
5542
{#if item.description}
56-
<div class="prose max-w-none markdown-content print:text-sm">
43+
<div class="prose max-w-none markdown-content text-sm">
5744
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
5845
{@html item.description}
5946
</div>
6047
{/if}
61-
<div class="flex gap-4 mt-2 print:text-sm">
48+
<div class="flex gap-4 mt-2 text-sm">
6249
<div class="flex items-center gap-2">
63-
<i class="fa-solid fa-calendar print:hidden"></i>
50+
<i class="fa-solid fa-calendar hidden"></i>
6451
<time datetime={item.date}>{item.date}</time>
6552
</div>
6653
<div class="flex items-center gap-2">
67-
<i class="fa-solid fa-clock print:hidden"></i>
54+
<i class="fa-solid fa-clock hidden"></i>
6855
<span>Time spent: {getHMSStringFromSeconds(item.seconds)}</span>
6956
</div>
7057
</div>
@@ -73,37 +60,31 @@
7360
{/each}
7461

7562
<!-- Total View -->
76-
<section
77-
class="hero bg-base-200 rounded-lg p-8 print:p-4 print:bg-white print:mt-8"
78-
>
63+
<section class="hero rounded-lg p-4 mt-8">
7964
<div class="hero-content">
8065
<div>
81-
<h2 class="text-3xl font-bold print:text-xl">Total Time</h2>
82-
<p class="text-lg mt-2 print:text-sm">
66+
<h2 class="font-bold text-xl">Total Time</h2>
67+
<p class="mt-2 text-sm">
8368
Total time spent on projects and tasks combined.
8469
</p>
8570
</div>
8671
</div>
8772
</section>
8873

8974
{#each Object.keys(total) as companyName (companyName)}
90-
<div
91-
class="card bg-base-200 shadow-xl print:bg-white print:shadow-none print:border print:border-gray-300"
92-
>
93-
<div class="card-body print:p-4">
94-
<h2 class="card-title print:text-xl">{companyName}</h2>
75+
<div class="card shadow-xl border">
76+
<div class="card-body p-4">
77+
<h2 class="card-title text-xl">{companyName}</h2>
9578
{#each Object.keys(total[companyName]) as projectName (projectName)}
9679
<div class="mt-4">
97-
<h3 class="text-lg font-semibold print:text-base mb-2">
80+
<h3 class="font-semibold text-base mb-2">
9881
{projectName}
9982
</h3>
100-
<div class="space-y-2 print:text-sm ml-4">
83+
<div class="space-y-2 text-sm ml-4">
10184
{#each Object.keys(total[companyName][projectName]) as taskName (taskName)}
10285
<div class="flex justify-between items-center">
10386
<span class="font-semibold">{taskName}</span>
104-
<span
105-
class="badge badge-primary badge-lg print:badge-sm print:bg-gray-200 print:text-gray-800"
106-
>
87+
<span class="badge badge-primary badge-sm text-base">
10788
{getHMSStringFromSeconds(
10889
total[companyName][projectName][taskName],
10990
)}
@@ -116,4 +97,15 @@
11697
</div>
11798
</div>
11899
{/each}
100+
101+
<!-- Powered by header -->
102+
<section class="hero rounded-lg p-4">
103+
<div class="hero-content text-center">
104+
<div>
105+
<h1 class="font-bold text-sm">
106+
Generated with ♥️ <a href="https://timetrack.mwco.app">timetrack</a>
107+
</h1>
108+
</div>
109+
</div>
110+
</section>
119111
</div>

src/renderer/src/components/Search.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,7 @@
351351
352352
// Convert search results to PDFQueryResult format
353353
const data: PDFQueryResult[] = result.tasks.map(task => ({
354+
id: task.id,
354355
companyName: task.companyName,
355356
projectName: task.projectName,
356357
name: task.name,

0 commit comments

Comments
 (0)