anki/ts/deck-options/DeckOptionsPage.svelte
Henrik Giesel ab6a68ec49
Introduce our own Container, Row, and Col components (#1495)
* Refactor out Placeholder from CardInfo.svelte

* Add breakpoint parameter for Container

- Use `Container` component inside `TitledContainer`

* Build Item into Row

- Use Row in DeckOptionsPage instead of just Item

* Reengineer Container/Row/Col CSS

* Inline Badges next to Labels when Lable spans multiple rows

* Adjust margins for mobile

* Implement Col component breakpoints

* Move card-info to use new Container and Row components

* Join StickyHeader and StickyFooter to StickyContainer

* Remove default middle vertical-alignment for Badges again

* Satisfy tests

* Restore inline gutters in change-notetype Mapper

* Add some comment to Col and Container

* Fix breaking behavior in DeckOptionsPage when multi-column

* Add back toolbar left padding to counter-act buttongroup right margins

* Make Label in SwitchRow take more of available space
2021-11-17 13:49:52 +10:00

134 lines
3.7 KiB
Svelte

<!--
Copyright: Ankitects Pty Ltd and contributors
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
-->
<script lang="ts">
import ConfigSelector from "./ConfigSelector.svelte";
import Container from "../components/Container.svelte";
import Row from "../components/Row.svelte";
import DailyLimits from "./DailyLimits.svelte";
import DisplayOrder from "./DisplayOrder.svelte";
import NewOptions from "./NewOptions.svelte";
import AdvancedOptions from "./AdvancedOptions.svelte";
import BuryOptions from "./BuryOptions.svelte";
import LapseOptions from "./LapseOptions.svelte";
import TimerOptions from "./TimerOptions.svelte";
import AudioOptions from "./AudioOptions.svelte";
import Addons from "./Addons.svelte";
import type { DeckOptionsState } from "./lib";
import type { Writable } from "svelte/store";
import HtmlAddon from "./HtmlAddon.svelte";
import type { DynamicSvelteComponent } from "../sveltelib/dynamicComponent";
export let state: DeckOptionsState;
let addons = state.addonComponents;
export function auxData(): Writable<Record<string, unknown>> {
return state.currentAuxData;
}
export function addSvelteAddon(component: DynamicSvelteComponent): void {
$addons = [...$addons, component];
}
export function addHtmlAddon(html: string, mounted: () => void): void {
$addons = [
...$addons,
{
component: HtmlAddon,
html,
mounted,
},
];
}
export const options = {};
export const dailyLimits = {};
export const newOptions = {};
export const lapseOptions = {};
export const buryOptions = {};
export const displayOrder = {};
export const timerOptions = {};
export const audioOptions = {};
export const addonOptions = {};
export const advancedOptions = {};
</script>
<ConfigSelector {state} />
<div class="deck-options-page">
<Container
breakpoint="sm"
--gutter-inline="0.25rem"
--gutter-block="0.5rem"
class="container-columns"
api={options}
>
<Row class="row-columns">
<DailyLimits {state} api={dailyLimits} />
</Row>
<Row class="row-columns">
<NewOptions {state} api={newOptions} />
</Row>
<Row class="row-columns">
<LapseOptions {state} api={lapseOptions} />
</Row>
{#if state.v3Scheduler}
<Row class="row-columns">
<DisplayOrder {state} api={displayOrder} />
</Row>
{/if}
<Row class="row-columns">
<TimerOptions {state} api={timerOptions} />
</Row>
<Row class="row-columns">
<BuryOptions {state} api={buryOptions} />
</Row>
<Row class="row-columns">
<AudioOptions {state} api={audioOptions} />
</Row>
<Row class="row-columns">
<Addons {state} api={addonOptions} />
</Row>
<Row class="row-columns">
<AdvancedOptions {state} api={advancedOptions} />
</Row>
</Container>
</div>
<style lang="scss">
@use "sass/breakpoints" as bp;
.deck-options-page {
overflow-x: hidden;
@include bp.with-breakpoint("lg") {
:global(.container) {
display: block;
}
:global(.container-columns) {
column-count: 2;
column-gap: 5em;
:global(.container) {
break-inside: avoid;
}
}
:global(.row-columns) {
display: block;
}
}
}
</style>