Merge pull request #1202 from hgiesel/nowrapdeckoptionstoolbar

Uniformly use properties to Button{Toolbar,Group} for setting button properties
This commit is contained in:
Damien Elmes 2021-05-29 10:39:11 +10:00 committed by GitHub
commit bb2026f3f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 112 additions and 92 deletions

View File

@ -6,7 +6,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import { setContext } from "svelte";
import { dropdownKey } from "./contextKeys";
import WithTheming from "./WithTheming.svelte";
import ButtonToolbar from "./ButtonToolbar.svelte";
export let id: string;
@ -18,22 +17,20 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
setContext(dropdownKey, null);
</script>
<WithTheming style="--toolbar-wrap: nowrap; ">
<ButtonToolbar
<ButtonToolbar
{id}
class={`dropdown-menu btn-dropdown-menu ${className}`}
nowrap={true}
wrap={false}
{api}
>
>
<slot />
</ButtonToolbar>
</WithTheming>
</ButtonToolbar>
<style lang="scss">
:global(.dropdown-menu.btn-dropdown-menu) {
display: none;
min-width: 0;
padding: calc(var(--toolbar-size) / 10) 0;
padding: calc(var(--buttons-size) / 10) 0;
background-color: var(--window-bg);
border-color: var(--medium-border);

View File

@ -18,6 +18,19 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
let className: string = "";
export { className as class };
export let size: number | undefined = undefined;
export let wrap: boolean | undefined = undefined;
$: buttonSize = size ? `--buttons-size: ${size}rem; ` : "";
let buttonWrap: string;
$: if (wrap === undefined) {
buttonWrap = "";
} else {
buttonWrap = wrap ? `--buttons-wrap: wrap; ` : `--buttons-wrap: nowrap; `;
}
$: style = buttonSize + buttonWrap;
function makeRegistration(): ButtonRegistration {
const detach = writable(false);
const position = writable(ButtonPosition.Standalone);
@ -77,6 +90,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
bind:this={buttonGroupRef}
{id}
class={`btn-group ${className}`}
{style}
dir="ltr"
role="group"
>
@ -90,8 +104,8 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
<style lang="scss">
div {
flex-wrap: var(--toolbar-wrap);
padding: calc(var(--toolbar-size) / 10);
flex-wrap: var(--buttons-wrap);
padding: calc(var(--buttons-size) / 10);
margin: 0;
}
</style>

View File

@ -20,7 +20,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
let position_: ButtonPosition;
let style: string;
const radius = "calc(var(--toolbar-size) / 7.5)";
const radius = "calc(var(--buttons-size) / 7.5)";
$: {
switch (position_) {

View File

@ -17,7 +17,18 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
let className: string = "";
export { className as class };
export let nowrap = false;
export let size: number | undefined = undefined;
export let wrap: boolean | undefined = undefined;
$: buttonSize = size ? `--buttons-size: ${size}rem; ` : "";
let buttonWrap: string;
$: if (wrap === undefined) {
buttonWrap = "";
} else {
buttonWrap = wrap ? `--buttons-wrap: wrap; ` : `--buttons-wrap: nowrap; `;
}
$: style = buttonSize + buttonWrap;
function makeRegistration(): ButtonGroupRegistration {
const detach = writable(false);
@ -64,8 +75,8 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
<div
bind:this={buttonToolbarRef}
{id}
class={`btn-toolbar ${className}`}
class:flex-nowrap={nowrap}
class={`btn-toolbar wrap-variable ${className}`}
{style}
role="toolbar"
>
<slot />
@ -75,3 +86,9 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
</ButtonToolbarItem>
{/each}
</div>
<style lang="scss">
.wrap-variable {
flex-wrap: var(--buttons-wrap);
}
</style>

View File

@ -46,8 +46,8 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
@import "ts/sass/bootstrap/variables";
button {
width: calc(var(--toolbar-size) - 0px);
height: calc(var(--toolbar-size) - 0px);
width: calc(var(--buttons-size) - 0px);
height: calc(var(--buttons-size) - 0px);
padding: 4px;
overflow: hidden;

View File

@ -40,7 +40,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
display: flex;
justify-content: space-between;
font-size: calc(var(--toolbar-size) / 2.3);
font-size: calc(var(--buttons-size) / 2.3);
background: none;
box-shadow: none;

View File

@ -63,8 +63,8 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
vertical-align: middle;
/* constrain icon */
width: calc(var(--toolbar-size) - 2px);
height: calc(var(--toolbar-size) - 2px);
width: calc(var(--buttons-size) - 2px);
height: calc(var(--buttons-size) - 2px);
& > :global(svg),
& > :global(img) {

View File

@ -56,9 +56,9 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
@use "ts/sass/button_mixins" as button;
button {
padding: 0 calc(var(--toolbar-size) / 3);
padding: 0 calc(var(--buttons-size) / 3);
width: auto;
height: var(--toolbar-size);
height: var(--buttons-size);
@include button.btn-border-radius;
}

View File

@ -45,7 +45,9 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
@use "ts/sass/button_mixins" as button;
select {
height: var(--toolbar-size);
height: var(--buttons-size);
/* Long option name can create overflow */
overflow-x: hidden;
}
@include button.btn-day($with-hover: false);

View File

@ -22,6 +22,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
<style lang="scss">
label {
display: flex;
padding: 0 calc(var(--toolbar-size) / 10);
padding: 0 calc(var(--buttons-size) / 10);
}
</style>

View File

@ -11,7 +11,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import TextInputModal from "./TextInputModal.svelte";
import StickyBar from "components/StickyBar.svelte";
import WithTheming from "components/WithTheming.svelte";
import ButtonToolbar from "components/ButtonToolbar.svelte";
import ButtonToolbarItem from "components/ButtonToolbarItem.svelte";
import ButtonGroup from "components/ButtonGroup.svelte";
@ -89,8 +88,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
/>
<StickyBar>
<WithTheming style="--toolbar-size: 2.3rem; --toolbar-wrap: nowrap">
<ButtonToolbar class="justify-content-between">
<ButtonToolbar class="justify-content-between" size={2.3} wrap={false}>
<ButtonToolbarItem>
<ButtonGroup class="flex-grow-1">
<ButtonGroupItem>
@ -117,5 +115,4 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
/>
</ButtonToolbarItem>
</ButtonToolbar>
</WithTheming>
</StickyBar>

View File

@ -30,7 +30,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
</script>
<script lang="typescript">
import WithTheming from "components/WithTheming.svelte";
import StickyBar from "components/StickyBar.svelte";
import ButtonToolbar from "components/ButtonToolbar.svelte";
import ButtonToolbarItem from "components/ButtonToolbarItem.svelte";
@ -48,17 +47,12 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
export const colorButtons = {};
export const templateButtons = {};
export let size: number = 2;
export let wraps: boolean = true;
$: style = `--toolbar-size: ${size}rem; --toolbar-wrap: ${
wraps ? "wrap" : "nowrap"
}`;
export let size = 2;
export let wrap = true;
</script>
<WithTheming {style}>
<StickyBar>
<ButtonToolbar api={toolbar}>
<StickyBar>
<ButtonToolbar {size} {wrap} api={toolbar}>
<ButtonToolbarItem id="notetype">
<NoteTypeButtons api={notetypeButtons} />
</ButtonToolbarItem>
@ -79,5 +73,4 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
<TemplateButtons api={templateButtons} />
</ButtonToolbarItem>
</ButtonToolbar>
</StickyBar>
</WithTheming>
</StickyBar>

View File

@ -1,7 +1,7 @@
.linkb {
display: inline-block;
min-width: calc(var(--toolbar-size) - 2px);
min-height: calc(var(--toolbar-size) - 2px);
min-width: calc(var(--buttons-size) - 2px);
min-height: calc(var(--buttons-size) - 2px);
background-color: white;
border: 1px solid var(--medium-border);
@ -22,7 +22,7 @@
&:active,
&:active:hover {
background-color: white;
box-shadow: inset 0 calc(var(--toolbar-size) / 15) calc(var(--toolbar-size) / 5)
box-shadow: inset 0 calc(var(--buttons-size) / 15) calc(var(--buttons-size) / 5)
rgba(0, 0, 0, 0.25);
}
@ -36,8 +36,8 @@
&:active,
&:active:hover {
box-shadow: inset 0 calc(var(--toolbar-size) / 15)
calc(var(--toolbar-size) / 5) rgba(0, 0, 0, 0.35);
box-shadow: inset 0 calc(var(--buttons-size) / 15)
calc(var(--buttons-size) / 5) rgba(0, 0, 0, 0.35);
border-color: #525252;
}
}
@ -46,8 +46,8 @@
.topbut {
display: inline-block;
vertical-align: middle;
width: calc(var(--toolbar-size) - 12px);
height: calc(var(--toolbar-size) - 12px);
width: calc(var(--buttons-size) - 12px);
height: calc(var(--buttons-size) - 12px);
}
.nightMode img.topbut {

View File

@ -113,7 +113,7 @@ $btn-base-color-night: #666;
$focus-color: $blue;
@mixin impressed-shadow($intensity) {
box-shadow: inset 0 calc(var(--toolbar-size) / 15) calc(var(--toolbar-size) / 5)
box-shadow: inset 0 calc(var(--buttons-size) / 15) calc(var(--buttons-size) / 5)
rgba(black, $intensity);
}