mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
Rely more heavily on bootstrap provided types for editor-toolbar
This commit is contained in:
parent
e6996ae5d3
commit
d6d4269aaf
4 changed files with 27 additions and 57 deletions
|
@ -18,17 +18,17 @@
|
||||||
|
|
||||||
padding-inline-start: 0;
|
padding-inline-start: 0;
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
|
|
||||||
& :global(button),
|
|
||||||
& :global(select) {
|
|
||||||
margin-left: -1px;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
li {
|
li {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
margin-bottom: calc(var(--toolbar-size) / 15);
|
margin-bottom: calc(var(--toolbar-size) / 15);
|
||||||
|
|
||||||
|
& > :global(button),
|
||||||
|
& > :global(select) {
|
||||||
|
border-radius: 0;
|
||||||
|
}
|
||||||
|
|
||||||
&:nth-child(1) {
|
&:nth-child(1) {
|
||||||
margin-left: calc(var(--toolbar-size) / 7.5);
|
margin-left: calc(var(--toolbar-size) / 7.5);
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<script lang="typescript">
|
<script lang="typescript">
|
||||||
import { onMount, createEventDispatcher, getContext } from "svelte";
|
import { onMount, createEventDispatcher, getContext } from "svelte";
|
||||||
import { disabledKey } from "./contextKeys";
|
import { disabledKey, nightModeKey } from "./contextKeys";
|
||||||
|
|
||||||
export let id: string;
|
export let id: string;
|
||||||
export let className = "";
|
export let className = "";
|
||||||
|
@ -21,38 +21,26 @@
|
||||||
let buttonRef: HTMLButtonElement;
|
let buttonRef: HTMLButtonElement;
|
||||||
|
|
||||||
function extendClassName(className: string): string {
|
function extendClassName(className: string): string {
|
||||||
return `btn btn-secondary ${className}`;
|
return `btn ${className}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const dispatch = createEventDispatcher();
|
|
||||||
onMount(() => dispatch("mount", { button: buttonRef }));
|
|
||||||
|
|
||||||
const disabled = getContext(disabledKey);
|
const disabled = getContext(disabledKey);
|
||||||
$: _disabled = disables && $disabled;
|
$: _disabled = disables && $disabled;
|
||||||
|
|
||||||
|
const nightMode = getContext(nightModeKey);
|
||||||
|
|
||||||
|
const dispatch = createEventDispatcher();
|
||||||
|
onMount(() => dispatch("mount", { button: buttonRef }));
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
@use "ts/sass/button_mixins" as button;
|
@use "ts/sass/button_mixins" as button;
|
||||||
|
|
||||||
button {
|
button {
|
||||||
display: inline-block;
|
|
||||||
padding: 0 calc(var(--toolbar-size) / 3);
|
padding: 0 calc(var(--toolbar-size) / 3);
|
||||||
|
|
||||||
font-size: calc(var(--toolbar-size) / 2.3);
|
font-size: calc(var(--toolbar-size) / 2.3);
|
||||||
width: auto;
|
width: auto;
|
||||||
height: var(--toolbar-size);
|
height: var(--toolbar-size);
|
||||||
|
|
||||||
border-radius: 0;
|
|
||||||
border-color: var(--faint-border);
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
box-shadow: 0 0 calc(var(--toolbar-size) / 2.5)
|
|
||||||
calc(var(--toolbar-size) / 7.5) rgb(255 255 255 / 0.5);
|
|
||||||
}
|
|
||||||
|
|
||||||
@include button.disabled {
|
|
||||||
border-color: var(--faint-border);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
@ -61,6 +49,8 @@
|
||||||
{id}
|
{id}
|
||||||
class={extendClassName(className)}
|
class={extendClassName(className)}
|
||||||
class:dropdown-toggle={dropdownToggle}
|
class:dropdown-toggle={dropdownToggle}
|
||||||
|
class:btn-light={!nightMode}
|
||||||
|
class:btn-secondary={nightMode}
|
||||||
tabindex="-1"
|
tabindex="-1"
|
||||||
disabled={_disabled}
|
disabled={_disabled}
|
||||||
title={tooltip}
|
title={tooltip}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<script lang="typescript">
|
<script lang="typescript">
|
||||||
import { getContext, onMount, createEventDispatcher } from "svelte";
|
import { getContext, onMount, createEventDispatcher } from "svelte";
|
||||||
import type { Readable } from "svelte/store";
|
import type { Readable } from "svelte/store";
|
||||||
import { disabledKey } from "./contextKeys";
|
import { disabledKey, nightModeKey } from "./contextKeys";
|
||||||
|
|
||||||
export let id: string;
|
export let id: string;
|
||||||
export let className = "";
|
export let className = "";
|
||||||
|
@ -21,9 +21,15 @@
|
||||||
|
|
||||||
let buttonRef: HTMLButtonElement;
|
let buttonRef: HTMLButtonElement;
|
||||||
|
|
||||||
|
function extendClassName(className: string): string {
|
||||||
|
return `btn ${className}`;
|
||||||
|
}
|
||||||
|
|
||||||
const disabled = getContext(disabledKey);
|
const disabled = getContext(disabledKey);
|
||||||
$: _disabled = disables && $disabled;
|
$: _disabled = disables && $disabled;
|
||||||
|
|
||||||
|
const nightMode = getContext(nightModeKey);
|
||||||
|
|
||||||
const dispatch = createEventDispatcher();
|
const dispatch = createEventDispatcher();
|
||||||
onMount(() => dispatch("mount", { button: buttonRef }));
|
onMount(() => dispatch("mount", { button: buttonRef }));
|
||||||
</script>
|
</script>
|
||||||
|
@ -32,38 +38,7 @@
|
||||||
@use "ts/sass/button_mixins" as button;
|
@use "ts/sass/button_mixins" as button;
|
||||||
|
|
||||||
button {
|
button {
|
||||||
display: inline-block;
|
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
|
||||||
background-color: white;
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
box-shadow: 0 0 calc(var(--toolbar-size) / 2.5)
|
|
||||||
calc(var(--toolbar-size) / 7.5) rgb(255 255 255 / 0.5);
|
|
||||||
}
|
|
||||||
|
|
||||||
&:active,
|
|
||||||
&.active {
|
|
||||||
box-shadow: inset 0 0 calc(var(--toolbar-size) / 2.5)
|
|
||||||
calc(var(--toolbar-size) / 7.5) rgb(0 0 0 / 30%);
|
|
||||||
border-color: #aaa;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.active:active {
|
|
||||||
box-shadow: none;
|
|
||||||
border-color: var(--border);
|
|
||||||
}
|
|
||||||
|
|
||||||
@include button.disabled {
|
|
||||||
&:hover {
|
|
||||||
background-color: white;
|
|
||||||
}
|
|
||||||
|
|
||||||
&:active,
|
|
||||||
&.active {
|
|
||||||
box-shadow: none;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
span {
|
span {
|
||||||
|
@ -91,9 +66,11 @@
|
||||||
<button
|
<button
|
||||||
bind:this={buttonRef}
|
bind:this={buttonRef}
|
||||||
{id}
|
{id}
|
||||||
class={className}
|
class={extendClassName(className)}
|
||||||
class:active
|
class:active
|
||||||
class:dropdown-toggle={dropdownToggle}
|
class:dropdown-toggle={dropdownToggle}
|
||||||
|
class:btn-light={!nightMode}
|
||||||
|
class:btn-secondary={nightMode}
|
||||||
tabindex="-1"
|
tabindex="-1"
|
||||||
title={tooltip}
|
title={tooltip}
|
||||||
disabled={_disabled}
|
disabled={_disabled}
|
||||||
|
|
3
ts/editor-toolbar/bootstrap.scss
vendored
3
ts/editor-toolbar/bootstrap.scss
vendored
|
@ -1,5 +1,8 @@
|
||||||
@import "ts/node_modules/bootstrap/scss/functions";
|
@import "ts/node_modules/bootstrap/scss/functions";
|
||||||
@import "ts/node_modules/bootstrap/scss/variables";
|
@import "ts/node_modules/bootstrap/scss/variables";
|
||||||
@import "ts/node_modules/bootstrap/scss/mixins";
|
@import "ts/node_modules/bootstrap/scss/mixins";
|
||||||
|
|
||||||
|
$btn-disabled-opacity: 0.4;
|
||||||
|
|
||||||
@import "ts/node_modules/bootstrap/scss/buttons";
|
@import "ts/node_modules/bootstrap/scss/buttons";
|
||||||
@import "ts/node_modules/bootstrap/scss/dropdown";
|
@import "ts/node_modules/bootstrap/scss/dropdown";
|
||||||
|
|
Loading…
Reference in a new issue