Skip to content

Commit cb7d331

Browse files
committed
Tweak site appearance
- Complete standard light color-scheme - Adjust appearance of setting inputs - Fix mini-column animations when dragging field into it - Hide loading indicators on fields in mini-column - Add block modal when screen resolution is too small
1 parent 734c0a4 commit cb7d331

File tree

16 files changed

+318
-209
lines changed

16 files changed

+318
-209
lines changed

site/assets/js/lab/config-panel.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { Eventable } from "./eventable";
2-
import { sleep } from "./pipeline";
31
import radlr_init, * as radlr from "js/radlr/radlr_wasm.js";
42
import { LocalStoreKeys, getLocalValue, setLocalValue, setupOpenCloseTriggers } from "./settings-panel";
53

@@ -28,19 +26,23 @@ export async function setupConfig(settings_changed: (cfg: radlr.JSParserConfig)
2826

2927
switch (input.type) {
3028
case "checkbox":
29+
//@ts-ignore
3130
input.checked = config[id];
3231
break;
3332
case "number":
33+
//@ts-ignore
3434
input.value = parseInt(config[id]).toString();
3535
break
3636
}
3737

3838
input.addEventListener("change", e => {
3939
switch (input.type) {
4040
case "checkbox":
41+
//@ts-ignore
4142
config[id] = input.checked;
4243
break;
4344
case "number":
45+
//@ts-ignore
4446
config[id] = input.value;
4547
break
4648
}

site/assets/js/lab/control.ts

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,32 @@ export class Controls extends Eventable<{
4444
window.addEventListener("keydown", e => {
4545
if (this.active) {
4646
let key = e.key;
47-
48-
if (key == "n" && e.altKey) {
49-
this.step_button.ele.click();
50-
e.preventDefault();
51-
e.stopImmediatePropagation();
52-
e.stopPropagation()
47+
if (!e.altKey || e.ctrlKey || e.shiftKey) return;
48+
switch (key) {
49+
case "n": {
50+
this.step_button.ele.click();
51+
e.preventDefault();
52+
e.stopImmediatePropagation();
53+
e.stopPropagation()
54+
} return
55+
case "r": {
56+
this.reset_button.ele.click();
57+
e.preventDefault();
58+
e.stopImmediatePropagation();
59+
e.stopPropagation()
60+
} return
61+
case "a": {
62+
this.jump_button.ele.click();
63+
e.preventDefault();
64+
e.stopImmediatePropagation();
65+
e.stopPropagation()
66+
} return
67+
case "space": {
68+
this.play_button.ele.click();
69+
e.preventDefault();
70+
e.stopImmediatePropagation();
71+
e.stopPropagation()
72+
} return
5373
}
5474
}
5575
}, {

site/assets/js/lab/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export async function init(compiler_worker_path: string) {
2323
grammar_input_field.set_text("");
2424
grammar_input_field.set_icon(`<i class="fa-solid fa-chart-gantt"></i>`);
2525

26-
let parser_info_field = nb.add_field(new NBContentField("Parser Info"), -1);
26+
let parser_info_field = nb.add_field(new NBContentField("Parser Info"), 1);
2727
parser_info_field.set_content_visible(false);
2828
parser_info_field.set_icon(`<i class="fa-solid fa-circle-info"></i>`);
2929

@@ -96,10 +96,11 @@ export async function init(compiler_worker_path: string) {
9696

9797
grammar_pipeline_node.addListener("loading", _ => {
9898
error_reporter.innerText = "";
99-
grammar_classification.innerHTML = "";
99+
grammar_classification.innerHTML = "...";
100100
})
101101

102102
grammar_pipeline_node.addListener("failed", errors => {
103+
grammar_classification.innerHTML = "error";
103104
for (const error of errors) {
104105
if (error.origin == radlr.ErrorOrigin.Grammar) {
105106
//alert(error.msg);

site/assets/js/lab/notebook.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,18 @@ export class MININBColumn extends NBColumn {
373373
field.is_mini = true;
374374
}
375375

376-
distribute_height() { }
376+
distribute_height() {
377+
// Every field is set to be 40px high
378+
let ratio = 50 / this.ele.getBoundingClientRect().height;
379+
for (const field of this.cells) {
380+
381+
if (field instanceof NBBlankField && field.deleting)
382+
continue;
383+
384+
field.set_relative_height(ratio);
385+
}
386+
387+
}
377388
}
378389

379390
export class NBField {

site/assets/js/lab/settings-panel.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ export function getLocalValue(key: LocalStoreKeys): string {
3333
function setupSetting() {
3434
let setting_panel = document.querySelector("#settings-panel");
3535

36-
if (!setting_panel) return;
36+
if (!setting_panel) {
37+
console.error("Could not locate settings element");
38+
return;
39+
}
3740

3841
const data_enable = new SettingInput(<HTMLLabelElement>setting_panel.querySelector(".data-enable"));
3942
const data_controls = Array.from(setting_panel.querySelectorAll(".data-control")).map(e => new SettingInput(<HTMLLabelElement>e));
@@ -175,11 +178,14 @@ class SettingInput extends Eventable<SettingInputEvents> {
175178

176179

177180
export function setupOpenCloseTriggers(panel: Element, button_selector: string = "#open-settings-button") {
181+
178182
let close_button = <HTMLDivElement>panel.querySelector(".close-button");
179183

180184
let open_button = <HTMLDivElement>document.body.querySelector(button_selector);
181185
open_button.classList.add("inactive");
182186

187+
console.log(open_button);
188+
183189
open_button.addEventListener("click", () => {
184190
if (panel.classList.contains("inactive")) {
185191
panel.classList.replace("inactive", "active");
@@ -200,7 +206,7 @@ function setupThemes(setting_panel: Element) {
200206

201207
let default_theme = <string>document.body.dataset.defaulttheme;
202208
let active_theme = getLocalValue(LocalStoreKeys.ActiveTheme) || default_theme;
203-
209+
204210
//document.body.classList.add(active_theme);
205211
let node = <HTMLTemplateElement>document.querySelector("#theme-entry-template");
206212

site/assets/sass/codemirror.sass

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
outline: none
1414
position: absolute !important
1515
font-size: 13px
16+
font-weight: 500
1617

1718
*
1819
color: none !important

site/assets/sass/color.scss

Lines changed: 86 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,59 @@
11
$theme-the-radlr-special: (
2-
/*
3-
colors
4-
- header fg bg
5-
6-
- base-line fg bg
7-
- focus fg bg
8-
- background fg bg
9-
10-
- controls fg bg :hover fg bg
11-
- links fg bg :hover fg bg
12-
*/
132

143
class-name: "the-RADLR-special",
4+
5+
base-fg: rgb(31, 31, 31),
6+
base-bg: rgb(241, 241, 241),
157

8+
// Panel header sections
9+
header-fg: rgb(31, 31, 31),
10+
header-bg: rgb(241, 241, 241),
11+
12+
header-hover-fg:rgb(241, 241, 241),
13+
header-hover-bg:rgb(31, 31, 31),
14+
15+
// Should contrast `base-*` to catch the user's attention
16+
focus-fg: rgb(227, 227, 227),
17+
focus-bg: rgb(61, 61, 61),
18+
19+
// Should blend in with `base-*` to avoid catching the user's attention
20+
backdrop-fg: rgb(92, 92, 92),
21+
backdrop-bg: rgb(227, 227, 227),
22+
23+
// Should work well when paired with `base-fg` and `backdrop-bg`
24+
button-fg: rgb(165, 165, 165),
25+
button-bg: transparent,
26+
button-hover-fg: rgb(241, 241, 241),
27+
button-hover-bg: rgb(31, 31, 31),
28+
29+
// Should contrast work will with `base-bg`, `focus-bg`, and `backdrop-bg`
30+
bc-address-bg: rgb(86, 78, 153),
31+
bc-address-fg: rgb(241, 241, 241),
32+
33+
// Gives a subtle contrast to `base-bg` to help delineate panel contents
34+
section-bg: rgba(0, 0, 0, 0.019),
35+
36+
// These setting contrast well with `focus-bg`
37+
settings-input-bg: rgb(227, 227, 227),
38+
settings-input-fg: rgb(61, 61, 61),
39+
settings-input-active-fg: rgb(255, 255, 255),
40+
settings-input-active-bg: rgb(53, 129, 204),
41+
settings-input-disabled-fg: rgb(245, 245, 245),
42+
settings-input-disabled-bg: rgb(187, 82, 82),
43+
44+
// These setting contrast well with `focus-bg` and `base-bg`
45+
link-fg: rgb(98, 178, 196),
46+
link-bg: transparent,
47+
link-hover-fg: rgb(94, 148, 214),
48+
link-hover-bg: transparent,
49+
50+
// ------------------------------------------
51+
);
52+
53+
$theme-pencil: (
54+
//
55+
class-name: "pencil",
56+
1657
header-fg: rgb(31, 31, 31),
1758
header-bg: rgb(241, 241, 241),
1859

@@ -39,13 +80,46 @@ $theme-the-radlr-special: (
3980

4081
section-bg: rgba(0, 0, 0, 0.019),
4182

83+
settings-input-bg: rgb(191, 191, 191),
84+
settings-input-fg: rgb(61, 61, 61),
85+
settings-input-active-fg: rgb(191, 191, 191),
86+
settings-input-active-bg: rgb(53, 129, 204),
87+
settings-input-disabled-fg: rgb(191, 191, 191),
88+
settings-input-disabled-bg: rgb(187, 82, 82),
89+
4290
link-fg: purple,
4391
link-bg: transparent,
4492

4593
link-hover-fg: purple,
4694
link-hover-bg: transparent,
4795

48-
// ------------------------------------------
96+
////
97+
98+
accent-color: #9f9f9f,
99+
// Main Colors
100+
bg-inc-2: #ffffff,
101+
bg-inc-1: #eeeeee,
102+
bg-basic: #e6e6e6,
103+
bg-dec-1: #7c7c7c67,
104+
bg-dec-2: #586464,
105+
106+
fg-inc-2: #bfbfbf,
107+
fg-inc-1: #afafaf,
108+
fg-basic: #848484,
109+
fg-dec-1: #393939,
110+
fg-dec-2: #000000,
111+
112+
// field header colors on hover
113+
field-header-bg: #e7ba02,
114+
field-header-fg: #ffffff,
115+
loader-bg: #cfcfcf,
116+
loader-fg: #3b9ee4,
117+
//
118+
border-color: #ff0000,
119+
debugger-action-red: #f17559,
120+
// codemirror
121+
active-color: #828282,
122+
inactive-color: #4a4a4a,
49123
);
50124

51125

@@ -145,43 +219,7 @@ $theme-desperados-unite: (
145219
inactive-color: #4a4a4a,
146220
);
147221

148-
$theme-pencil: (
149-
//
150-
class-name: "pencil",
151-
accent-color: #9f9f9f,
152-
// Main Colors
153-
bg-inc-2: #ffffff,
154-
bg-inc-1: #eeeeee,
155-
bg-basic: #e6e6e6,
156-
bg-dec-1: #7c7c7c67,
157-
bg-dec-2: #586464,
158-
159-
fg-inc-2: #bfbfbf,
160-
fg-inc-1: #afafaf,
161-
fg-basic: #848484,
162-
fg-dec-1: #393939,
163-
fg-dec-2: #000000,
164222

165-
// field header colors on hover
166-
field-header-bg: #e7ba02,
167-
field-header-fg: #ffffff,
168-
loader-bg: #cfcfcf,
169-
loader-fg: #3b9ee4,
170-
//
171-
border-color: #ff0000,
172-
debugger-action-red: #f17559,
173-
// codemirror
174-
active-color: #828282,
175-
inactive-color: #4a4a4a,
176-
177-
button-fg: rgb(187, 187, 187),
178-
button-bg: red,
179-
button-active-fg: rgb(255, 255, 255),
180-
button-active-bg: rgb(251, 94, 94),
181-
182-
bc-address-bg-active: rgb(255, 255, 255),
183-
bc-address-bg: rgb(255, 255, 255)
184-
);
185223

186224

187225
$themes : ( //

site/assets/sass/header.sass

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ header
2929
.header-right
3030
min-width: 200px
3131

32+
@include mobile-screens
33+
min-width: 180px
34+
3235
#header-logo
3336
display: inline-block
3437
height: 2em

0 commit comments

Comments
 (0)