Use custom scrollbar in stats screen, use grid layout and tweak CSS (#2154)

* Include base styles in graphs-base.scss

This includes the custom scrollbar styles, which were missing on the stats page.

* Set responsive grid layout on GraphsPage, use TitledContainer component

+ use global button style, tweak input appearance and other small changes

* Improve margins on GraphsPage
This commit is contained in:
Matthias Metelka 2022-11-02 09:23:08 +01:00 committed by GitHub
parent 1478801e4a
commit ee9af871b7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 85 additions and 55 deletions

View file

@ -55,6 +55,7 @@ button {
/* override transition for instant hover response */ /* override transition for instant hover response */
transition: color 0.15s ease-in-out, box-shadow 0.15s ease-in-out !important; transition: color 0.15s ease-in-out, box-shadow 0.15s ease-in-out !important;
border-radius: prop(border-radius); border-radius: prop(border-radius);
@include button.base;
} }
pre, pre,
@ -113,3 +114,17 @@ select {
color: color(fg); color: color(fg);
} }
} }
label,
input[type="radio"],
input[type="checkbox"] {
cursor: pointer;
}
input[type="text"] {
border-radius: prop(border-radius);
outline: none;
border: 1px solid color(border);
&:focus {
border-color: color(border-focus);
}
}

View file

@ -5,11 +5,16 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
<script lang="ts"> <script lang="ts">
import { pageTheme } from "../sveltelib/theme"; import { pageTheme } from "../sveltelib/theme";
export let id: string | undefined = undefined;
let className: string = "";
export { className as class };
export let title: string; export let title: string;
</script> </script>
<div <div
class="container" {id}
class="container {className}"
class:light={!$pageTheme.isDark} class:light={!$pageTheme.isDark}
class:dark={$pageTheme.isDark} class:dark={$pageTheme.isDark}
style:--gutter-block="2px" style:--gutter-block="2px"

View file

@ -3,8 +3,8 @@ Copyright: Ankitects Pty Ltd and contributors
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
--> -->
<script lang="ts"> <script lang="ts">
import TitledContainer from "../components/TitledContainer.svelte";
import type { DeckOptionsState } from "./lib"; import type { DeckOptionsState } from "./lib";
import TitledContainer from "./TitledContainer.svelte";
export let state: DeckOptionsState; export let state: DeckOptionsState;

View file

@ -8,6 +8,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import DynamicallySlottable from "../components/DynamicallySlottable.svelte"; import DynamicallySlottable from "../components/DynamicallySlottable.svelte";
import Item from "../components/Item.svelte"; import Item from "../components/Item.svelte";
import TitledContainer from "../components/TitledContainer.svelte";
import * as tr from "../lib/ftl"; import * as tr from "../lib/ftl";
import CardStateCustomizer from "./CardStateCustomizer.svelte"; import CardStateCustomizer from "./CardStateCustomizer.svelte";
import HelpModal from "./HelpModal.svelte"; import HelpModal from "./HelpModal.svelte";
@ -15,7 +16,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import SettingTitle from "./SettingTitle.svelte"; import SettingTitle from "./SettingTitle.svelte";
import SpinBoxFloatRow from "./SpinBoxFloatRow.svelte"; import SpinBoxFloatRow from "./SpinBoxFloatRow.svelte";
import SpinBoxRow from "./SpinBoxRow.svelte"; import SpinBoxRow from "./SpinBoxRow.svelte";
import TitledContainer from "./TitledContainer.svelte";
import type { DeckOption } from "./types"; import type { DeckOption } from "./types";
export let state: DeckOptionsState; export let state: DeckOptionsState;

View file

@ -8,12 +8,12 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import DynamicallySlottable from "../components/DynamicallySlottable.svelte"; import DynamicallySlottable from "../components/DynamicallySlottable.svelte";
import Item from "../components/Item.svelte"; import Item from "../components/Item.svelte";
import TitledContainer from "../components/TitledContainer.svelte";
import * as tr from "../lib/ftl"; import * as tr from "../lib/ftl";
import HelpModal from "./HelpModal.svelte"; import HelpModal from "./HelpModal.svelte";
import type { DeckOptionsState } from "./lib"; import type { DeckOptionsState } from "./lib";
import SettingTitle from "./SettingTitle.svelte"; import SettingTitle from "./SettingTitle.svelte";
import SwitchRow from "./SwitchRow.svelte"; import SwitchRow from "./SwitchRow.svelte";
import TitledContainer from "./TitledContainer.svelte";
import type { DeckOption } from "./types"; import type { DeckOption } from "./types";
export let state: DeckOptionsState; export let state: DeckOptionsState;

