@@ -57,6 +57,21 @@ private struct UserView: HTML {
5757 . joined ( separator: " , " )
5858 }
5959
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+
6075 static let aboutDescription = """
6176 I'm a passionate software developer who builds applications using Swift and modern web technologies.
6277 """
@@ -71,7 +86,8 @@ private struct UserView: HTML {
7186 name: " Erik Bautista Santibanez " ,
7287 role: " Mobile & Web Developer " ,
7388 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) \" " } ?? " " )
7591 )
7692
7793 > print(user.about())
@@ -83,7 +99,8 @@ private struct UserView: HTML {
8399 name: " Erik Bautista Santibanez " ,
84100 role: " Mobile & Web Developer " ,
85101 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) \" " } ?? " " )
87104 };
88105
89106 > console.log(user.about());
@@ -95,14 +112,15 @@ private struct UserView: HTML {
95112 name: " Erik Bautista Santibanez " ,
96113 role: " Mobile & Web Developer " ,
97114 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) \" " } ?? " " )
99117 };
100118
101119 > println!( " {} " , user.about());
102120 // \( Self . aboutDescription)
103121 """
104122 case . none:
105- h1 ( . aria. label ( " Name " ) ) {
123+ h1 ( . aria. label ( " name " ) ) {
106124 span { " # " }
107125 . inlineStyle ( " color " , " #808080 " )
108126 . inlineStyle ( " font-weight " , " 700 " )
@@ -112,9 +130,9 @@ private struct UserView: HTML {
112130 . inlineStyle ( " margin-bottom " , " 0.25rem " )
113131
114132 HTMLGroup {
115- p ( . aria. label ( " Occupation " ) ) { " Mobile & Web Developer " }
133+ p ( . aria. label ( " occupation " ) ) { " Mobile & Web Developer " }
116134
117- p ( . aria. label ( " Residency " ) ) {
135+ p ( . aria. label ( " residency " ) ) {
118136 svg (
119137 . xmlns( ) ,
120138 . fill( " currentColor " ) ,
@@ -134,7 +152,7 @@ private struct UserView: HTML {
134152 }
135153
136154 if let currentLocation {
137- p ( . aria. label ( " Current location" ) ) {
155+ p ( . aria. label ( " current location" ) ) {
138156 svg (
139157 . xmlns( ) ,
140158 . fill( " currentColor " ) ,
@@ -158,15 +176,48 @@ private struct UserView: HTML {
158176
159177 " Currently in "
160178
161- span { " *** " }
162- . inlineStyle ( " color " , " #808080 " )
163- . inlineStyle ( " font-weight " , " 700 " )
179+ // span { "***" }
180+ // .inlineStyle("color", "#808080")
181+ // .inlineStyle("font-weight", "700")
164182 em { currentLocation }
165183 . inlineStyle ( " font-weight " , " 700 " )
166184 . 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 }
169216 . inlineStyle ( " font-weight " , " 700 " )
217+ . inlineStyle ( " color " , " #fafafa " )
218+ // span { "***" }
219+ // .inlineStyle("color", "#808080")
220+ // .inlineStyle("font-weight", "700")
170221 }
171222 }
172223
0 commit comments