Skip to content

Commit

Permalink
Docs: Demo Site Implemented, using temporary API
Browse files Browse the repository at this point in the history
  • Loading branch information
Fallstop committed Jan 12, 2022
1 parent 0e3cc7d commit 25a184e
Show file tree
Hide file tree
Showing 16 changed files with 1,100 additions and 2 deletions.
8 changes: 8 additions & 0 deletions demo-site/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.DS_Store
node_modules
/build
/.svelte-kit
/package
.env
.env.*
!.env.example
1 change: 1 addition & 0 deletions demo-site/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
engine-strict=true
1 change: 1 addition & 0 deletions demo-site/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v17.1.0
38 changes: 38 additions & 0 deletions demo-site/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# create-svelte

Everything you need to build a Svelte project, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/master/packages/create-svelte);

## Creating a project

If you're seeing this, you've probably already done this step. Congrats!

```bash
# create a new project in the current directory
npm init svelte@next

# create a new project in my-app
npm init svelte@next my-app
```

> Note: the `@next` is temporary
## Developing

Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:

```bash
npm run dev

# or start the server and open the app in a new browser tab
npm run dev -- --open
```

## Building

Before creating a production version of your app, install an [adapter](https://kit.svelte.dev/docs#adapters) for your target environment. Then:

```bash
npm run build
```

> You can preview the built app with `npm run preview`, regardless of whether you installed an adapter. This should _not_ be used to serve your app in production.
29 changes: 29 additions & 0 deletions demo-site/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "demo-site",
"version": "0.0.1",
"type": "module",
"scripts": {
"build": "svelte-kit build",
"check": "svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-check --tsconfig ./tsconfig.json --watch",
"dev": "svelte-kit dev",
"package": "svelte-kit package",
"preview": "svelte-kit preview"
},
"dependencies": {
"@fontsource/fira-sans": "^4.5.0"
},
"devDependencies": {
"@sveltejs/adapter-auto": "next",
"@sveltejs/adapter-static": "^1.0.0-next.26",
"@sveltejs/kit": "next",
"nodesass": "^0.0.2-security",
"sass": "^1.47.0",
"svelte": "^3.44.0",
"svelte-check": "^2.2.6",
"svelte-preprocess": "^4.9.4",
"svelte-simple-modal": "^1.2.0",
"tslib": "^2.3.1",
"typescript": "^4.4.3"
}
}
13 changes: 13 additions & 0 deletions demo-site/src/app.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="description" content="" />
<link rel="icon" href="%svelte.assets%/favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
%svelte.head%
</head>
<body>
<div id="svelte">%svelte.body%</div>
</body>
</html>
1 change: 1 addition & 0 deletions demo-site/src/global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="@sveltejs/kit" />
84 changes: 84 additions & 0 deletions demo-site/src/lib/ResultModal.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<script lang="ts">
import type path from 'path/posix'
export let message:
| {
details: ParsedApcCert | null
status: string
}
| {
error: string
}
interface ParsedApcCert {
fullName: string
issueDate: Date
expiryDate: Date
practiceScope: string
conditions: string | null
}
</script>

