initial push

This commit is contained in:
2021-12-31 09:39:03 +01:00
commit 2bd04341cf
16 changed files with 5775 additions and 0 deletions

21
src/app.html Normal file
View File

@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="description" content="" />
<link rel="icon" href="/favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="https://unpkg.com/tachyons@4.12.0/css/tachyons.min.css" />
%svelte.head%
<style>
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans',
'Helvetica Neue', sans-serif;
}
</style>
</head>
<body>
<div id="svelte">%svelte.body%</div>
</body>
</html>

1
src/global.d.ts vendored Normal file
View File

@@ -0,0 +1 @@
/// <reference types="@sveltejs/kit" />

1377
src/lib/gql/gen.ts Normal file

File diff suppressed because it is too large Load Diff

5
src/lib/gql/index.ts Normal file
View File

@@ -0,0 +1,5 @@
import { GraphQLClient } from 'graphql-request'
import { getSdk } from './gen'
const client = new GraphQLClient('https://api.spacex.land/graphql/')
export const SDK = getSdk(client)

22
src/lib/gql/root.graphql Normal file
View File

@@ -0,0 +1,22 @@
query LaunchpadsMany {
launchpads(limit: 10) {
id
name
location {
name
}
successful_launches
status
}
}
query LaunchByYear($year: String!) {
launches(find: { launch_year: $year }) {
mission_id
mission_name
launch_date_utc
rocket {
rocket_name
}
}
}

58
src/routes/index.svelte Normal file
View File

@@ -0,0 +1,58 @@
<script lang="ts" context="module">
import { SDK } from '$lib/gql'
import type { Load } from '@sveltejs/kit'
export const load: Load = async () => ({
props: {
launchpads: await SDK.LaunchpadsMany(),
},
})
</script>
<script lang="ts">
import type { GQLLaunchpadsManyQuery } from '$lib/gql/gen'
export let launchpads: GQLLaunchpadsManyQuery
let needle: string = '2020'
$: launches = SDK.LaunchByYear({ year: needle })
</script>
<main>
<h1>SpaceX Land</h1>
<h2>Launchpads</h2>
{#each launchpads.launchpads as launchpad (launchpad.id)}
<div class="mb3">
<b>{launchpad.name}</b>
<br />
{launchpad.location.name}
<br /> <i>Launches:</i>
{launchpad.successful_launches}
</div>
{/each}
<h2>Launches</h2>
<input bind:value={needle} />
{#await launches}
<br />
Loading...
{:then launches}
{#each launches.launches as launch}
<div class="mb3">
<b>{launch.mission_name}</b>
<br />
<i>Rocket:</i>
{launch.rocket.rocket_name}
</div>
{/each}
{/await}
</main>
<style>
main {
padding: 1em;
max-width: 50rem;
margin: 0 auto;
}
</style>