mirror of
https://github.com/ankitects/anki.git
synced 2025-09-20 06:52:21 -04:00
Use elevation + overflow:hidden in Editorfield
This commit is contained in:
parent
b94114aa0a
commit
ee0cfc25e2
6 changed files with 47 additions and 78 deletions
|
@ -59,7 +59,7 @@ $umbra-opacity: 0.2;
|
||||||
$penumbra-opacity: 0.14;
|
$penumbra-opacity: 0.14;
|
||||||
$ambient-opacity: 0.12;
|
$ambient-opacity: 0.12;
|
||||||
|
|
||||||
@function box-shadow($level, $opacity-boost: 0, $color: black) {
|
@function box-shadow($level, $opacity-boost, $color) {
|
||||||
$umbra-z-value: map.get($umbra-map, $level);
|
$umbra-z-value: map.get($umbra-map, $level);
|
||||||
$penumbra-z-value: map.get($penumbra-map, $level);
|
$penumbra-z-value: map.get($penumbra-map, $level);
|
||||||
$ambient-z-value: map.get($ambient-map, $level);
|
$ambient-z-value: map.get($ambient-map, $level);
|
||||||
|
@ -75,6 +75,10 @@ $ambient-opacity: 0.12;
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@mixin elevation($level, $other: ()) {
|
@mixin elevation($level, $opacity-boost: 0, $color: black) {
|
||||||
box-shadow: list.join(box-shadow($level), $other);
|
box-shadow: box-shadow($level, $opacity-boost, $color);
|
||||||
|
}
|
||||||
|
|
||||||
|
@mixin elevation-transition() {
|
||||||
|
transition: box-shadow 80ms cubic-bezier(0.33, 1, 0.68, 1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -186,31 +186,5 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
display: grid;
|
display: grid;
|
||||||
/* TODO allow configuration of grid #1503 */
|
/* TODO allow configuration of grid #1503 */
|
||||||
/* grid-template-columns: repeat(2, 1fr); */
|
/* grid-template-columns: repeat(2, 1fr); */
|
||||||
|
|
||||||
position: relative;
|
|
||||||
background: var(--frame-bg);
|
|
||||||
border-radius: 5px;
|
|
||||||
border: 1px solid var(--border);
|
|
||||||
|
|
||||||
box-shadow: 0px 0px 2px 0px var(--border);
|
|
||||||
transition: box-shadow 80ms cubic-bezier(0.33, 1, 0.68, 1);
|
|
||||||
|
|
||||||
&:focus-within {
|
|
||||||
outline: none;
|
|
||||||
|
|
||||||
/* This pseudo-element is required to display
|
|
||||||
the inset box-shadow above field contents */
|
|
||||||
&::after {
|
|
||||||
content: "";
|
|
||||||
position: absolute;
|
|
||||||
top: -1px;
|
|
||||||
right: -1px;
|
|
||||||
bottom: -1px;
|
|
||||||
left: -1px;
|
|
||||||
pointer-events: none;
|
|
||||||
border-radius: 5px;
|
|
||||||
box-shadow: inset 0 0 0 2px var(--focus-border);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -115,9 +115,26 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
</Collapsible>
|
</Collapsible>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
@use "sass/elevation" as elevation;
|
||||||
|
|
||||||
.editor-field {
|
.editor-field {
|
||||||
position: relative;
|
overflow: hidden;
|
||||||
padding: 0 3px;
|
margin: 0 3px;
|
||||||
|
|
||||||
--border-color: var(--border);
|
--border-color: var(--border);
|
||||||
|
|
||||||
|
border-radius: 5px;
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
|
||||||
|
@include elevation.elevation-transition;
|
||||||
|
@include elevation.elevation(1);
|
||||||
|
|
||||||
|
&:focus-within {
|
||||||
|
@include elevation.elevation(
|
||||||
|
2,
|
||||||
|
$color: rgb(59 130 246),
|
||||||
|
$opacity-boost: 0.2
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -460,8 +460,6 @@ the AddCards dialog) should be implemented in the user of this component.
|
||||||
>
|
>
|
||||||
<PlainTextInput
|
<PlainTextInput
|
||||||
{hidden}
|
{hidden}
|
||||||
isDefault={plainTextDefaults[index]}
|
|
||||||
richTextHidden={richTextsHidden[index]}
|
|
||||||
on:focusout={() => {
|
on:focusout={() => {
|
||||||
saveFieldNow();
|
saveFieldNow();
|
||||||
$focusedInput = null;
|
$focusedInput = null;
|
||||||
|
|
|
@ -39,9 +39,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
import removeProhibitedTags from "./remove-prohibited";
|
import removeProhibitedTags from "./remove-prohibited";
|
||||||
import { storedToUndecorated, undecoratedToStored } from "./transform";
|
import { storedToUndecorated, undecoratedToStored } from "./transform";
|
||||||
|
|
||||||
export let isDefault: boolean;
|
|
||||||
export let hidden = false;
|
export let hidden = false;
|
||||||
export let richTextHidden: boolean;
|
|
||||||
|
|
||||||
const configuration = {
|
const configuration = {
|
||||||
mode: htmlanki,
|
mode: htmlanki,
|
||||||
|
@ -145,8 +143,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
<div
|
<div
|
||||||
class="plain-text-input"
|
class="plain-text-input"
|
||||||
class:light-theme={!$pageTheme.isDark}
|
class:light-theme={!$pageTheme.isDark}
|
||||||
class:is-default={isDefault}
|
|
||||||
class:alone={richTextHidden}
|
|
||||||
on:focusin={() => ($focusedInput = api)}
|
on:focusin={() => ($focusedInput = api)}
|
||||||
{hidden}
|
{hidden}
|
||||||
>
|
>
|
||||||
|
@ -161,31 +157,8 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
.plain-text-input {
|
.plain-text-input {
|
||||||
border-top: 1px solid var(--border);
|
|
||||||
border-radius: 0 0 5px 5px;
|
|
||||||
|
|
||||||
:global(.CodeMirror) {
|
:global(.CodeMirror) {
|
||||||
background: var(--code-bg);
|
background: var(--code-bg);
|
||||||
border-radius: 0 0 5px 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
&.is-default {
|
|
||||||
border-top: none;
|
|
||||||
border-bottom: 1px solid var(--border);
|
|
||||||
border-radius: 5px 5px 0 0;
|
|
||||||
|
|
||||||
:global(.CodeMirror) {
|
|
||||||
border-radius: 5px 5px 0 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&.alone {
|
|
||||||
border: none;
|
|
||||||
border-radius: 5px;
|
|
||||||
|
|
||||||
:global(.CodeMirror) {
|
|
||||||
border-radius: 5px;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
:global(.CodeMirror-lines) {
|
:global(.CodeMirror-lines) {
|
||||||
|
|
|
@ -127,7 +127,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
return hidden;
|
return hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
const className = "rich-text-editable";
|
|
||||||
let richTextDiv: HTMLElement;
|
let richTextDiv: HTMLElement;
|
||||||
|
|
||||||
async function getInputAPI(target: EventTarget): Promise<FocusableInputAPI | null> {
|
async function getInputAPI(target: EventTarget): Promise<FocusableInputAPI | null> {
|
||||||
|
@ -222,29 +221,33 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
let:attachToShadow={attachStyles}
|
let:attachToShadow={attachStyles}
|
||||||
let:stylesDidLoad
|
let:stylesDidLoad
|
||||||
>
|
>
|
||||||
<div
|
<div class="rich-text-relative">
|
||||||
bind:this={richTextDiv}
|
<div
|
||||||
class={className}
|
class="rich-text-editable"
|
||||||
class:night-mode={$pageTheme.isDark}
|
bind:this={richTextDiv}
|
||||||
use:attachShadow
|
use:attachShadow
|
||||||
use:attachStyles
|
use:attachStyles
|
||||||
use:attachContentEditable={{ stylesDidLoad }}
|
use:attachContentEditable={{ stylesDidLoad }}
|
||||||
on:focusin
|
on:focusin
|
||||||
on:focusout
|
on:focusout
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{#await Promise.all([richTextPromise, stylesDidLoad]) then _}
|
{#await Promise.all([richTextPromise, stylesDidLoad]) then _}
|
||||||
<div class="rich-text-widgets">
|
<div class="rich-text-widgets">
|
||||||
<slot />
|
<slot />
|
||||||
</div>
|
</div>
|
||||||
{/await}
|
{/await}
|
||||||
|
</div>
|
||||||
</RichTextStyles>
|
</RichTextStyles>
|
||||||
<slot name="plain-text-badge" />
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
.rich-text-input {
|
.rich-text-input {
|
||||||
|
background-color: white;
|
||||||
|
padding: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rich-text-relative {
|
||||||
position: relative;
|
position: relative;
|
||||||
margin: 6px;
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
Loading…
Reference in a new issue