Skip to content

Commit 24c7957

Browse files
committed
Minor test UI tweaks
1 parent dc1bb67 commit 24c7957

File tree

2 files changed

+30
-11
lines changed

2 files changed

+30
-11
lines changed

dev/sass/views/text.scss

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
padding-bottom: $pad*0.275;
1111

1212
&:last-child::after {
13+
transition: opacity 1s;
1314
font-size: 0.625rem;
1415
padding: 0.25em 0.5em;
1516
display: inline-block;
@@ -56,6 +57,10 @@
5657
}
5758
}
5859

60+
&.tests-viewed > header .modelist li:last-child::after {
61+
opacity: 0;
62+
}
63+
5964
.editor {
6065
position: relative;
6166
box-sizing: border-box;
@@ -102,13 +107,17 @@
102107
overflow: auto;
103108

104109
.default {
105-
display: none;
110+
transition: opacity 1s;
106111
padding: $pad $pad * 0.5;
107112
color: $doc-dark;
108113
}
109114

110115
.list:empty ~ .default {
111-
display: block;
116+
opacity: 1;
117+
}
118+
119+
&.tests-added .default {
120+
opacity: 0;
112121
}
113122

114123
.add.button {

dev/src/views/Text.js

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ export default class Text extends EventDispatcher {
5454
}
5555

5656
set tests(val) {
57-
val = val instanceof Array ? val : [];
57+
if (!(val instanceof Array)) {
58+
val = [];
59+
$.removeClass(this.testsEl, "tests-added");
60+
}
5861
this._tests = this.testList.data = val;
5962
this._testMatches = null;
6063
this._reselectTest();
@@ -96,6 +99,15 @@ export default class Text extends EventDispatcher {
9699
}
97100
return null;
98101
}
102+
103+
getEmptyTest() {
104+
return {
105+
id: UID.id,
106+
name: "",
107+
text: "Enter your test text here.",
108+
type: "any"
109+
}
110+
}
99111

100112
// private methods:
101113
_initUI(el) {
@@ -142,6 +154,7 @@ export default class Text extends EventDispatcher {
142154
_handleModeChange(evt) {
143155
this.dispatchEvent("modechange");
144156
if (this.mode === "text") { this.editor.refresh(); }
157+
else { $.addClass(this.el, "tests-viewed"); }
145158
}
146159

147160
_setResult(val) {
@@ -276,10 +289,11 @@ export default class Text extends EventDispatcher {
276289
];
277290
this.typeLabels = types.reduce((o, t) => { o[t.id] = t.label; return o; }, {});
278291

292+
this.testsEl = $.query(".tests", el);
279293
this.testItemEl = $.query("#library > #tests_item");
280-
this.testListEl = $.query(".tests .list", el);
294+
this.testListEl = $.query(".list", this.testsEl);
281295
this.testList = new List(this.testListEl, {template:(o) => this._testItemTemplate(o)});
282-
this.testList.scrollEl = $.query(".tests", el);
296+
this.testList.scrollEl = this.testsEl;
283297

284298
this.testList.on("change", (evt) => this._handleTestChange(evt));
285299

@@ -364,16 +378,12 @@ export default class Text extends EventDispatcher {
364378
}
365379

366380
_addTest() {
367-
const o = {
368-
id: UID.id,
369-
name: "",
370-
text: "Enter your test text here.",
371-
type: "any"
372-
}
381+
const o = this.getEmptyTest();
373382
this._tests.push(o);
374383
this.testList.addItem(o, true);
375384
this._handleTestChange();
376385
this.testEditor.execCommand("selectAll");
386+
$.addClass(this.testsEl, "tests-added");
377387
this._change();
378388
}
379389

0 commit comments

Comments
 (0)