1
1
import { LitElement , html , css } from 'lit' ;
2
-
3
- const logo = new URL ( '../assets/open-wc-logo.svg' , import . meta. url ) . href ;
2
+ import { until } from 'lit/directives/until.js' ;
4
3
5
4
export class VernierApp extends LitElement {
6
5
static get properties ( ) {
@@ -21,7 +20,6 @@ export class VernierApp extends LitElement {
21
20
color: #1a2b42;
22
21
max-width: 960px;
23
22
margin: 0 auto;
24
- text-align: center;
25
23
background-color: var(--vernier-app-background-color);
26
24
}
27
25
@@ -54,37 +52,36 @@ export class VernierApp extends LitElement {
54
52
` ;
55
53
}
56
54
55
+ /**
56
+ * List of recent natural events from NASA's EONET
57
+ *
58
+ * @return {Element }
59
+ */
60
+ static async makeNaturalEventsList ( ) {
61
+ const eventsData = await ( await fetch ( 'https://eonet.gsfc.nasa.gov/api/v3/events?limit=15' ) ) . json ( ) ;
62
+ const events = eventsData . events . map ( event => html `
63
+ < li > ${ event . title } </ li >
64
+ ` ) ;
65
+
66
+ return html `
67
+ < ol id ="trends-list ">
68
+ ${ events }
69
+ </ ol >
70
+ < p > Thanks, < a href ="https://eonet.gsfc.nasa.gov/what-is-eonet "> EONET</ a > !</ p >
71
+ ` ;
72
+ }
73
+
57
74
constructor ( ) {
58
75
super ( ) ;
59
- this . title = 'My app ' ;
76
+ this . title = 'Natural Events ' ;
60
77
}
61
78
62
79
render ( ) {
63
80
return html `
64
81
< main >
65
- < div class ="logo "> < img alt ="open-wc logo " src =${ logo } / > </ div >
66
82
< h1 > ${ this . title } </ h1 >
67
-
68
- < p > Edit < code > src/VernierApp.js</ code > and save to reload.</ p >
69
- < a
70
- class ="app-link "
71
- href ="https://open-wc.org/guides/developing-components/code-examples/ "
72
- target ="_blank "
73
- rel ="noopener noreferrer "
74
- >
75
- Code examples
76
- </ a >
83
+ ${ until ( VernierApp . makeNaturalEventsList ( ) , html `Loading...` ) }
77
84
</ main >
78
-
79
- < p class ="app-footer ">
80
- 🚽 Made with love by
81
- < a
82
- target ="_blank "
83
- rel ="noopener noreferrer "
84
- href ="https://github.com/open-wc "
85
- > open-wc</ a
86
- > .
87
- </ p >
88
85
` ;
89
86
}
90
87
}
0 commit comments