@@ -36,6 +36,7 @@ public struct HomePage: Page {
36
36
body {
37
37
header ( . class( " hero " ) , . aria. label ( " About " ) ) {
38
38
hgroup {
39
+ p ( . class( " file-name " ) ) { " User.swift " }
39
40
h1 ( . class( " hero-title " ) ) { " Erik Bautista Santibanez " }
40
41
p ( . class( " hero-subtitle " ) ) { " Swift & Web Developer " }
41
42
@@ -75,6 +76,7 @@ public struct HomePage: Page {
75
76
}
76
77
main ( . v. scope ( " { selection: undefined } " ) ) {
77
78
header {
79
+ p ( . class( " file-name " ) ) { " Posts.swift " }
78
80
hgroup {
79
81
h2 { " Posts " }
80
82
ul ( . class( " post-tabs " ) ) {
@@ -86,6 +88,7 @@ public struct HomePage: Page {
86
88
}
87
89
li {
88
90
button (
91
+ . class( " post-tab " ) ,
89
92
. v. on ( . click, " selection = \( value) " ) ,
90
93
. v. bind ( " aria-selected " , " selection == \( value) " ) ,
91
94
. aria. selected ( kind == nil )
@@ -103,7 +106,7 @@ public struct HomePage: Page {
103
106
. class( " post " ) ,
104
107
. v. show ( " !selection || selection == ' \( post. kind. rawValue) ' " )
105
108
) {
106
- header { post. dateFormatted }
109
+ header ( . class ( " post-date " ) ) { post. dateFormatted }
107
110
h3 ( . class( " post-title " ) ) { post. title }
108
111
div ( . class( " post-content " ) ) { post. content }
109
112
}
@@ -129,10 +132,16 @@ public struct HomePage: Page {
129
132
extension HomePage {
130
133
struct Style : @unchecked Sendable , StyleSheet {
131
134
var body : some Rule {
132
- // TODO: Add Work-Sans font?
135
+ resetStyles ( )
136
+ generalStyles ( )
137
+ heroStyles ( )
138
+ postTabsStyles ( )
139
+ postStyles ( )
140
+ }
133
141
134
- // Reset components
135
- " :root " => {
142
+ /// MARK: - Reset components
143
+ @CSSBuilder func resetStyles( ) -> some Rule {
144
+ Pseudo ( class: . root) => {
136
145
AnyProperty ( " line-height " , " 1.5 " )
137
146
}
138
147
@@ -149,8 +158,21 @@ extension HomePage {
149
158
AnyProperty ( " display " , " block " )
150
159
AnyProperty ( " max-inline-size " , " 100% " )
151
160
}
161
+ }
162
+
163
+ @CSSBuilder func generalStyles( ) -> some Rule {
164
+ // TODO: Add Work-Sans font?
165
+
166
+ /// MARK: - General
167
+
168
+ " @font-face " => {
169
+ AnyProperty ( " font-family " , " \" CommitMono \" " )
170
+ AnyProperty ( " font-src " , " url( \" https://github.com/eigilnikolajsen/commit-mono/raw/ecd81cdbd7f7eb2acaaa2f2f7e1a585676f9beff/src/fonts/fontlab/CommitMonoV143-VF.woff2 \" ) " )
171
+ AnyProperty ( " font-style " , " normal " )
172
+ AnyProperty ( " font-weight " , " 400 " )
173
+ AnyProperty ( " font-display " , " swap " )
174
+ }
152
175
153
- // General
154
176
Pseudo ( class: . root) => {
155
177
BackgroundColor ( " #1c1c1c " )
156
178
Color ( " #fafafa " )
@@ -189,18 +211,32 @@ extension HomePage {
189
211
AnyProperty ( " scale " , " calc(100% * -1) 100% " )
190
212
}
191
213
192
- /// Hero header
214
+ Class ( " file-name " ) => {
215
+ Color ( " #777 " )
216
+ AnyProperty ( " text-align " , " end " )
217
+ AnyProperty ( " font-size " , " 0.85em " )
218
+ AnyProperty ( " font-weight " , " 600 " )
219
+ AnyProperty ( " font-family " , " \" CommitMono \" , monospace " )
220
+ }
221
+
222
+ Element ( . pre) => {
223
+ AnyProperty ( " font-family " , " \" CommitMono \" , monospace " )
224
+ }
225
+ }
226
+
227
+ @CSSBuilder func heroStyles( ) -> some Rule {
228
+ /// MARK: - Hero header
193
229
194
230
Class ( " hero " ) => {
195
231
AnyProperty ( " padding-bottom " , " 1.5rem " )
196
232
}
197
233
198
- Class ( " hero " ) * Element ( . p ) => {
234
+ Class ( " hero-location " ) => {
199
235
Color ( . hex( " #D0D0D0 " ) )
200
236
}
237
+ }
201
238
202
- /// Post tabs
203
-
239
+ @CSSBuilder func postTabsStyles( ) -> some Rule {
204
240
Class ( " post-tabs " ) => {
205
241
AnyProperty ( " list-style-type " , " none " )
206
242
AnyProperty ( " margin " , " 0 " )
@@ -213,7 +249,7 @@ extension HomePage {
213
249
AnyProperty ( " margin-right " , " 0.25rem " )
214
250
}
215
251
216
- Class ( " post-tabs " ) * Element ( . button ) => {
252
+ Class ( " post-tab " ) => {
217
253
BackgroundColor ( " #3c3c3c " )
218
254
AnyProperty ( " color " , " white " )
219
255
AnyProperty ( " border-color " , " #505050 " )
@@ -223,22 +259,24 @@ extension HomePage {
223
259
AnyProperty ( " padding " , " 0.25rem 0.75rem " )
224
260
}
225
261
226
- Class ( " post-tabs " ) * Element ( . button ) <> . attr( " aria-selected " , match: . exact, value: " true " ) => {
262
+ Class ( " post-tab " ) <> . attr( " aria-selected " , match: . exact, value: " true " ) => {
227
263
AnyProperty ( " background-color " , " #F0F0F0 " )
228
264
AnyProperty ( " color " , " #101010 " )
229
265
AnyProperty ( " border-color " , " #A0A0A0 " )
230
266
}
267
+ }
231
268
232
- /// Posts
269
+ @CSSBuilder func postStyles( ) -> some Rule {
270
+ /// MARK: - Posts
233
271
234
272
Class ( " post " ) => {
235
273
AnyProperty ( " margin-top " , " 0.75rem " )
236
274
AnyProperty ( " margin-bottom " , " 1.5rem " )
237
275
// AnyProperty("border-bottom", "1px dotted #404040")
238
276
}
239
277
240
- Class ( " post " ) > Element ( . header ) => {
241
- Color ( . gray )
278
+ Class ( " post-date " ) => {
279
+ Color ( " #9A9A9A " )
242
280
AnyProperty ( " font-size " , " 0.75em " )
243
281
AnyProperty ( " font-weight " , " 600 " )
244
282
}
@@ -251,7 +289,6 @@ extension HomePage {
251
289
AnyProperty ( " margin " , " revert " )
252
290
}
253
291
254
- /// Code blocks
255
292
Class ( " post " ) * Element( . pre) => {
256
293
AnyProperty ( " padding " , " 1rem " )
257
294
Background ( " #242424 " )
@@ -260,6 +297,7 @@ extension HomePage {
260
297
AnyProperty ( " border-width " , " 1.5px " )
261
298
AnyProperty ( " border-radius " , " 0.75rem " )
262
299
AnyProperty ( " overflow-x " , " auto " )
300
+ AnyProperty ( " font-size " , " 0.85em " )
263
301
}
264
302
}
265
303
}
0 commit comments