View file

@ -8,12 +8,12 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import DynamicallySlottable from "../components/DynamicallySlottable.svelte"; import DynamicallySlottable from "../components/DynamicallySlottable.svelte";
import Item from "../components/Item.svelte"; import Item from "../components/Item.svelte";
import TitledContainer from "../components/TitledContainer.svelte";
import * as tr from "../lib/ftl"; import * as tr from "../lib/ftl";
import HelpModal from "./HelpModal.svelte"; import HelpModal from "./HelpModal.svelte";
import type { DeckOptionsState } from "./lib"; import type { DeckOptionsState } from "./lib";
import SettingTitle from "./SettingTitle.svelte"; import SettingTitle from "./SettingTitle.svelte";
import SwitchRow from "./SwitchRow.svelte"; import SwitchRow from "./SwitchRow.svelte";
import TitledContainer from "./TitledContainer.svelte";
import type { DeckOption } from "./types"; import type { DeckOption } from "./types";
export let state: DeckOptionsState; export let state: DeckOptionsState;

View file

@ -8,6 +8,7 @@
import DynamicallySlottable from "../components/DynamicallySlottable.svelte"; import DynamicallySlottable from "../components/DynamicallySlottable.svelte";
import Item from "../components/Item.svelte"; import Item from "../components/Item.svelte";
import TitledContainer from "../components/TitledContainer.svelte";
import * as tr from "../lib/ftl"; import * as tr from "../lib/ftl";
import HelpModal from "./HelpModal.svelte"; import HelpModal from "./HelpModal.svelte";
import type { DeckOptionsState } from "./lib"; import type { DeckOptionsState } from "./lib";
@ -15,7 +16,6 @@
import SettingTitle from "./SettingTitle.svelte"; import SettingTitle from "./SettingTitle.svelte";
import SpinBoxRow from "./SpinBoxRow.svelte"; import SpinBoxRow from "./SpinBoxRow.svelte";
import TabbedValue from "./TabbedValue.svelte"; import TabbedValue from "./TabbedValue.svelte";
import TitledContainer from "./TitledContainer.svelte";
import type { DeckOption } from "./types"; import type { DeckOption } from "./types";
import Warning from "./Warning.svelte"; import Warning from "./Warning.svelte";

View file

@ -8,6 +8,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import DynamicallySlottable from "../components/DynamicallySlottable.svelte"; import DynamicallySlottable from "../components/DynamicallySlottable.svelte";
import Item from "../components/Item.svelte"; import Item from "../components/Item.svelte";
import TitledContainer from "../components/TitledContainer.svelte";
import * as tr from "../lib/ftl"; import * as tr from "../lib/ftl";
import { DeckConfig } from "../lib/proto"; import { DeckConfig } from "../lib/proto";
import EnumSelectorRow from "./EnumSelectorRow.svelte"; import EnumSelectorRow from "./EnumSelectorRow.svelte";
@ -15,7 +16,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import type { DeckOptionsState } from "./lib"; import type { DeckOptionsState } from "./lib";
import SettingTitle from "./SettingTitle.svelte"; import SettingTitle from "./SettingTitle.svelte";
import { reviewMixChoices } from "./strings"; import { reviewMixChoices } from "./strings";
import TitledContainer from "./TitledContainer.svelte";
import type { DeckOption } from "./types"; import type { DeckOption } from "./types";
export let state: DeckOptionsState; export let state: DeckOptionsState;

View file

@ -8,6 +8,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import DynamicallySlottable from "../components/DynamicallySlottable.svelte"; import DynamicallySlottable from "../components/DynamicallySlottable.svelte";
import Item from "../components/Item.svelte"; import Item from "../components/Item.svelte";
import TitledContainer from "../components/TitledContainer.svelte";
import * as tr from "../lib/ftl"; import * as tr from "../lib/ftl";
import EnumSelectorRow from "./EnumSelectorRow.svelte"; import EnumSelectorRow from "./EnumSelectorRow.svelte";
import HelpModal from "./HelpModal.svelte"; import HelpModal from "./HelpModal.svelte";
@ -15,7 +16,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import SettingTitle from "./SettingTitle.svelte"; import SettingTitle from "./SettingTitle.svelte";
import SpinBoxRow from "./SpinBoxRow.svelte"; import SpinBoxRow from "./SpinBoxRow.svelte";
import StepsInputRow from "./StepsInputRow.svelte"; import StepsInputRow from "./StepsInputRow.svelte";
import TitledContainer from "./TitledContainer.svelte";
import type { DeckOption } from "./types"; import type { DeckOption } from "./types";
import Warning from "./Warning.svelte"; import Warning from "./Warning.svelte";

