Using prettier to format

This commit is contained in:
Fabian Stamm 2020-03-11 13:54:13 +01:00
parent afd25f47d7
commit df017833a4
9 changed files with 551 additions and 552 deletions

View File

@ -5,7 +5,7 @@ indent_style = space
indent_size = 3 indent_size = 3
charset = utf-8 charset = utf-8
trim_trailing_whitespace = false trim_trailing_whitespace = false
insert_final_newline = false insert_final_newline = true
[*.svelte] [*.svelte]
indent_size = 2 indent_size = 2

3
.vscode/extensions.json vendored Normal file
View File

@ -0,0 +1,3 @@
{
"recommendations": ["esbenp.prettier-vscode"]
}

View File

@ -3,10 +3,7 @@
// onMount, // onMount,
// onDestroy // onDestroy
// } from "svelte"; // } from "svelte";
import { import { onMount, onDestroy } from "svelte";
onMount,
onDestroy
} from 'svelte';
const basetext = "Logged in. Redirecting"; const basetext = "Logged in. Redirecting";
let dots = 0; let dots = 0;
@ -18,27 +15,16 @@
console.log("Mounted"); console.log("Mounted");
iv = setInterval(() => { iv = setInterval(() => {
dots++; dots++;
if (dots > 3) if (dots > 3) dots = 0;
dots = 0;
}, 500); }, 500);
}); });
onDestroy(() => { onDestroy(() => {
console.log("on Destroy") console.log("on Destroy");
clearInterval(iv) clearInterval(iv);
}); });
</script> </script>
<div class="scale">
<svg class="checkmark" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 52 52">
<circle class="checkmark__circle" cx="26" cy="26" r="25" fill="none" />
<path class="checkmark__check" fill="none" d="M14.1 27.2l7.1 7.2 16.7-16.8" />
</svg>
</div>
<!-- <div style="text-align: center;"> -->
<h3>{text}</h3>
<!-- </div> -->
<style> <style>
.checkmark__circle { .checkmark__circle {
stroke-dasharray: 166; stroke-dasharray: 166;
@ -60,7 +46,8 @@
stroke-miterlimit: 10; stroke-miterlimit: 10;
margin: 10% auto; margin: 10% auto;
box-shadow: inset 0px 0px 0px #7ac142; box-shadow: inset 0px 0px 0px #7ac142;
animation: fill .4s ease-in-out .4s forwards, scale .3s ease-in-out .9s both; animation: fill 0.4s ease-in-out 0.4s forwards,
scale 0.3s ease-in-out 0.9s both;
} }
.checkmark__check { .checkmark__check {
@ -77,7 +64,6 @@
} }
@keyframes scale { @keyframes scale {
0%, 0%,
100% { 100% {
transform: none; transform: none;
@ -98,3 +84,16 @@
transform: scale(1.5); transform: scale(1.5);
} }
</style> </style>
<div class="scale">
<svg class="checkmark" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 52 52">
<circle class="checkmark__circle" cx="26" cy="26" r="25" fill="none" />
<path
class="checkmark__check"
fill="none"
d="M14.1 27.2l7.1 7.2 16.7-16.8" />
</svg>
</div>
<!-- <div style="text-align: center;"> -->
<h3>{text}</h3>
<!-- </div> -->

View File

@ -1,8 +1,6 @@
<script> <script>
import Cleave from "../../cleave" import Cleave from "../../cleave";
import { import { onMount } from "svelte";
onMount
} from 'svelte';
export let error; export let error;
export let label; export let label;
@ -13,10 +11,10 @@
onMount(() => { onMount(() => {
const cleaveCustom = new Cleave(input, { const cleaveCustom = new Cleave(input, {
blocks: [length / 2, length / 2], blocks: [length / 2, length / 2],
delimiter: ' ', delimiter: " ",
numericOnly: true numericOnly: true
}); });
}) });
</script> </script>
<style> <style>
@ -27,9 +25,9 @@
</style> </style>
<div class="floating group"> <div class="floating group">
<input bind:this={input} autofocus bind:value={value}> <input bind:this={input} autofocus bind:value />
<span class="highlight"></span> <span class="highlight" />
<span class="bar"></span> <span class="bar" />
<label>Code</label> <label>Code</label>
<div class="error" style={!error ? "display: none;" : "" }>{error}</div> <div class="error" style={!error ? 'display: none;' : ''}>{error}</div>
</div> </div>

View File

@ -9,12 +9,10 @@
export let finish; export let finish;
async function requestPush() { async function requestPush() {
// Push Request // Push Request
} }
</script> </script>
<style> <style>
.error { .error {
color: var(--error); color: var(--error);
@ -94,8 +92,6 @@
-moz-animation-delay: 1.003s; -moz-animation-delay: 1.003s;
} }
@keyframes orbit { @keyframes orbit {
0% { 0% {
opacity: 1; opacity: 1;
@ -369,23 +365,26 @@
<h3>SMS</h3> <h3>SMS</h3>
<p>A code was sent to your Device <b>{device}</b></p> <p>
A code was sent to your Device
<b>{device}</b>
</p>
<div class="windows8"> <div class="windows8">
<div class="wBall" id="wBall_1"> <div class="wBall" id="wBall_1">
<div class="wInnerBall"></div> <div class="wInnerBall" />
</div> </div>
<div class="wBall" id="wBall_2"> <div class="wBall" id="wBall_2">
<div class="wInnerBall"></div> <div class="wInnerBall" />
</div> </div>
<div class="wBall" id="wBall_3"> <div class="wBall" id="wBall_3">
<div class="wInnerBall"></div> <div class="wInnerBall" />
</div> </div>
<div class="wBall" id="wBall_4"> <div class="wBall" id="wBall_4">
<div class="wInnerBall"></div> <div class="wInnerBall" />
</div> </div>
<div class="wBall" id="wBall_5"> <div class="wBall" id="wBall_5">
<div class="wInnerBall"></div> <div class="wInnerBall" />
</div> </div>
</div> </div>

View File

@ -4,7 +4,7 @@
const states = { const states = {
approve: 1, approve: 1,
enter: 2 enter: 2
} };
let state = states.approve; let state = states.approve;
let error = ""; let error = "";
@ -12,9 +12,7 @@
export let number = "+4915...320"; export let number = "+4915...320";
//export let finish; //export let finish;
function validateCode() { function validateCode() {}
}
function sendCode() { function sendCode() {
// Send request to Server // Send request to Server
@ -23,7 +21,6 @@
} }
</script> </script>
<style> <style>
:root { :root {
--error: red; --error: red;
@ -41,8 +38,11 @@
{:else} {:else}
<p>A code was sent to you. Please enter</p> <p>A code was sent to you. Please enter</p>
<input type="number" placeholder="Code" bind:value={code} /> <input type="number" placeholder="Code" bind:value={code} />
<button on:click={validateCode}>Send</button><br> <button on:click={validateCode}>Send</button>
<a href="# " on:click|preventDefault={() => state = states.approve}>Not received?</a> <br />
<a href="# " on:click|preventDefault={() => (state = states.approve)}>
Not received?
</a>
{/if} {/if}
<div class="error">{error}</div> <div class="error">{error}</div>

View File

@ -1,6 +1,7 @@
<script> <script>
export let finish = () => {}; export let finish = () => {};
</script> </script>
<style> <style>
a { a {
color: var(--primary); color: var(--primary);
@ -9,5 +10,7 @@
</style> </style>
<p> <p>
<a href="# " on:click={evt=>evt.preventDefault() || finish(false)}>Choose another Method</a> <a href="# " on:click={evt => evt.preventDefault() || finish(false)}>
Choose another Method
</a>
</p> </p>

View File

@ -8,7 +8,7 @@
requestUser: 1, requestUser: 1,
sendChallenge: 2, sendChallenge: 2,
error: 3 error: 3
} };
let state = states.getChallenge; let state = states.getChallenge;
@ -25,7 +25,7 @@
state = states.requestUser; state = states.requestUser;
let res = await window.navigator.credentials.get({ let res = await window.navigator.credentials.get({
publicKey: challenge publicKey: challenge
}) });
state = states.sendChallenge(); state = states.sendChallenge();
let r = res.response; let r = res.response;
let data = encode({ let data = encode({
@ -34,12 +34,10 @@
signature: r.signature, signature: r.signature,
userHandle: r.userHandle userHandle: r.userHandle
}); });
let { let { success } = fetch("https://localhost:8444/auth", {
success
} = fetch("https://localhost:8444/auth", {
body: data, body: data,
method: "POST" method: "POST"
}).then(res => res.json()) }).then(res => res.json());
if (success) { if (success) {
finish(true); finish(true);
} }
@ -53,10 +51,9 @@
requestUser().catch(onError); requestUser().catch(onError);
} }
getChallenge().catch(onError) getChallenge().catch(onError);
</script> </script>
<style> <style>
:root { :root {
--error: red; --error: red;

View File

@ -4,7 +4,7 @@ import { getCookie } from "./cookie";
// const baseURL = "http://localhost:3000"; // const baseURL = "http://localhost:3000";
const baseURL = ""; const baseURL = "";
export default async function request(endpoint: string, parameters: { [key: string]: string } = {}, method: "GET" | "POST" | "DELETE" | "PUT" = "GET", body?: any, authInParam = false) { export default async function request(endpoint: string, parameters: { [key: string]: string } = {}, method: "GET" | "POST" | "DELETE" | "PUT" = "GET", body?: any, authInParam = false, redirect = false) {
let pairs = []; let pairs = [];
if (authInParam) { if (authInParam) {
@ -33,9 +33,9 @@ export default async function request(endpoint: string, parameters: { [key: stri
return e.json() return e.json()
}).then(data => { }).then(data => {
if (data.error) { if (data.error) {
if (data.additional && data.additional.auth) { if (redirect && data.additional && data.additional.auth) {
let state = btoa(window.location.pathname + window.location.hash); let state = btoa(window.location.pathname + window.location.hash);
// window.location.href = `/login?state=${state}&base64=true`; window.location.href = `/login?state=${state}&base64=true`;
} }
return Promise.reject(new Error(data.error)) return Promise.reject(new Error(data.error))
} }