Make focus highlight artificial and based on :focus-within

This commit is contained in:
Henrik Giesel 2021-08-31 22:25:50 +02:00 committed by Damien Elmes
parent c3253e8596
commit af7f2c06df
5 changed files with 35 additions and 5 deletions

View file

@ -6,6 +6,10 @@ anki-editable {
overflow: auto; overflow: auto;
padding: 6px; padding: 6px;
&:focus {
outline: none;
}
* { * {
max-width: 100%; max-width: 100%;
} }

View file

@ -10,6 +10,8 @@ export class EditorField extends HTMLDivElement {
constructor() { constructor() {
super(); super();
this.classList.add("editor-field");
this.labelContainer = document.createElement("div", { this.labelContainer = document.createElement("div", {
is: "anki-label-container", is: "anki-label-container",
}) as LabelContainer; }) as LabelContainer;

View file

@ -12,13 +12,32 @@
display: flex; display: flex;
overflow-x: hidden; overflow-x: hidden;
flex-direction: column; flex-direction: column;
margin: 5px; margin: 3px 0;
}
.editor-field {
margin: 3px;
border-radius: 6px;
border: 1px solid var(--border);
&:focus-within {
box-shadow: 0 0 0 3px var(--focus-shadow);
border-color: var(--focus-border);
}
} }
.field { .field {
position: relative; position: relative;
border: 1px solid var(--border);
background: var(--frame-bg); background: var(--frame-bg);
border-width: 1px 0 0;
border-style: dashed;
border-color: var(--border);
border-radius: 0 0 6px 6px;
&:focus-within {
border-color: var(--focus-border);
}
&.dupe { &.dupe {
// this works around the background colour persisting in copy+paste // this works around the background colour persisting in copy+paste
@ -28,8 +47,8 @@
} }
.fname { .fname {
vertical-align: middle; border-radius: 6px 6px 0 0;
padding: 0; padding: 0px 6px;
} }
#dupes, #dupes,
@ -71,5 +90,6 @@
.CodeMirror { .CodeMirror {
height: auto; height: auto;
border-radius: 0 0 6px 6px;
padding: 6px 0; padding: 6px 0;
} }

View file

@ -37,7 +37,7 @@ export class LabelContainer extends HTMLDivElement {
constructor() { constructor() {
super(); super();
this.className = "d-flex justify-content-between"; this.className = "fname d-flex justify-content-between";
i18n.then(() => { i18n.then(() => {
this.title = appendInParentheses(tr.editingToggleSticky(), "F9"); this.title = appendInParentheses(tr.editingToggleSticky(), "F9");

View file

@ -36,6 +36,8 @@
--suspended-bg: #ffffb2; --suspended-bg: #ffffb2;
--marked-bg: #cce; --marked-bg: #cce;
--tooltip-bg: #fcfcfc; --tooltip-bg: #fcfcfc;
--focus-border: #0969da;
--focus-shadow: rgba(9 105 218 / 0.3);
} }
:root[class*="night-mode"] { :root[class*="night-mode"] {
@ -73,4 +75,6 @@
--suspended-bg: #aaaa33; --suspended-bg: #aaaa33;
--marked-bg: #77c; --marked-bg: #77c;
--tooltip-bg: #272727; --tooltip-bg: #272727;
--focus-border: #316dca;
--focus-shadow: #143d79;
} }