Skip to content

Commit 8745f7c

Browse files
committed
refactor: better style thanks to cursor and claude
1 parent 0ea6d67 commit 8745f7c

File tree

3 files changed

+95
-16
lines changed

3 files changed

+95
-16
lines changed

go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
module github.com/kaihendry/days
22

3-
go 1.23
3+
go 1.24
44

55
require (
66
github.com/apex/gateway/v2 v2.0.0
7-
github.com/arran4/golang-ical v0.3.1
7+
github.com/arran4/golang-ical v0.3.2
88
)
99

1010
require (

go.sum

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ github.com/arran4/golang-ical v0.2.8 h1:8lsFcfQqzg0gBpIxq7fWr4RV+8SVENLMXpSic5xs
55
github.com/arran4/golang-ical v0.2.8/go.mod h1:RqMuPGmwRRwjkb07hmm+JBqcWa1vF1LvVmPtSZN2OhQ=
66
github.com/arran4/golang-ical v0.3.1 h1:v13B3eQZ9VDHTAvT6M11vVzxYgcYmjyPBE2eAZl3VZk=
77
github.com/arran4/golang-ical v0.3.1/go.mod h1:LZWxF8ZIu/sjBVUCV0udiVPrQAgq3V0aa0RfbO99Qkk=
8+
github.com/arran4/golang-ical v0.3.2 h1:MGNjcXJFSuCXmYX/RpZhR2HDCYoFuK8vTPFLEdFC3JY=
9+
github.com/arran4/golang-ical v0.3.2/go.mod h1:xblDGxxIUMWwFZk9dlECUlc1iXNV65LJZOTHLVwu8bo=
810
github.com/aws/aws-lambda-go v1.17.0/go.mod h1:FEwgPLE6+8wcGBTe5cJN3JWurd1Ztm9zN4jsXsjzKKw=
911
github.com/aws/aws-lambda-go v1.46.0 h1:UWVnvh2h2gecOlFhHQfIPQcD8pL/f7pVCutmFl+oXU8=
1012
github.com/aws/aws-lambda-go v1.46.0/go.mod h1:dpMpZgvWx5vuQJfBt0zqBha60q7Dd7RfgJv23DymV8A=

templates/index.html

+91-14
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,47 @@
5151
}
5252

5353
pre {
54-
white-space: pre-wrap;
55-
word-break: break-all;
56-
font-family: inherit;
57-
line-height: normal; /* Reset line-height */
58-
margin: 0; /* Remove default margin */
59-
padding: 0; /* Remove default padding */
60-
}
54+
white-space: pre;
55+
word-break: normal;
56+
font-family: inherit;
57+
line-height: 1.5;
58+
margin: 0;
59+
padding: 0;
60+
display: flex;
61+
align-items: center;
62+
}
63+
64+
main {
65+
min-width: 300px;
66+
width: 100%;
67+
max-width: 600px;
68+
}
6169

70+
table {
71+
width: 100%;
72+
border-collapse: collapse;
73+
table-layout: fixed;
74+
}
75+
76+
td {
77+
padding: 2px 0;
78+
text-align: left;
79+
vertical-align: top;
80+
}
81+
82+
td.date {
83+
white-space: nowrap;
84+
}
85+
86+
/* Reset table and row styling to default */
87+
tr {
88+
display: table-row;
89+
}
90+
91+
td {
92+
display: table-cell;
93+
}
94+
6295
a {
6396
color: #2a5db0;
6497
text-decoration: none;
@@ -67,11 +100,46 @@
67100
a:hover {
68101
text-decoration: underline;
69102
}
103+
104+
.holiday {
105+
color: #e67e22;
106+
font-weight: 600;
107+
background-color: #fff3e0;
108+
padding: 2px 8px;
109+
border-radius: 4px;
110+
display: inline-block;
111+
font-size: 0.95rem;
112+
border: 1px solid #ffd8a8;
113+
margin-left: 4px;
114+
}
70115

71-
.holiday {
72-
color: #d35400;
73-
font-weight: bold;
74-
}
116+
/* Visually hidden elements - visible for screen readers and copying */
117+
.visually-hidden {
118+
clip: rect(1px, 1px, 1px, 1px);
119+
height: 1px;
120+
width: 1px;
121+
overflow: hidden;
122+
position: absolute;
123+
white-space: pre;
124+
}
125+
126+
@media (max-width: 480px) {
127+
table {
128+
table-layout: fixed;
129+
width: 100%;
130+
}
131+
132+
td.date {
133+
margin-bottom: 2px;
134+
}
135+
136+
.holiday {
137+
display: inline-block;
138+
word-break: break-word;
139+
max-width: 100%;
140+
margin-left: 4px;
141+
}
142+
}
75143

76144
</style>
77145
</head>
@@ -104,18 +172,27 @@
104172
</script>
105173
<main>
106174
{{- $previousWeek := -1 }}{{/* Initialize a variable to track the previous week number */}}
175+
<table>
107176
{{range $day := .Days -}}
108177
{{- $currentWeek := $day.Date | weekNumber }}{{/* Get the current week number */}}
109178
{{- if ne $currentWeek $previousWeek }}{{/* Compare with the previous week number */}}
110-
<h2>Week Number: {{$currentWeek}}</h2>{{/* Print the week number if it's different */}}
179+
<tr><td colspan="2"><h2>Week Number: {{$currentWeek}}</h2></td></tr>{{/* Print the week number if it's different */}}
111180
{{- $previousWeek = $currentWeek }}{{/* Update the previous week number */}}
112181
{{- end }}
182+
<tr>
113183
{{- if eq ($day.Date.Format "2006-01-02") ($.Now.Format "2006-01-02") }}
114-
<pre><strong>{{$day.Date.Format "2006-01-02 Mon"}}</strong></pre>
184+
<td class="date"><strong>{{$day.Date.Format "2006-01-02 Mon"}}</strong></td>
185+
{{- else }}
186+
<td class="date">{{$day.Date.Format "2006-01-02 Mon"}}</td>
187+
{{- end }}
188+
{{- if $day.IsHoliday}}
189+
<td><span class="visually-hidden"> - </span><span class="holiday">{{$day.HolidaySummary}}</span></td>
115190
{{- else }}
116-
<pre>{{$day.Date.Format "2006-01-02 Mon"}}{{if $day.IsHoliday}}<span class="holiday">&nbsp;{{$day.HolidaySummary}}</span>{{end}}</pre>
191+
<td></td>
117192
{{- end }}
193+
</tr>
118194
{{- end }}
195+
</table>
119196
</main>
120197

121198
<br>

0 commit comments

Comments
 (0)