Style light mode button bar with borders

- whereas night mode toolbar has no visible borders
This commit is contained in:
Henrik Giesel 2021-04-14 21:58:58 +02:00
parent a7d24e7159
commit b696635afc
7 changed files with 45 additions and 18 deletions

View file

@ -22,7 +22,9 @@ compile_sass(
"legacy.scss", "legacy.scss",
"bootstrap.scss", "bootstrap.scss",
], ],
deps = [], deps = [
"//ts/sass:button_mixins_lib",
],
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
) )

View file

@ -1,5 +1,7 @@
<script lang="typescript"> <script lang="typescript">
import type { ToolbarItem } from "./types"; import type { ToolbarItem } from "./types";
import { getContext } from "svelte";
import { nightModeKey } from "./contextKeys";
export let id: string; export let id: string;
export let className = ""; export let className = "";
@ -8,11 +10,15 @@
function filterHidden({ hidden, ...props }) { function filterHidden({ hidden, ...props }) {
return props; return props;
} }
const nightMode = getContext(nightModeKey);
</script> </script>
<style lang="scss"> <style lang="scss">
ul { ul {
display: flex; display: inline-flex;
justify-items: start;
flex-wrap: var(--toolbar-wrap); flex-wrap: var(--toolbar-wrap);
overflow-y: auto; overflow-y: auto;
@ -20,6 +26,14 @@
margin-bottom: 0; margin-bottom: 0;
} }
.border-group {
/* buttons' borders exactly overlap each other */
:global(button),
:global(select) {
margin-left: -2px;
}
}
li { li {
display: inline-block; display: inline-block;
margin-bottom: calc(var(--toolbar-size) / 15); margin-bottom: calc(var(--toolbar-size) / 15);
@ -56,7 +70,7 @@
} }
</style> </style>
<ul {id} class={className}> <ul {id} class={className} class:border-group={!nightMode}>
{#each buttons as button} {#each buttons as button}
{#if !button.hidden} {#if !button.hidden}
<li> <li>

View file

@ -14,10 +14,10 @@
const nightMode = getContext(nightModeKey); const nightMode = getContext(nightModeKey);
let input: HTMLInputElement; let inputRef: HTMLInputElement;
function delegateToInput() { function delegateToInput() {
input.click(); inputRef.click();
} }
</script> </script>
@ -40,16 +40,22 @@
.btn-light { .btn-light {
@include button.light-hover-active; @include button.light-hover-active;
background: content-box linear-gradient(217deg, rgba(255, 0, 0, 0.8), rgba(255, 0, 0, 0) 70.71%), background: content-box
content-box linear-gradient(127deg, rgba(0, 255, 0, 0.8), rgba(0, 255, 0, 0) 70.71%), linear-gradient(217deg, rgba(255, 0, 0, 0.8), rgba(255, 0, 0, 0) 70.71%),
content-box linear-gradient(336deg, rgba(0, 0, 255, 0.8), rgba(0, 0, 255, 0) 70.71%), content-box
linear-gradient(127deg, rgba(0, 255, 0, 0.8), rgba(0, 255, 0, 0) 70.71%),
content-box
linear-gradient(336deg, rgba(0, 0, 255, 0.8), rgba(0, 0, 255, 0) 70.71%),
border-box $light; border-box $light;
} }
.btn-secondary { .btn-secondary {
background: content-box linear-gradient(217deg, rgba(255, 0, 0, 0.8), rgba(255, 0, 0, 0) 70.71%), background: content-box
content-box linear-gradient(127deg, rgba(0, 255, 0, 0.8), rgba(0, 255, 0, 0) 70.71%), linear-gradient(217deg, rgba(255, 0, 0, 0.8), rgba(255, 0, 0, 0) 70.71%),
content-box linear-gradient(336deg, rgba(0, 0, 255, 0.8), rgba(0, 0, 255, 0) 70.71%), content-box
linear-gradient(127deg, rgba(0, 255, 0, 0.8), rgba(0, 255, 0, 0) 70.71%),
content-box
linear-gradient(336deg, rgba(0, 0, 255, 0.8), rgba(0, 0, 255, 0) 70.71%),
border-box $secondary; border-box $secondary;
} }
@ -69,5 +75,5 @@
title={tooltip} title={tooltip}
on:click={delegateToInput} on:click={delegateToInput}
on:mousedown|preventDefault> on:mousedown|preventDefault>
<input bind:this={input} type="color" on:change={onChange} /> <input bind:this={inputRef} type="color" on:change={onChange} />
</button> </button>

View file

@ -26,7 +26,8 @@
&.nightMode { &.nightMode {
color: white; color: white;
&:hover, &:focus { &:hover,
&:focus {
color: black; color: black;
} }

View file

@ -39,7 +39,6 @@
button { button {
padding: 0; padding: 0;
} }
.btn-light { .btn-light {

View file

@ -58,8 +58,9 @@ class EditorToolbar extends HTMLElement {
props: { props: {
buttons: this.buttons, buttons: this.buttons,
menus: this.menus, menus: this.menus,
nightMode: document.documentElement.classList.contains("night-mode"), nightMode: document.documentElement.classList.contains(
"night-mode"
),
}, },
}); });
}); });

View file

@ -1,6 +1,10 @@
@mixin light-hover-active { @mixin light-hover-active {
&:hover, &:focus, &:active, &.active { border-color: var(--faint-border) !important;
&:hover,
&:focus,
&:active,
&.active {
background-color: #e3e3e8; background-color: #e3e3e8;
border-color: #e3e3e8;
} }
} }