Update colors to use scss, add Modal
This commit is contained in:
@@ -1,2 +1,13 @@
|
|||||||
$background-color: #1b1b20;
|
$background-color: #1b1b20;
|
||||||
|
|
||||||
|
$primary-color: #2e3042;
|
||||||
|
$primary-accent-color: #263447;
|
||||||
|
|
||||||
|
$secondary-color: #dfdfe9;
|
||||||
|
$secondary-accent-color: #adadbb;
|
||||||
|
|
||||||
|
$danger-color: #be3329;
|
||||||
|
$danger-accent-color: #ddaeb2;
|
||||||
|
$danger-active-color: #b69092;
|
||||||
|
|
||||||
$font-family: Verdana, Geneva, Tahoma, sans-serif;
|
$font-family: Verdana, Geneva, Tahoma, sans-serif;
|
||||||
|
|||||||
@@ -1,71 +1,50 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { colors } from '$lib/theme';
|
|
||||||
|
|
||||||
type ButtonType = 'primary' | 'secondary' | 'tertiary' | 'danger';
|
type ButtonType = 'primary' | 'secondary' | 'tertiary' | 'danger';
|
||||||
|
|
||||||
export let variant: ButtonType = 'primary';
|
export let variant: ButtonType = 'primary';
|
||||||
|
|
||||||
function getStyles(buttonType: ButtonType) {
|
|
||||||
switch (buttonType) {
|
|
||||||
case 'primary':
|
|
||||||
return {
|
|
||||||
backgroundColor: colors.primaryColor,
|
|
||||||
color: colors.secondaryColor,
|
|
||||||
activeColor: colors.primaryAccentColor
|
|
||||||
};
|
|
||||||
case 'secondary':
|
|
||||||
return {
|
|
||||||
backgroundColor: colors.secondaryColor,
|
|
||||||
color: colors.primaryColor,
|
|
||||||
activeColor: colors.secondaryAccentColor
|
|
||||||
};
|
|
||||||
case 'tertiary':
|
|
||||||
return {
|
|
||||||
backgroundColor: 'transparent',
|
|
||||||
color: colors.secondaryColor,
|
|
||||||
activeColor: colors.primaryAccentColor
|
|
||||||
};
|
|
||||||
case 'danger':
|
|
||||||
return {
|
|
||||||
backgroundColor: colors.dangerAccentColor,
|
|
||||||
color: colors.dangerColor,
|
|
||||||
activeColor: colors.dangerActivecolor
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const { backgroundColor, color, activeColor } = getStyles(variant);
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<button
|
<button class={variant} {...$$restProps} on:click>
|
||||||
style:--color={color}
|
|
||||||
style:--background-color={backgroundColor}
|
|
||||||
style:--active={activeColor}
|
|
||||||
{...$$restProps}
|
|
||||||
on:click
|
|
||||||
>
|
|
||||||
<slot />
|
<slot />
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<style>
|
<style lang="scss">
|
||||||
button {
|
@mixin button(
|
||||||
|
$bg-color: $primary-color,
|
||||||
|
$color: $secondary-color,
|
||||||
|
$active-color: $primary-accent-color
|
||||||
|
) {
|
||||||
border-style: none;
|
border-style: none;
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
padding: 2px 10px 2px 10px;
|
padding: 2px 10px 2px 10px;
|
||||||
font-family: var(--font-family);
|
font-family: $font-family;
|
||||||
height: 40px;
|
height: 40px;
|
||||||
max-height: 40px;
|
max-height: 40px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
color: var(--color);
|
color: $color;
|
||||||
border: 1px solid;
|
border: 1px solid;
|
||||||
background-color: var(--background-color);
|
background-color: $bg-color;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
&:active {
|
||||||
|
background-color: $active-color;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
button:hover {
|
.primary {
|
||||||
cursor: pointer;
|
@include button();
|
||||||
|
}
|
||||||
|
.secondary {
|
||||||
|
@include button($secondary-color, $primary-color, $secondary-accent-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
button:active {
|
.tertiary {
|
||||||
background-color: var(--active);
|
@include button(transparent, $secondary-color, $primary-accent-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.danger {
|
||||||
|
@include button($danger-accent-color, $danger-color, $danger-active-color);
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,8 +1,4 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { Entry } from '@zip.js/zip.js';
|
|
||||||
import Button from './Button.svelte';
|
|
||||||
import { colors } from '$lib/theme';
|
|
||||||
|
|
||||||
export let accept: string | null | undefined = undefined;
|
export let accept: string | null | undefined = undefined;
|
||||||
export let files: FileList | null | undefined = undefined;
|
export let files: FileList | null | undefined = undefined;
|
||||||
export let multiple: boolean | null | undefined = true;
|
export let multiple: boolean | null | undefined = true;
|
||||||
@@ -30,14 +26,13 @@
|
|||||||
|
|
||||||
<button
|
<button
|
||||||
on:click={onClick}
|
on:click={onClick}
|
||||||
style:--border={colors.secondaryColor}
|
|
||||||
on:dragover|preventDefault
|
on:dragover|preventDefault
|
||||||
on:drop|preventDefault|stopPropagation={onDrop}
|
on:drop|preventDefault|stopPropagation={onDrop}
|
||||||
>
|
>
|
||||||
<p style:color={colors.secondaryColor}><slot>Upload</slot></p>
|
<p><slot>Upload</slot></p>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<style>
|
<style lang="scss">
|
||||||
input {
|
input {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
@@ -46,11 +41,12 @@
|
|||||||
width: 500px;
|
width: 500px;
|
||||||
height: 100px;
|
height: 100px;
|
||||||
border-radius: 12px;
|
border-radius: 12px;
|
||||||
border: 2px dashed var(--border);
|
border: 2px dashed $secondary-color;
|
||||||
}
|
}
|
||||||
|
|
||||||
p {
|
p {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
|
color: $secondary-color;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
47
src/lib/components/Modal.svelte
Normal file
47
src/lib/components/Modal.svelte
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
export let modal: HTMLDialogElement;
|
||||||
|
|
||||||
|
function closeClicked() {
|
||||||
|
modal.close();
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<dialog bind:this={modal}>
|
||||||
|
<button on:click={closeClicked}>X</button>
|
||||||
|
<h2 class="title">
|
||||||
|
<slot name="title" />
|
||||||
|
</h2>
|
||||||
|
<slot name="content" />
|
||||||
|
<div class="action">
|
||||||
|
<slot name="action" />
|
||||||
|
</div>
|
||||||
|
</dialog>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
dialog {
|
||||||
|
background-color: $secondary-color;
|
||||||
|
width: clamp(50vw, 500px, 90%);
|
||||||
|
border: 2px solid $primary-color;
|
||||||
|
border-radius: 12px;
|
||||||
|
}
|
||||||
|
dialog::backdrop {
|
||||||
|
background-color: rgba(black, 0.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
button {
|
||||||
|
color: black;
|
||||||
|
font-weight: bold;
|
||||||
|
position: absolute;
|
||||||
|
right: 10px;
|
||||||
|
top: 10px;
|
||||||
|
font-size: large;
|
||||||
|
}
|
||||||
|
|
||||||
|
.action {
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
.title {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
import { currentManga, currentVolume } from '$lib/catalog';
|
import { currentManga, currentVolume } from '$lib/catalog';
|
||||||
|
|
||||||
import { colors } from '$lib/theme';
|
|
||||||
import { writable } from 'svelte/store';
|
import { writable } from 'svelte/store';
|
||||||
let title: string | undefined = 'Mokuro';
|
let title: string | undefined = 'Mokuro';
|
||||||
let back: string | undefined = undefined;
|
let back: string | undefined = undefined;
|
||||||
@@ -40,7 +39,7 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<nav>
|
<nav>
|
||||||
<div style:background-color={colors.primaryColor}>
|
<div>
|
||||||
{#if back}
|
{#if back}
|
||||||
<a href={back}><h2>Back</h2></a>
|
<a href={back}><h2>Back</h2></a>
|
||||||
<h2>{title}</h2>
|
<h2>{title}</h2>
|
||||||
@@ -50,13 +49,14 @@
|
|||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
<style>
|
<style lang="scss">
|
||||||
nav {
|
nav {
|
||||||
position: relative;
|
position: relative;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
}
|
}
|
||||||
div {
|
div {
|
||||||
|
background-color: $primary-color;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
|||||||
@@ -1,31 +1,25 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { colorAlpha, colors } from '$lib/theme';
|
|
||||||
import { snackbarStore } from '$lib/util/snackbar';
|
import { snackbarStore } from '$lib/util/snackbar';
|
||||||
import { fade, fly } from 'svelte/transition';
|
import { fade, fly } from 'svelte/transition';
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if $snackbarStore?.message && $snackbarStore?.visible}
|
{#if $snackbarStore?.message && $snackbarStore?.visible}
|
||||||
<div
|
<div in:fly={{ y: 200, duration: 500 }} out:fade={{ duration: 500 }}>
|
||||||
in:fly={{ y: 200, duration: 500 }}
|
|
||||||
out:fade={{ duration: 500 }}
|
|
||||||
style:--background={colorAlpha(colors.primaryAccentColor, 0.9)}
|
|
||||||
style:--border={colors.secondaryColor}
|
|
||||||
class="toast"
|
|
||||||
>
|
|
||||||
{$snackbarStore?.message}
|
{$snackbarStore?.message}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<style>
|
<style lang="scss">
|
||||||
.toast {
|
div {
|
||||||
background-color: var(--background);
|
background-color: rgba($primary-accent-color, 0.9);
|
||||||
position: fixed;
|
position: fixed;
|
||||||
right: 10px;
|
right: 10px;
|
||||||
bottom: 10px;
|
bottom: 10px;
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
border: 1px solid var(--border);
|
border: 1px solid $secondary-color;
|
||||||
min-width: 250px;
|
min-width: 250px;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
z-index: 2;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
export const colors = {
|
|
||||||
backgroundColor: '#1b1b20',
|
|
||||||
|
|
||||||
primaryColor: '#2e3042',
|
|
||||||
primaryAccentColor: '#263447',
|
|
||||||
|
|
||||||
secondaryColor: '#dfdfe9',
|
|
||||||
secondaryAccentColor: ' #adadbb',
|
|
||||||
|
|
||||||
dangerColor: '#be3329',
|
|
||||||
dangerAccentColor: '#ddaeb2',
|
|
||||||
dangerActivecolor: '#b69092'
|
|
||||||
};
|
|
||||||
|
|
||||||
export function colorAlpha(hex: string, alpha: number) {
|
|
||||||
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
|
||||||
|
|
||||||
if (result) {
|
|
||||||
const { r, g, b } = {
|
|
||||||
r: parseInt(result[1], 16),
|
|
||||||
g: parseInt(result[2], 16),
|
|
||||||
b: parseInt(result[3], 16)
|
|
||||||
}
|
|
||||||
return `rgba(${r},${g},${b},${alpha})`
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,11 +2,29 @@
|
|||||||
import { goto } from '$app/navigation';
|
import { goto } from '$app/navigation';
|
||||||
import Button from '$lib/components/Button.svelte';
|
import Button from '$lib/components/Button.svelte';
|
||||||
import Catalog from '$lib/components/Catalog.svelte';
|
import Catalog from '$lib/components/Catalog.svelte';
|
||||||
|
import Modal from '$lib/components/Modal.svelte';
|
||||||
|
import { showSnackbar } from '$lib/util/snackbar';
|
||||||
|
|
||||||
function onClick() {
|
function onClick() {
|
||||||
goto('/upload');
|
goto('/upload');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let modal: HTMLDialogElement;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Button on:click={onClick}>Upload</Button>
|
<Button variant="primary" on:click={onClick}>Upload</Button>
|
||||||
|
<Button variant="secondary" on:click={() => showSnackbar('Snackbar')}>Upload</Button>
|
||||||
|
<Button variant="tertiary" on:click={() => modal.showModal()}>Upload</Button>
|
||||||
|
<Button variant="danger" on:click={onClick}>Upload</Button>
|
||||||
|
<Modal bind:modal>
|
||||||
|
<div slot="title">Title</div>
|
||||||
|
<div slot="content">
|
||||||
|
Content
|
||||||
|
<input type="text" />
|
||||||
|
</div>
|
||||||
|
<div slot="action">
|
||||||
|
<Button on:click={() => modal.close()}>Action</Button>
|
||||||
|
<Button variant="secondary" on:click={() => modal.close()}>Close</Button>
|
||||||
|
</div>
|
||||||
|
</Modal>
|
||||||
<Catalog />
|
<Catalog />
|
||||||
|
|||||||
Reference in New Issue
Block a user