@@ -57,6 +57,21 @@ private struct UserView: HTML {
57
57
. joined ( separator: " , " )
58
58
}
59
59
60
+ var nowPlaying : String ? {
61
+ guard let nowPlaying = activityClient. nowPlaying ( ) else {
62
+ return nil
63
+ }
64
+
65
+ let nowPlayingText = [
66
+ nowPlaying. title,
67
+ nowPlaying. artist? . isEmpty == false ? " — " : nil ,
68
+ nowPlaying. artist
69
+ ]
70
+ . compactMap { $0 }
71
+ . joined ( separator: " " )
72
+ return nowPlayingText
73
+ }
74
+
60
75
static let aboutDescription = """
61
76
I'm a passionate software developer who builds applications using Swift and modern web technologies.
62
77
"""
@@ -71,7 +86,8 @@ private struct UserView: HTML {
71
86
name: " Erik Bautista Santibanez " ,
72
87
role: " Mobile & Web Developer " ,
73
88
home: " \( residency ?? . default) " \
74
- \( currentLocation. flatMap { " , \n location: \" Currently in \( $0) \" " } ?? " " )
89
+ \( currentLocation. flatMap { " , \n location: \" Currently in \( $0) \" " } ?? " " ) \
90
+ \( nowPlaying. flatMap { " , \n listeningTo: \" \( $0) \" " } ?? " " )
75
91
)
76
92
77
93
> print(user.about())
@@ -83,7 +99,8 @@ private struct UserView: HTML {
83
99
name: " Erik Bautista Santibanez " ,
84
100
role: " Mobile & Web Developer " ,
85
101
home: " \( residency ?? . default) " \
86
- \( currentLocation. flatMap { " , \n location: \" Currently in \( $0) \" " } ?? " " )
102
+ \( currentLocation. flatMap { " , \n location: \" Currently in \( $0) \" " } ?? " " ) \
103
+ \( nowPlaying. flatMap { " , \n listeningTo: \" \( $0) \" " } ?? " " )
87
104
};
88
105
89
106
> console.log(user.about());
@@ -95,14 +112,15 @@ private struct UserView: HTML {
95
112
name: " Erik Bautista Santibanez " ,
96
113
role: " Mobile & Web Developer " ,
97
114
home: " \( residency ?? . default) " \
98
- \( currentLocation. flatMap { " , \n location: \" Currently in \( $0) \" " } ?? " " )
115
+ \( currentLocation. flatMap { " , \n location: \" Currently in \( $0) \" " } ?? " " ) \
116
+ \( nowPlaying. flatMap { " , \n listeningTo: \" \( $0) \" " } ?? " " )
99
117
};
100
118
101
119
> println!( " {} " , user.about());
102
120
// \( Self . aboutDescription)
103
121
"""
104
122
case . none:
105
- h1 ( . aria. label ( " Name " ) ) {
123
+ h1 ( . aria. label ( " name " ) ) {
106
124
span { " # " }
107
125
. inlineStyle ( " color " , " #808080 " )
108
126
. inlineStyle ( " font-weight " , " 700 " )
@@ -112,9 +130,9 @@ private struct UserView: HTML {
112
130
. inlineStyle ( " margin-bottom " , " 0.25rem " )
113
131
114
132
HTMLGroup {
115
- p ( . aria. label ( " Occupation " ) ) { " Mobile & Web Developer " }
133
+ p ( . aria. label ( " occupation " ) ) { " Mobile & Web Developer " }
116
134
117
- p ( . aria. label ( " Residency " ) ) {
135
+ p ( . aria. label ( " residency " ) ) {
118
136
svg (
119
137
. xmlns( ) ,
120
138
. fill( " currentColor " ) ,
@@ -134,7 +152,7 @@ private struct UserView: HTML {
134
152
}
135
153
136
154
if let currentLocation {
137
- p ( . aria. label ( " Current location" ) ) {
155
+ p ( . aria. label ( " current location" ) ) {
138
156
svg (
139
157
. xmlns( ) ,
140
158
. fill( " currentColor " ) ,
@@ -158,15 +176,48 @@ private struct UserView: HTML {
158
176
159
177
" Currently in "
160
178
161
- span { " *** " }
162
- . inlineStyle ( " color " , " #808080 " )
163
- . inlineStyle ( " font-weight " , " 700 " )
179
+ // span { "***" }
180
+ // .inlineStyle("color", "#808080")
181
+ // .inlineStyle("font-weight", "700")
164
182
em { currentLocation }
165
183
. inlineStyle ( " font-weight " , " 700 " )
166
184
. inlineStyle ( " color " , " #fafafa " )
167
- span { " *** " }
168
- . inlineStyle ( " color " , " #808080 " )
185
+ // span { "***" }
186
+ // .inlineStyle("color", "#808080")
187
+ // .inlineStyle("font-weight", "700")
188
+ }
189
+ }
190
+
191
+ if let nowPlaying {
192
+ p ( . aria. label ( " music playing " ) ) {
193
+ // <svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" fill="#000000" viewBox="0 0 256 256"><path d=""></path></svg>
194
+ svg (
195
+ . xmlns( ) ,
196
+ . fill( " currentColor " ) ,
197
+ . viewBox( " 0 0 256 256 " ) ,
198
+ . aria. label ( " wave icon " )
199
+ ) {
200
+ path (
201
+ . d(
202
+ " M56,96v64a8,8,0,0,1-16,0V96a8,8,0,0,1,16,0ZM88,24a8,8,0,0,0-8,8V224a8,8,0,0,0,16,0V32A8,8,0,0,0,88,24Zm40,32a8,8,0,0,0-8,8V192a8,8,0,0,0,16,0V64A8,8,0,0,0,128,56Zm40,32a8,8,0,0,0-8,8v64a8,8,0,0,0,16,0V96A8,8,0,0,0,168,88Zm40-16a8,8,0,0,0-8,8v96a8,8,0,0,0,16,0V80A8,8,0,0,0,208,72Z "
203
+ )
204
+ )
205
+ }
206
+ . inlineStyle ( " scale " , " calc(100% * -1) 100% " )
207
+ . svgIconStyling ( )
208
+ . inlineStyle ( " margin-right " , " 0.25rem " )
209
+
210
+ " Listening to "
211
+
212
+ // span { "***" }
213
+ // .inlineStyle("color", "#808080")
214
+ // .inlineStyle("font-weight", "700")
215
+ em { nowPlaying }
169
216
. inlineStyle ( " font-weight " , " 700 " )
217
+ . inlineStyle ( " color " , " #fafafa " )
218
+ // span { "***" }
219
+ // .inlineStyle("color", "#808080")
220
+ // .inlineStyle("font-weight", "700")
170
221
}
171
222
}
172
223
0 commit comments