aboutsummaryrefslogtreecommitdiffstats
path: root/src/App.tsx
blob: 5645dcc891c015fcc59c7e16effc04e6a06f8541 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { useSnippets } from "./api"
import styles from "./App.module.css"
import icon from "./favicon.png"

const App = () => {
  const snippets = useSnippets()

  const renderSnippets = () => {
    if (snippets.type === "failed") {
      return <div className={styles.error}>
        Unexpected error loading snippets. See console for details.
      </div>
    }

    if (snippets.type === "loading") {
      return <div>Loading snippets...</div>
    }

    return snippets.data.map((snippet) =>
      <div key={snippet.id}>{snippet.title}</div>,
    )
  }

  return (
    <div className={styles.app}>
      <header className={styles.header}>
        <div className={styles.iconRow}>
          <img src={icon} />
          <strong>SLAM</strong>
        </div>
        <div className={styles.sloganRow}>
          <small>A Mere Stack Language</small>
        </div>
      </header>
      <div>
        {renderSnippets()}
      </div>
    </div>
  )
}

export default App