<div class="container">
{#if 'error' in message}
<div class="error-message">
{message.error}
</div>
{:else if message.details !== null}
<table>
<tr>
<th> key </th>
<th> value </th>
</tr>
{#each Object.keys(message.details) as key}
<tr>
<td>{key}</td>
<td>{message.details[key]}</td>
</tr>
{/each}
</table>
{:else}
<div class="error-message">
Certificate did not match any known Physioboard APC certificates. Make sure you upload the original APC certificate that was sent to you electronically.
</div>
{/if}
</div>

<style lang="scss">
.container {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
table {
border-spacing: 0;
$table-border-color: rgb(58, 58, 58);
tr {
th {
text-align: left;
background-color: #efefef;
}
th,
td {
padding: 5px;
border-top: 1px solid $table-border-color;
}
&:nth-child(odd) {
background-color: rgb(245, 245, 245);
}
td:nth-child(even) {
text-transform: capitalize;
}
}
border-bottom: 1px solid $table-border-color;
border-left: 1px solid $table-border-color;
border-right: 1px solid $table-border-color;
}
.error-message {
padding: 1rem;
}
}
</style>
6 changes: 6 additions & 0 deletions demo-site/src/main.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@import "@fontsource/fira-sans";

body {
font-family: "Fira Sans";
margin: 0;
}
8 changes: 8 additions & 0 deletions demo-site/src/routes/__layout.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<script lang="ts">
import "../main.scss"
import Modal from 'svelte-simple-modal';
</script>
<Modal>
<slot/>
</Modal>
86 changes: 86 additions & 0 deletions demo-site/src/routes/index.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<script lang="ts">
import { getContext } from 'svelte'
import ResultModal from '$lib/ResultModal.svelte'
// Temporary, till AWS Lambda's are implemented
const API_URL = 'https://apc-reader-api.host.qrl.nz/'
async function scanFiles(uploadEvent: Event) {
let uploadedFile: File = (uploadEvent.target as HTMLInputElement).files[0];
if (uploadedFile) {
let formData = new FormData()
formData.append('data', uploadedFile)
let scanResults = await fetch(API_URL, {
method: 'POST',
body: formData,
})
console.log('Scan Results:', scanResults)
showResultModal(await scanResults.json())
}
}
// Modal to show PDF results
const { open } = getContext('simple-modal')
const showResultModal = (data) => {
open(ResultModal, { message: data })
}
</script>

<div class="primary-container">
<h1>Physioboard APC Reader</h1>
<!-- File Input -->
<div class="form-group">
<label for="file" class="file-uploader">
Upload PDF
<input
type="file"
id="file"
name="file"
accept=".pdf"
on:change={(e) => {
console.log(e)
scanFiles(e)
}}
/>
</label>
</div>
</div>

<style lang="scss">
.primary-container {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
text-align: center;
height: 100vh;
background: linear-gradient(167deg, rgba(255,250,227,1) 0%, rgba(234,252,211,1) 66%, rgba(212,255,201,1) 100%);
h1 {
font-size: 3.5rem;
margin-bottom: 3rem;
}
input[type='file'] {
display: none;
}
.file-uploader {
font-size: 1.75rem;
border: 1px solid #ccc;
display: inline-block;
padding: 6px 12px;
cursor: pointer;
transition: all 100ms ease-in-out;
border-radius: 2px;
&:hover {
background-color: rgba(0, 0, 0, 0.041);
}
&:active {
background-color: rgba(0, 0, 0, 0.24);
}
}
}
</style>
Binary file added demo-site/static/favicon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions demo-site/svelte.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import adapter from '@sveltejs/adapter-static';
import preprocess from 'svelte-preprocess';

/** @type {import('@sveltejs/kit').Config} */
const config = {
// Consult https://github.com/sveltejs/svelte-preprocess
// for more information about preprocessors
preprocess: preprocess(),

kit: {
adapter: adapter(),

// hydrate the <div id="svelte"> element in src/app.html
target: '#svelte'
}
};

export default config;
35 changes: 35 additions & 0 deletions demo-site/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"compilerOptions": {
"moduleResolution": "node",
"module": "es2020",
"lib": [
"es2020",
"DOM"
],
"target": "es2020",
"importsNotUsedAsValues": "error",
"isolatedModules": true,
"resolveJsonModule": true,
"sourceMap": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"baseUrl": ".",
"allowJs": true,
"checkJs": true,
"paths": {
"$lib": [
"src/lib"
],
"$lib/*": [
"src/lib/*"
]
}
},
"include": [
"src/**/*.d.ts",
"src/**/*.js",
"src/**/*.ts",
"src/**/*.svelte"
]
}

0 comments on commit 25a184e

Please sign in to comment.