Adding entrances for also
This commit is contained in:
parent
4d2e1493cf
commit
655ce304cd
|
@ -74,6 +74,8 @@
|
||||||
0px 2px 4px -1px rgba(0, 0, 0, 0.05),
|
0px 2px 4px -1px rgba(0, 0, 0, 0.05),
|
||||||
0px 0px 0px 3px var(--color-l-alpha-gray);
|
0px 0px 0px 3px var(--color-l-alpha-gray);
|
||||||
--text-input-shadow-active: inset 0px 1px 0px 0px rgba(255, 255, 255, 1), inset 0px -1px 0px 0px rgba(0, 0, 0, 0.04), 0px 1px 6px 0px rgba(0, 0, 0, 0.07);
|
--text-input-shadow-active: inset 0px 1px 0px 0px rgba(255, 255, 255, 1), inset 0px -1px 0px 0px rgba(0, 0, 0, 0.04), 0px 1px 6px 0px rgba(0, 0, 0, 0.07);
|
||||||
|
|
||||||
|
--hide-speed: .2s;
|
||||||
}
|
}
|
||||||
|
|
||||||
input, select {
|
input, select {
|
||||||
|
@ -151,16 +153,7 @@ label {
|
||||||
margin-top: 8px;
|
margin-top: 8px;
|
||||||
margin-left: 18px;
|
margin-left: 18px;
|
||||||
gap: 6px;
|
gap: 6px;
|
||||||
height: 0;
|
height: 297px;
|
||||||
transition: .5s;
|
|
||||||
}
|
|
||||||
|
|
||||||
#other.show-other {
|
|
||||||
height: 297px; /* Height of other options */
|
|
||||||
}
|
|
||||||
|
|
||||||
#header-pov.show-other {
|
|
||||||
margin-top: 16px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#other li {
|
#other li {
|
||||||
|
@ -190,21 +183,35 @@ label {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 6px;
|
gap: 6px;
|
||||||
margin-top: 6px;
|
margin-top: 6px;
|
||||||
|
height: 26px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.lhs {
|
.lhs {
|
||||||
text-align: right;
|
text-align: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
#also > li > button {
|
|
||||||
|
.delete {
|
||||||
|
color: var(--icon-color);
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
width: fit-content;
|
width: fit-content;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
border: 0;
|
||||||
|
box-shadow: 0;
|
||||||
|
visibility: block;
|
||||||
|
scale: 1;
|
||||||
|
transition: all .1s allow-discrete;
|
||||||
|
}
|
||||||
|
|
||||||
|
.delete:hover, .delete:focus {
|
||||||
|
color: var(--icon-color-hover);
|
||||||
|
outline: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.hide-button > button {
|
.hide-button > button {
|
||||||
visibility: hidden;
|
visibility: hidden;
|
||||||
|
scale: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
|
@ -267,7 +274,7 @@ button:not(.delete) {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
button > svg {
|
button:not(.delete) > svg {
|
||||||
transform: translateY(-.15em);
|
transform: translateY(-.15em);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -408,25 +415,6 @@ label {
|
||||||
text-align: right;
|
text-align: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
#also > li > button {
|
|
||||||
color: var(--icon-color);
|
|
||||||
background-color: transparent;
|
|
||||||
width: 24px;
|
|
||||||
height: 24px;
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
border: 0;
|
|
||||||
box-shadow: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#also > li > button:hover {
|
|
||||||
color: var(--icon-color-hover);
|
|
||||||
}
|
|
||||||
|
|
||||||
.hide-button > button {
|
|
||||||
visibility: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Links section */
|
/* Links section */
|
||||||
|
@ -450,3 +438,24 @@ a {
|
||||||
a:hover{
|
a:hover{
|
||||||
color: var(--text-color);
|
color: var(--text-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.hide {
|
||||||
|
height: 0 !important;
|
||||||
|
padding-top: 0 !important;
|
||||||
|
padding-bottom: 0 !important;
|
||||||
|
margin-top: 0 !important;
|
||||||
|
margin-bottom: 0 !important;
|
||||||
|
overflow: hidden !important;
|
||||||
|
opacity: 0 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.unhide {
|
||||||
|
transition:
|
||||||
|
height var(--hide-speed) ease-out,
|
||||||
|
padding-top var(--hide-speed) ease-out,
|
||||||
|
padding-bottom var(--hide-speed) ease-out,
|
||||||
|
margin-top var(--hide-speed) ease-out,
|
||||||
|
margin-bottom var(--hide-speed) ease-out,
|
||||||
|
opacity var(--hide-speed) linear !important;
|
||||||
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ul id="other">
|
<ul id="other" class="hide unhide">
|
||||||
<li>
|
<li>
|
||||||
<label for="subjective">Subjective</label>
|
<label for="subjective">Subjective</label>
|
||||||
<input type="text" id="subjective" name="subjective" placeholder="e.g. he, they">
|
<input type="text" id="subjective" name="subjective" placeholder="e.g. he, they">
|
||||||
|
|
42
src/popup.js
42
src/popup.js
|
@ -160,6 +160,7 @@ function saveAlso() {
|
||||||
/* Creates the HTML for a new also replacement */
|
/* Creates the HTML for a new also replacement */
|
||||||
function createLi(index) {
|
function createLi(index) {
|
||||||
const li = document.createElement("li");
|
const li = document.createElement("li");
|
||||||
|
li.classList.add("unhide");
|
||||||
|
|
||||||
const lhs = document.createElement("input");
|
const lhs = document.createElement("input");
|
||||||
lhs.type = "text";
|
lhs.type = "text";
|
||||||
|
@ -203,13 +204,27 @@ function addLi() {
|
||||||
setFinal(this.parentNode, false);
|
setFinal(this.parentNode, false);
|
||||||
setFinal(li, true);
|
setFinal(li, true);
|
||||||
document.querySelector("#also").append(li);
|
document.querySelector("#also").append(li);
|
||||||
|
|
||||||
|
li.classList.add("hide");
|
||||||
|
requestAnimationFrame(() => {
|
||||||
|
li.classList.remove("hide")
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Removes an item from the list of also replacements */
|
/* Removes an item from the list of also replacements */
|
||||||
function removeLi() {
|
async function removeLi() {
|
||||||
document.querySelector("#also").removeChild(this.parentNode);
|
this.parentNode.classList.add("hide");
|
||||||
const also = document.querySelector("#also").querySelectorAll("li");
|
let fields = this.parentNode.querySelectorAll("input, button");
|
||||||
also.forEach((li, index) => {
|
fields.forEach((field) => {
|
||||||
|
field.disabled = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
await sleep(200); /* TODO make 300 different if reduced motion */
|
||||||
|
|
||||||
|
let also = document.querySelector("#also");
|
||||||
|
also.removeChild(this.parentNode);
|
||||||
|
let list = also.querySelectorAll("li");
|
||||||
|
list.forEach((li, index) => {
|
||||||
lhs = li.querySelector(".lhs");
|
lhs = li.querySelector(".lhs");
|
||||||
lhs.id = "lhs-" + index;
|
lhs.id = "lhs-" + index;
|
||||||
lhs.name = lhs.id;
|
lhs.name = lhs.id;
|
||||||
|
@ -245,16 +260,25 @@ function setFinal(li, isFinal) {
|
||||||
/* Displays more options for pronouns if "other" is selected */
|
/* Displays more options for pronouns if "other" is selected */
|
||||||
function showOther() {
|
function showOther() {
|
||||||
let other = document.querySelector("#other");
|
let other = document.querySelector("#other");
|
||||||
let headerPov = document.querySelector("#header-pov");
|
let fields = other.querySelectorAll("input, select");
|
||||||
if (document.querySelector("#preset").value == "other") {
|
if (document.querySelector("#preset").value == "other") {
|
||||||
other.classList.add("show-other");
|
other.classList.remove("hide");
|
||||||
headerPov.classList.add("show-other");
|
fields.forEach((field) => {
|
||||||
|
field.disabled = false;
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
other.classList.remove("show-other");
|
other.classList.add("hide");
|
||||||
headerPov.classList.remove("show-other");
|
fields.forEach((field) => {
|
||||||
|
field.disabled = true;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Sleep */
|
||||||
|
function sleep(ms) {
|
||||||
|
return new Promise(resolve => setTimeout(resolve, ms));
|
||||||
|
}
|
||||||
|
|
||||||
/* Required by then */
|
/* Required by then */
|
||||||
function logError(error) {
|
function logError(error) {
|
||||||
console.log(`Error: ${error}`);
|
console.log(`Error: ${error}`);
|
||||||
|
|
Loading…
Reference in New Issue