2019-08-27 18:32:56 +12:00
|
|
|
<script>
|
2020-11-19 08:18:18 +13:00
|
|
|
import { getContext } from "svelte"
|
|
|
|
|
2020-11-20 22:50:10 +13:00
|
|
|
const { authStore, styleable } = getContext("sdk")
|
|
|
|
const styles = getContext("style")
|
2020-11-13 01:24:45 +13:00
|
|
|
|
2020-10-15 05:06:20 +13:00
|
|
|
export let buttonText = "Log In"
|
2020-02-03 22:50:30 +13:00
|
|
|
export let logo = ""
|
2020-07-06 22:30:36 +12:00
|
|
|
export let title = ""
|
2020-02-03 22:50:30 +13:00
|
|
|
export let buttonClass = ""
|
|
|
|
export let inputClass = ""
|
|
|
|
|
|
|
|
let username = ""
|
|
|
|
let password = ""
|
2020-05-06 21:33:30 +12:00
|
|
|
let loading = false
|
|
|
|
let error = false
|
2020-02-03 22:50:30 +13:00
|
|
|
let _buttonClass = ""
|
|
|
|
let _inputClass = ""
|
|
|
|
|
|
|
|
$: {
|
|
|
|
_buttonClass = buttonClass || "default-button"
|
|
|
|
_inputClass = inputClass || "default-input"
|
|
|
|
}
|
|
|
|
|
2020-05-06 21:33:30 +12:00
|
|
|
const login = async () => {
|
|
|
|
loading = true
|
2020-11-20 07:39:22 +13:00
|
|
|
await authStore.actions.logIn({ username, password })
|
2020-11-13 01:24:45 +13:00
|
|
|
loading = false
|
2020-02-03 22:50:30 +13:00
|
|
|
}
|
2019-08-27 18:32:56 +12:00
|
|
|
</script>
|
2020-06-25 02:41:33 +12:00
|
|
|
|
2020-11-24 22:31:54 +13:00
|
|
|
<div class="root" use:styleable={$styles}>
|
2020-06-25 03:57:21 +12:00
|
|
|
<div class="content">
|
|
|
|
{#if logo}
|
2020-10-15 01:21:43 +13:00
|
|
|
<div class="logo-container"><img src={logo} alt="logo" /></div>
|
2020-06-25 03:57:21 +12:00
|
|
|
{/if}
|
2020-06-04 02:13:39 +12:00
|
|
|
|
2020-07-06 22:30:36 +12:00
|
|
|
{#if title}
|
2020-10-15 05:06:20 +13:00
|
|
|
<h2 class="header-content">{title}</h2>
|
2020-07-06 22:30:36 +12:00
|
|
|
{/if}
|
2020-06-25 03:57:21 +12:00
|
|
|
|
|
|
|
<div class="form-root">
|
|
|
|
<div class="control">
|
|
|
|
<input
|
|
|
|
bind:value={username}
|
|
|
|
type="text"
|
|
|
|
placeholder="Username"
|
|
|
|
class={_inputClass} />
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="control">
|
|
|
|
<input
|
|
|
|
bind:value={password}
|
|
|
|
type="password"
|
|
|
|
placeholder="Password"
|
|
|
|
class={_inputClass} />
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<button disabled={loading} on:click={login} class={_buttonClass}>
|
2020-10-15 05:06:20 +13:00
|
|
|
{buttonText || 'Log In'}
|
2020-06-25 03:57:21 +12:00
|
|
|
</button>
|
2020-02-03 22:50:30 +13:00
|
|
|
</div>
|
2020-06-25 03:57:21 +12:00
|
|
|
|
|
|
|
{#if error}
|
|
|
|
<div class="incorrect-details-panel">Incorrect username or password</div>
|
|
|
|
{/if}
|
2020-02-03 22:50:30 +13:00
|
|
|
</div>
|
2019-08-27 18:32:56 +12:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<style>
|
2020-02-03 22:50:30 +13:00
|
|
|
.root {
|
2019-08-27 18:32:56 +12:00
|
|
|
height: 100%;
|
2020-06-04 02:13:39 +12:00
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
2020-02-03 22:50:30 +13:00
|
|
|
}
|
2019-08-27 18:32:56 +12:00
|
|
|
|
2020-02-03 22:50:30 +13:00
|
|
|
.content {
|
2020-06-04 02:13:39 +12:00
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
2020-10-16 04:37:50 +13:00
|
|
|
align-items: stretch;
|
2020-06-04 02:13:39 +12:00
|
|
|
justify-content: center;
|
2020-02-03 22:50:30 +13:00
|
|
|
}
|
2019-08-27 18:32:56 +12:00
|
|
|
|
2020-02-03 22:50:30 +13:00
|
|
|
.logo-container {
|
2020-06-04 02:55:42 +12:00
|
|
|
margin-bottom: 10px;
|
2020-10-16 04:37:50 +13:00
|
|
|
display: flex;
|
|
|
|
flex-direction: row;
|
|
|
|
justify-content: center;
|
|
|
|
align-items: center;
|
2020-02-03 22:50:30 +13:00
|
|
|
}
|
2019-08-27 18:32:56 +12:00
|
|
|
|
2020-02-03 22:50:30 +13:00
|
|
|
.logo-container > img {
|
2020-10-16 04:37:50 +13:00
|
|
|
max-height: 80px;
|
2020-06-04 02:55:42 +12:00
|
|
|
max-width: 200px;
|
2020-10-15 05:06:20 +13:00
|
|
|
margin-bottom: 20px;
|
2020-02-03 22:50:30 +13:00
|
|
|
}
|
2019-08-27 18:32:56 +12:00
|
|
|
|
2020-06-04 02:13:39 +12:00
|
|
|
.header-content {
|
|
|
|
font-family: Inter;
|
2020-06-25 03:57:21 +12:00
|
|
|
font-weight: 700;
|
2020-06-04 02:13:39 +12:00
|
|
|
color: #1f1f1f;
|
2020-10-15 05:06:20 +13:00
|
|
|
font-size: 32px;
|
2020-06-04 02:13:39 +12:00
|
|
|
text-rendering: optimizeLegibility;
|
|
|
|
-webkit-font-smoothing: antialiased;
|
|
|
|
font-feature-settings: "case" "rlig" "calt" 0;
|
2020-10-15 05:06:20 +13:00
|
|
|
margin: 0 0 20px 0;
|
2020-02-03 22:50:30 +13:00
|
|
|
}
|
2019-08-27 18:32:56 +12:00
|
|
|
|
2020-02-03 22:50:30 +13:00
|
|
|
.incorrect-details-panel {
|
2020-10-15 08:12:27 +13:00
|
|
|
margin-top: 26px;
|
2019-09-19 15:35:40 +12:00
|
|
|
padding: 10px;
|
|
|
|
border-style: solid;
|
|
|
|
border-width: 1px;
|
|
|
|
border-color: maroon;
|
2020-10-15 08:12:27 +13:00
|
|
|
border-radius: 4px;
|
2019-09-19 15:35:40 +12:00
|
|
|
text-align: center;
|
|
|
|
color: maroon;
|
|
|
|
background-color: mistyrose;
|
2020-10-15 08:12:27 +13:00
|
|
|
align-self: stretch;
|
2020-02-03 22:50:30 +13:00
|
|
|
}
|
2019-09-19 15:35:40 +12:00
|
|
|
|
2020-02-03 22:50:30 +13:00
|
|
|
.form-root {
|
2020-06-04 02:13:39 +12:00
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
2020-10-16 04:37:50 +13:00
|
|
|
align-items: stretch;
|
2020-06-04 02:13:39 +12:00
|
|
|
width: 300px;
|
2020-10-17 03:32:02 +13:00
|
|
|
margin: auto;
|
|
|
|
gap: 8px;
|
2020-02-03 22:50:30 +13:00
|
|
|
}
|
2019-09-19 15:35:40 +12:00
|
|
|
|
2020-02-03 22:50:30 +13:00
|
|
|
.control {
|
2020-06-04 02:13:39 +12:00
|
|
|
width: 100%;
|
2020-02-03 22:50:30 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
.default-input {
|
2020-06-04 02:13:39 +12:00
|
|
|
font-family: Inter;
|
|
|
|
font-size: 14px;
|
|
|
|
color: #393c44;
|
|
|
|
padding: 2px 6px 2px 12px;
|
2020-02-03 22:50:30 +13:00
|
|
|
margin: 0 0 0.5em 0;
|
|
|
|
box-sizing: border-box;
|
2020-06-04 02:13:39 +12:00
|
|
|
border: 0.5px solid #d8d8d8;
|
|
|
|
border-radius: 4px;
|
2019-09-29 18:40:06 +13:00
|
|
|
width: 100%;
|
2020-06-04 02:13:39 +12:00
|
|
|
height: 40px;
|
|
|
|
transition: border-color 100ms ease-in 0s;
|
|
|
|
outline-color: #797979;
|
2020-02-03 22:50:30 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
.default-button {
|
2020-06-04 02:13:39 +12:00
|
|
|
font-family: Inter;
|
|
|
|
font-size: 16px;
|
2020-02-03 22:50:30 +13:00
|
|
|
padding: 0.4em;
|
|
|
|
box-sizing: border-box;
|
2020-06-04 02:13:39 +12:00
|
|
|
border-radius: 4px;
|
|
|
|
color: white;
|
|
|
|
background-color: #393c44;
|
2020-02-03 22:50:30 +13:00
|
|
|
outline: none;
|
2020-06-04 02:13:39 +12:00
|
|
|
width: 300px;
|
|
|
|
height: 40px;
|
|
|
|
cursor: pointer;
|
|
|
|
transition: all 0.2s ease 0s;
|
|
|
|
overflow: hidden;
|
|
|
|
outline: none;
|
|
|
|
user-select: none;
|
|
|
|
white-space: nowrap;
|
|
|
|
text-align: center;
|
2020-02-03 22:50:30 +13:00
|
|
|
}
|
|
|
|
|
2020-06-04 02:13:39 +12:00
|
|
|
.default-button:hover {
|
|
|
|
background-color: white;
|
|
|
|
border-color: #393c44;
|
|
|
|
color: #393c44;
|
2020-02-03 22:50:30 +13:00
|
|
|
}
|
2020-10-16 04:37:50 +13:00
|
|
|
|
|
|
|
h2 {
|
|
|
|
text-align: center;
|
2020-10-17 03:32:02 +13:00
|
|
|
margin-bottom: 10px;
|
2020-10-16 04:37:50 +13:00
|
|
|
}
|
2020-02-03 22:50:30 +13:00
|
|
|
</style>
|