View file

@ -8,6 +8,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import DynamicallySlottable from "../components/DynamicallySlottable.svelte"; import DynamicallySlottable from "../components/DynamicallySlottable.svelte";
import Item from "../components/Item.svelte"; import Item from "../components/Item.svelte";
import TitledContainer from "../components/TitledContainer.svelte";
import * as tr from "../lib/ftl"; import * as tr from "../lib/ftl";
import { DeckConfig } from "../lib/proto"; import { DeckConfig } from "../lib/proto";
import EnumSelectorRow from "./EnumSelectorRow.svelte"; import EnumSelectorRow from "./EnumSelectorRow.svelte";
@ -16,7 +17,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import SettingTitle from "./SettingTitle.svelte"; import SettingTitle from "./SettingTitle.svelte";
import SpinBoxRow from "./SpinBoxRow.svelte"; import SpinBoxRow from "./SpinBoxRow.svelte";
import StepsInputRow from "./StepsInputRow.svelte"; import StepsInputRow from "./StepsInputRow.svelte";
import TitledContainer from "./TitledContainer.svelte";
import type { DeckOption } from "./types"; import type { DeckOption } from "./types";
import Warning from "./Warning.svelte"; import Warning from "./Warning.svelte";

View file

@ -8,13 +8,13 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import DynamicallySlottable from "../components/DynamicallySlottable.svelte"; import DynamicallySlottable from "../components/DynamicallySlottable.svelte";
import Item from "../components/Item.svelte"; import Item from "../components/Item.svelte";
import TitledContainer from "../components/TitledContainer.svelte";
import * as tr from "../lib/ftl"; import * as tr from "../lib/ftl";
import HelpModal from "./HelpModal.svelte"; import HelpModal from "./HelpModal.svelte";
import type { DeckOptionsState } from "./lib"; import type { DeckOptionsState } from "./lib";
import SettingTitle from "./SettingTitle.svelte"; import SettingTitle from "./SettingTitle.svelte";
import SpinBoxRow from "./SpinBoxRow.svelte"; import SpinBoxRow from "./SpinBoxRow.svelte";
import SwitchRow from "./SwitchRow.svelte"; import SwitchRow from "./SwitchRow.svelte";
import TitledContainer from "./TitledContainer.svelte";
import type { DeckOption } from "./types"; import type { DeckOption } from "./types";
import Warning from "./Warning.svelte"; import Warning from "./Warning.svelte";

View file

@ -45,11 +45,11 @@ export async function setupDeckOptions(did: number): Promise<DeckOptionsPage> {
}); });
} }
import TitledContainer from "../components/TitledContainer.svelte";
import EnumSelectorRow from "./EnumSelectorRow.svelte"; import EnumSelectorRow from "./EnumSelectorRow.svelte";
import SpinBoxFloatRow from "./SpinBoxFloatRow.svelte"; import SpinBoxFloatRow from "./SpinBoxFloatRow.svelte";
import SpinBoxRow from "./SpinBoxRow.svelte"; import SpinBoxRow from "./SpinBoxRow.svelte";
import SwitchRow from "./SwitchRow.svelte"; import SwitchRow from "./SwitchRow.svelte";
import TitledContainer from "./TitledContainer.svelte";
export const components = { export const components = {
TitledContainer, TitledContainer,

View file

@ -14,12 +14,14 @@ compile_sass(
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
deps = [ deps = [
"//sass:base_lib", "//sass:base_lib",
"//sass:button_mixins_lib",
"//sass:scrollbar_lib", "//sass:scrollbar_lib",
], ],
) )
_ts_deps = [ _ts_deps = [
"//ts/lib", "//ts/lib",
"//ts/components",
"//ts/sveltelib", "//ts/sveltelib",
"@npm//@fluent", "@npm//@fluent",
"@npm//@types/d3", "@npm//@types/d3",
@ -68,6 +70,7 @@ svelte_check(
"*.ts", "*.ts",
"*.svelte", "*.svelte",
]) + [ ]) + [
"//sass:button_mixins_lib",
"//ts/lib", "//ts/lib",
"//ts/sveltelib", "//ts/sveltelib",
], ],

