switch config to a grid; move info to popups

This commit is contained in:
Damien Elmes 2021-04-22 15:39:50 +10:00
parent c5eedfb21e
commit 5eb5664c12
10 changed files with 130 additions and 72 deletions

View File

@ -34,6 +34,7 @@ copy_bootstrap_icons(
name = "bootstrap-icons", name = "bootstrap-icons",
icons = [ icons = [
"arrow-counterclockwise.svg", "arrow-counterclockwise.svg",
"info-circle.svg",
], ],
) )
@ -44,6 +45,7 @@ ts_library(
"DeckConfigPage", "DeckConfigPage",
"lib", "lib",
"//ts/lib", "//ts/lib",
"@npm//@popperjs",
"@npm//svelte2tsx", "@npm//svelte2tsx",
], ],
) )

View File

@ -20,6 +20,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
:global(input, select) { :global(input, select) {
font-size: 16px; font-size: 16px;
text-align: right;
} }
</style> </style>

View File

@ -4,6 +4,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
--> -->
<script lang="ts"> <script lang="ts">
import RevertIcon from "./RevertIcon.svelte"; import RevertIcon from "./RevertIcon.svelte";
import HelpPopup from "./HelpPopup.svelte";
export let label: string; export let label: string;
export let subLabel = ""; export let subLabel = "";
@ -17,28 +18,58 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
.outer { .outer {
margin-top: 1em; margin-top: 1em;
& > * { display: grid;
margin-top: 0.3em; grid-template-columns: 1fr 1fr;
} grid-column-gap: 0.5em;
} }
.label { .full-grid-width {
font-weight: bold; grid-row-start: 2;
grid-column: 1 / 3;
}
.table {
display: table;
height: 100%;
}
.vcenter {
display: table-cell;
vertical-align: middle;
}
.alert {
margin-top: 0.5em;
}
.input-grid {
// width: 90vw;
display: grid;
grid-column-gap: 0.5em;
grid-template-columns: 10fr 1fr;
} }
</style> </style>
<div class="outer"> <div class="outer">
<span class="label">{label}</span> <div class="table">
<RevertIcon bind:value {defaultValue} on:revert /> <span class="vcenter">
<div class="sub">{subLabel}</div> {label}
{#if subLabel}
<div class="inner"> <HelpPopup html={subLabel} />
<slot /> {/if}
</span>
</div> </div>
{#each warnings as warning} <div class="input-grid">
{#if warning} <slot />
<div class="alert alert-warning">{warning}</div> <RevertIcon bind:value {defaultValue} on:revert />
{/if} </div>
{/each}
<div class="full-grid-width">
{#each warnings as warning}
{#if warning}
<div class="alert alert-warning">{warning}</div>
{/if}
{/each}
</div>
</div> </div>

View File

@ -21,52 +21,36 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
</script> </script>
<style lang="scss"> <style lang="scss">
.form-select { .sticky-bar {
grid-column: 1 / 5; position: sticky;
}
.fixed-bar {
position: fixed;
z-index: 1; z-index: 1;
top: 0; top: 0;
left: 0;
width: 100%;
color: var(--text-fg); color: var(--text-fg);
background: var(--window-bg); background: var(--window-bg);
display: flex; padding-bottom: 0.5em;
justify-content: center;
} }
.grid { .selector-grid {
display: grid; display: grid;
grid-template-columns: 1fr 1fr 1fr 1fr 1fr; grid-template-columns: 6fr 1fr;
grid-column-gap: 0.5em; grid-column-gap: 0.5em;
} padding-right: 0.5em;
.padding {
height: 3em;
} }
</style> </style>
<div class="fixed-bar"> <div class="sticky-bar">
<div class="width-limited"> <div>{tr.actionsOptionsFor({ val: state.currentDeck.name })}</div>
<div>{tr.actionsOptionsFor({ val: state.currentDeck.name })}</div>
<div class="grid"> <div class="selector-grid">
<!-- svelte-ignore a11y-no-onchange --> <!-- svelte-ignore a11y-no-onchange -->
<select class="form-select" on:change={blur}> <select class="form-select" on:change={blur}>
{#each $configList as entry} {#each $configList as entry}
<option value={entry.idx} selected={entry.current}> <option value={entry.idx} selected={entry.current}>
{configLabel(entry)} {configLabel(entry)}
</option> </option>
{/each} {/each}
</select> </select>
<OptionsDropdown {state} /> <OptionsDropdown {state} />
</div>
</div> </div>
</div> </div>
<div class="padding">
<!-- make sure subsequent content doesn't flow under us -->
</div>

View File

@ -10,15 +10,10 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
export let state: DeckConfigState; export let state: DeckConfigState;
</script> </script>
<style> <style lang="scss">
.outer { .editor {
display: flex; // without this, the initial viewport can be wrong
justify-content: center; overflow-x: hidden;
}
:global(.width-limited) {
width: 40em;
padding: 0.5em;
} }
</style> </style>
@ -28,8 +23,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
<ConfigSelector {state} /> <ConfigSelector {state} />
<div class="outer"> <div class="editor">
<div class="width-limited"> <ConfigEditor {state} />
<ConfigEditor {state} />
</div>
</div> </div>

View File

@ -0,0 +1,32 @@
<!--
Copyright: Ankitects Pty Ltd and contributors
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
<script lang="ts">
import { infoCircle } from "./icons";
import { onMount } from "svelte";
import Tooltip from "bootstrap/js/dist/tooltip";
export let html: string;
let ref: HTMLAnchorElement;
onMount(() => {
new Tooltip(ref, { placement: "bottom", html: true, offset: [0, 20] });
});
</script>
<style>
:global(svg) {
vertical-align: text-bottom;
}
</style>
<span
href={'#'}
bind:this={ref}
data-toggle="tooltip"
data-placement="bottom"
title={html}>
{@html infoCircle}
</span>

View File

@ -23,11 +23,16 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
</script> </script>
<style> <style>
.img-div {
display: flex;
}
:global(svg) { :global(svg) {
vertical-align: text-bottom; align-self: center;
} }
</style> </style>
{#if modified} {#if modified}
<span on:click={revert}>{@html revertIcon}</span> <div class="img-div" on:click={revert}>
{@html revertIcon}
</div>
{/if} {/if}

View File

@ -29,12 +29,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
} }
</script> </script>
<style lang="scss">
input {
width: 100%;
}
</style>
<ConfigEntry {label} {subLabel} {value} {defaultValue} {warnings} on:revert={revert}> <ConfigEntry {label} {subLabel} {value} {defaultValue} {warnings} on:revert={revert}>
<input type="text" value={stringValue} on:blur={update} class="form-control" /> <input type="text" value={stringValue} on:blur={update} class="form-control" />
</ConfigEntry> </ConfigEntry>

View File

@ -8,6 +8,7 @@
@import "ts/sass/bootstrap/modal"; @import "ts/sass/bootstrap/modal";
@import "ts/sass/bootstrap/close"; @import "ts/sass/bootstrap/close";
@import "ts/sass/bootstrap/alert"; @import "ts/sass/bootstrap/alert";
@import "ts/sass/bootstrap/tooltip";
.night-mode { .night-mode {
@include scrollbar.night-mode; @include scrollbar.night-mode;
@ -17,3 +18,16 @@
.form-select { .form-select {
-webkit-appearance: none; -webkit-appearance: none;
} }
body {
width: min(100vw, 40em);
margin: 0 auto;
}
html {
overflow-x: hidden;
}
#main {
padding: 0.5em;
}

View File

@ -4,4 +4,6 @@
// Import icons from bootstrap // Import icons from bootstrap
import revertIcon from "./arrow-counterclockwise.svg"; import revertIcon from "./arrow-counterclockwise.svg";
export { revertIcon }; import infoCircle from "./info-circle.svg";
export { revertIcon, infoCircle };