mirror of
https://github.com/wukko/cobalt.git
synced 2024-11-15 12:50:01 +00:00
web: full SmallDialog component, one flexible meowbalt component
- fully stylized small dialog: header, title, subtext, state without meowbalt - moved meowbalt into his own adaptive component, no need to import/create new ones for each emotion - better types for dialog related stuff - type for meowbalt's emotions - better padding in small dialog
This commit is contained in:
parent
e541bdc6d7
commit
720b3c5f68
11 changed files with 86 additions and 62 deletions
|
@ -4,10 +4,11 @@
|
||||||
import { killDialog } from "$lib/dialogs";
|
import { killDialog } from "$lib/dialogs";
|
||||||
import type { DialogButton } from "$lib/types/dialog";
|
import type { DialogButton } from "$lib/types/dialog";
|
||||||
|
|
||||||
import MeowbaltError from "$components/meowbalt/MeowbaltError.svelte";
|
import Meowbalt from "$components/misc/Meowbalt.svelte";
|
||||||
|
import type { MeowbaltEmotions } from "$lib/types/meowbalt";
|
||||||
|
|
||||||
export let id: string;
|
export let id: string;
|
||||||
export let meowbalt: string = "";
|
export let meowbalt: MeowbaltEmotions;
|
||||||
export let title: string = "";
|
export let title: string = "";
|
||||||
export let bodyText: string = "";
|
export let bodyText: string = "";
|
||||||
export let bodySubText: string = "";
|
export let bodySubText: string = "";
|
||||||
|
@ -39,16 +40,16 @@
|
||||||
|
|
||||||
<dialog id="dialog-{id}" bind:this={dialogParent} class:closing class:open>
|
<dialog id="dialog-{id}" bind:this={dialogParent} class:closing class:open>
|
||||||
<div class="dialog-body small-dialog" class:meowbalt-visible={meowbalt}>
|
<div class="dialog-body small-dialog" class:meowbalt-visible={meowbalt}>
|
||||||
{#if meowbalt === "error"}
|
{#if meowbalt}
|
||||||
<div class="meowbalt-container">
|
<div class="meowbalt-container">
|
||||||
<MeowbaltError />
|
<Meowbalt emotion={meowbalt} />
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
<div class="popup-header">
|
{#if title}
|
||||||
{#if title}
|
<div class="popup-header">
|
||||||
<h2>{title}</h2>
|
<h2>{title}</h2>
|
||||||
{/if}
|
</div>
|
||||||
</div>
|
{/if}
|
||||||
<div class="popup-body">
|
<div class="popup-body">
|
||||||
{#if bodyText}
|
{#if bodyText}
|
||||||
<div class="body-text" tabindex="-1">{bodyText}</div>
|
<div class="body-text" tabindex="-1">{bodyText}</div>
|
||||||
|
@ -60,7 +61,7 @@
|
||||||
<div class="popup-buttons">
|
<div class="popup-buttons">
|
||||||
{#each buttons as button}
|
{#each buttons as button}
|
||||||
<button
|
<button
|
||||||
class="button popup-button"
|
class="button elevated popup-button"
|
||||||
class:active={button.main}
|
class:active={button.main}
|
||||||
on:click={async () => {
|
on:click={async () => {
|
||||||
await button.action();
|
await button.action();
|
||||||
|
@ -108,13 +109,15 @@
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.small-dialog {
|
.small-dialog,
|
||||||
--small-dialog-padding: 18px;
|
.popup-body {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
|
||||||
text-align: center;
|
|
||||||
gap: var(--padding);
|
gap: var(--padding);
|
||||||
|
}
|
||||||
|
|
||||||
|
.small-dialog {
|
||||||
|
--small-dialog-padding: 18px;
|
||||||
max-width: 340px;
|
max-width: 340px;
|
||||||
width: calc(
|
width: calc(
|
||||||
100% - var(--padding) * 2 - var(--small-dialog-padding) * 2
|
100% - var(--padding) * 2 - var(--small-dialog-padding) * 2
|
||||||
|
@ -140,12 +143,18 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.small-dialog.meowbalt-visible {
|
.small-dialog.meowbalt-visible {
|
||||||
padding-top: 45px;
|
padding-top: calc(var(--padding) * 4);
|
||||||
|
align-items: center;
|
||||||
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.meowbalt-container {
|
.meowbalt-container {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: -110px;
|
top: -120px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.popup-header {
|
||||||
|
color: var(--secondary);
|
||||||
}
|
}
|
||||||
|
|
||||||
.body-text {
|
.body-text {
|
||||||
|
@ -173,6 +182,20 @@
|
||||||
height: 40px;
|
height: 40px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.popup-button:not(.active) {
|
||||||
|
background-color: var(--button-elevated);
|
||||||
|
}
|
||||||
|
|
||||||
|
.popup-button:not(:focus-visible) {
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (hover: hover) {
|
||||||
|
.popup-button:not(.active):hover {
|
||||||
|
background-color: var(--button-elevated-hover);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#dialog-backdrop {
|
#dialog-backdrop {
|
||||||
--backdrop-opacity: 0.4;
|
--backdrop-opacity: 0.4;
|
||||||
background-color: var(--popup-backdrop);
|
background-color: var(--popup-backdrop);
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
<script lang="ts">
|
|
||||||
import { t } from "$lib/i18n/translations";
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<img
|
|
||||||
id="meowbalt-error"
|
|
||||||
src="/meowbalt/error.png"
|
|
||||||
height="160"
|
|
||||||
alt={$t("a11y.meowbalt.error")}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
#meowbalt-error {
|
|
||||||
display: block;
|
|
||||||
margin: 0;
|
|
||||||
object-fit: cover;
|
|
||||||
margin-left: 25px;
|
|
||||||
}
|
|
||||||
</style>
|
|
|
@ -1,18 +0,0 @@
|
||||||
<script lang="ts">
|
|
||||||
import { t } from "$lib/i18n/translations";
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<img
|
|
||||||
id="meowbalt-loaf"
|
|
||||||
src="/meowbalt/smile.png"
|
|
||||||
height="152"
|
|
||||||
alt={$t("a11y.meowbalt.smile")}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
#meowbalt-loaf {
|
|
||||||
display: block;
|
|
||||||
margin: 0;
|
|
||||||
object-fit: cover;
|
|
||||||
}
|
|
||||||
</style>
|
|
31
web/src/components/misc/Meowbalt.svelte
Normal file
31
web/src/components/misc/Meowbalt.svelte
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
<script lang="ts">
|
||||||
|
import { t } from "$lib/i18n/translations";
|
||||||
|
|
||||||
|
import type { MeowbaltEmotions } from "$lib/types/meowbalt";
|
||||||
|
|
||||||
|
export let emotion: MeowbaltEmotions;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<img
|
||||||
|
class="meowbalt {emotion}"
|
||||||
|
src="/meowbalt/{emotion}.png"
|
||||||
|
height="152"
|
||||||
|
alt={$t(`a11y.meowbalt.${emotion}`)}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.meowbalt {
|
||||||
|
display: block;
|
||||||
|
margin: 0;
|
||||||
|
object-fit: cover;
|
||||||
|
}
|
||||||
|
|
||||||
|
.think,
|
||||||
|
.error {
|
||||||
|
height: 160px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.error {
|
||||||
|
margin-left: 25px;
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -1,10 +1,11 @@
|
||||||
<script>
|
<script>
|
||||||
import MeowbaltLoaf from "$components/meowbalt/MeowbaltLoaf.svelte";
|
import Meowbalt from "$components/misc/Meowbalt.svelte";
|
||||||
|
|
||||||
export let pageName;
|
export let pageName;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div id="placeholder-container" class="center-column-container">
|
<div id="placeholder-container" class="center-column-container">
|
||||||
<MeowbaltLoaf />
|
<Meowbalt emotion="smile" />
|
||||||
<div>{pageName} page is not ready yet!</div>
|
<div>{pageName} page is not ready yet!</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -20,15 +20,12 @@
|
||||||
id: "save-error",
|
id: "save-error",
|
||||||
type: "small",
|
type: "small",
|
||||||
meowbalt: "error",
|
meowbalt: "error",
|
||||||
title: "",
|
|
||||||
bodySubText: "",
|
|
||||||
buttons: [{
|
buttons: [{
|
||||||
text: $t("general.gotit"),
|
text: $t("general.gotit"),
|
||||||
color: "gray",
|
|
||||||
main: true,
|
main: true,
|
||||||
action: () => {},
|
action: () => {},
|
||||||
}]
|
}]
|
||||||
}
|
} as DialogInfo
|
||||||
|
|
||||||
const changeDownloadButton = (state: string) => {
|
const changeDownloadButton = (state: string) => {
|
||||||
isDisabled = true;
|
isDisabled = true;
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
|
import type { MeowbaltEmotions } from "$lib/types/meowbalt";
|
||||||
|
|
||||||
export type DialogButton = {
|
export type DialogButton = {
|
||||||
text: string,
|
text: string,
|
||||||
color: string,
|
color: "blue" | "red" | "default",
|
||||||
main: boolean,
|
main: boolean,
|
||||||
action: () => unknown | Promise<unknown>
|
action: () => unknown | Promise<unknown>
|
||||||
}
|
}
|
||||||
|
@ -8,7 +10,7 @@ export type DialogButton = {
|
||||||
export type DialogInfo = {
|
export type DialogInfo = {
|
||||||
id: string,
|
id: string,
|
||||||
type: "small",
|
type: "small",
|
||||||
meowbalt: "error",
|
meowbalt: MeowbaltEmotions | "",
|
||||||
title: string,
|
title: string,
|
||||||
bodyText: string,
|
bodyText: string,
|
||||||
bodySubText: string,
|
bodySubText: string,
|
||||||
|
|
1
web/src/lib/types/meowbalt.ts
Normal file
1
web/src/lib/types/meowbalt.ts
Normal file
|
@ -0,0 +1 @@
|
||||||
|
export type MeowbaltEmotions = "smile" | "error" | "question" | "think";
|
|
@ -71,6 +71,9 @@
|
||||||
--button-text: #282828;
|
--button-text: #282828;
|
||||||
--button-box-shadow: 0 0 0 1.5px var(--button-stroke) inset;
|
--button-box-shadow: 0 0 0 1.5px var(--button-stroke) inset;
|
||||||
|
|
||||||
|
--button-elevated: #e3e3e3;
|
||||||
|
--button-elevated-hover: #dadada;
|
||||||
|
|
||||||
--popup-bg: #f1f1f1;
|
--popup-bg: #f1f1f1;
|
||||||
--popup-backdrop: var(--primary);
|
--popup-backdrop: var(--primary);
|
||||||
--popup-stroke: rgba(0, 0, 0, 0.08);
|
--popup-stroke: rgba(0, 0, 0, 0.08);
|
||||||
|
@ -126,6 +129,9 @@
|
||||||
--button-text: #e1e1e1;
|
--button-text: #e1e1e1;
|
||||||
--button-box-shadow: 0 0 0 1.5px var(--button-stroke) inset;
|
--button-box-shadow: 0 0 0 1.5px var(--button-stroke) inset;
|
||||||
|
|
||||||
|
--button-elevated: #282828;
|
||||||
|
--button-elevated-hover: #2f2f2f;
|
||||||
|
|
||||||
--popup-bg: #191919;
|
--popup-bg: #191919;
|
||||||
--popup-backdrop: var(--primary);
|
--popup-backdrop: var(--primary);
|
||||||
--popup-stroke: rgba(255, 255, 255, 0.08);
|
--popup-stroke: rgba(255, 255, 255, 0.08);
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
import { t } from "$lib/i18n/translations";
|
import { t } from "$lib/i18n/translations";
|
||||||
|
|
||||||
import Omnibox from "$components/save/Omnibox.svelte";
|
import Omnibox from "$components/save/Omnibox.svelte";
|
||||||
import MeowbaltLoaf from "$components/meowbalt/MeowbaltLoaf.svelte";
|
import Meowbalt from "$components/misc/Meowbalt.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
<div id="cobalt-save-container" class="center-column-container">
|
<div id="cobalt-save-container" class="center-column-container">
|
||||||
<main id="cobalt-save">
|
<main id="cobalt-save">
|
||||||
<MeowbaltLoaf />
|
<Meowbalt emotion="smile" />
|
||||||
<Omnibox />
|
<Omnibox />
|
||||||
</main>
|
</main>
|
||||||
<div id="terms-note">
|
<div id="terms-note">
|
||||||
|
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
Loading…
Reference in a new issue