View file

@ -3,25 +3,24 @@ Copyright: Ankitects Pty Ltd and contributors
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
--> -->
<script lang="ts"> <script lang="ts">
import TitledContainer from "../components/TitledContainer.svelte";
export let title: string; export let title: string;
export let subtitle: string | null = null; export let subtitle: string | null = null;
</script> </script>
<div class="graph" tabindex="-1"> <TitledContainer {title}>
<h1>{title}</h1> <div class="graph">
{#if subtitle}
{#if subtitle} <div class="subtitle">{subtitle}</div>
<div class="subtitle">{subtitle}</div> {/if}
{/if} <slot />
</div>
<slot /> </TitledContainer>
</div>
<style lang="scss"> <style lang="scss">
@use "sass/elevation" as *;
.graph { .graph {
margin-left: auto;
margin-right: auto;
max-width: 60em;
page-break-inside: avoid; page-break-inside: avoid;
/* See graph-styles.ts for constants referencing global styles */ /* See graph-styles.ts for constants referencing global styles */
@ -63,13 +62,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
} }
} }
h1 {
text-align: center;
margin-bottom: 0.25em;
margin-top: 1.5em;
font-weight: bold;
}
.subtitle { .subtitle {
text-align: center; text-align: center;
margin-bottom: 1em; margin-bottom: 1em;

View file

@ -24,19 +24,19 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
} }
</script> </script>
<div> <WithGraphData
<WithGraphData {search}
{search} {days}
{days} let:loading
let:loading let:sourceData
let:sourceData let:preferences
let:preferences let:revlogRange
let:revlogRange >
> {#if controller}
{#if controller} <svelte:component this={controller} {search} {days} {loading} />
<svelte:component this={controller} {search} {days} {loading} /> {/if}
{/if}
<div class="graphs-container">
{#if sourceData && preferences && revlogRange} {#if sourceData && preferences && revlogRange}
{#each graphs as graph} {#each graphs as graph}
<svelte:component <svelte:component
@ -49,13 +49,25 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
/> />
{/each} {/each}
{/if} {/if}
</WithGraphData> </div>
</div> <div class="spacer" />
</WithGraphData>
<style lang="scss"> <style lang="scss">
div { .graphs-container {
display: grid;
gap: 1.5em;
grid-template-columns: 50% 50%;
@media only screen and (max-width: 1200px) {
grid-template-columns: 100%;
}
@media only screen and (max-width: 600px) { @media only screen and (max-width: 600px) {
font-size: 12px; font-size: 12px;
} }
} }
.spacer {
height: 1.5em;
}
</style> </style>

View file

@ -113,13 +113,14 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
<style lang="scss"> <style lang="scss">
.range-box { .range-box {
position: fixed; position: sticky;
z-index: 1; z-index: 1;
top: 0; top: 0;
width: 100%; width: 100vw;
color: var(--fg); color: var(--fg);
background: var(--canvas); background: var(--canvas);
padding: 0.5em; padding: 0.5em;
border-bottom: 1px solid var(--border);
@media print { @media print {
position: absolute; position: absolute;
@ -152,6 +153,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
} }
.range-box-pad { .range-box-pad {
height: 2em; height: 1.5em;
} }
</style> </style>

View file

@ -1,12 +1,10 @@
@use "root-vars"; @use "root-vars";
@use "sass/button-mixins" as button; @import "sass/base";
label, body {
input[type="radio"], padding: 0 1em 1em 1em;
input[type="checkbox"] {
cursor: pointer;
} }
button { button {
@include button.base; margin-bottom: 5px;
} }

View file

@ -1,5 +1,9 @@
{ {
"extends": "../tsconfig.json", "extends": "../tsconfig.json",
"include": ["*"], "include": ["*"],
"references": [{ "path": "../lib" }, { "path": "../sveltelib" }] "references": [
{ "path": "../lib" },
{ "path": "../components" },
{ "path": "../sveltelib" }
]
} }