Skip to content

Commit

Permalink
Some QOL and styling improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
daem-on committed Aug 1, 2022
1 parent 0009b97 commit eeed4d8
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 15 deletions.
6 changes: 3 additions & 3 deletions css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ body, input, button, textarea, label {
}

input, select {
border: 1px solid #aaa;
outline: none;
/* border: 1px solid #aaa;
outline: none; */
padding: 0 4px;
height: 22px;
box-shadow: none;
}

.hidden {
display:none;
display: none;
}

.zoom-in {
Expand Down
10 changes: 10 additions & 0 deletions css/toolOptionPanel.css
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,16 @@
width: 100%;
}

.toolOptionPanel .option-section.vertical {
display: flex;
flex-direction: column;
}

.toolOptionPanel .option-section textarea {
overflow-wrap: normal;
white-space: pre;
}

.toolOptionPanel .toolOptionResetButton {
position: absolute;
width: 16px;
Expand Down
1 change: 1 addition & 0 deletions src/editTH2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ export default {
const selection = pg.selection.getSelectedItems();
for (const item of selection)
item.locked = !item.locked;
pg.undo.snapshot("Toggle locked");
},

randomizeRotation: function() {
Expand Down
5 changes: 5 additions & 0 deletions src/objectSettings/customToolbarInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ export function constructSelect(element: HTMLDivElement, selectedVal: string, im
closeAllSelect(this.parentElement);
this.parentElement.classList.toggle("open");
});

input.addEventListener("keypress", e => {
if (e.key === "Enter") element.classList.remove("open");
})
input.addEventListener("blur", e => element.classList.remove("open"));
}

function constructOptionItem(option: HTMLOptionElement, imageRoot?: string) {
Expand Down
21 changes: 9 additions & 12 deletions src/toolOptionPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ import "jquery-ui/ui/widgets/draggable";
import pg from "../src/init";
import {constructSelect} from "../src/objectSettings/customToolbarInput";

type ComponentType = "int" | "list" | "float" | "text" | "button" | "boolean" |
"nullable-boolean" | "title" | "customList" | "textarea";

type component = {
type?: "int" | "list" | "float" | "text" | "button" | "boolean" |
"nullable-boolean" | "title" | "customList" | "textarea",
min?: any,
max?: any,
type?: ComponentType
min?: number,
max?: number,
label?: string,
options?: string[],
optionValuePairs?: [string, string|number][],
Expand Down Expand Up @@ -69,14 +71,8 @@ export default {
break;
case 'float':
case 'int':
let minAttr = '';
if(comp.min != undefined && comp.type == 'int') {
minAttr = ` min="${parseInt(comp.min)}"`;

} else if(comp.min != undefined && comp.type == 'float') {
minAttr = ` min="${parseFloat(comp.min)}"`;
}
$input = jQuery(`<input type="number" data-type="${comp.type}" name="${key}" value="${options[key]}"${minAttr}>`);
$input = jQuery(`<input type="number" data-type="${comp.type}" name="${key}" value="${options[key]}">`);
$input.attr("min", comp.min);

break;
case 'list':
Expand Down Expand Up @@ -122,6 +118,7 @@ export default {
break;
case 'textarea':
$input = jQuery(`<textarea name="${key}">${options[key] ?? ""}</textarea>`);
$optionSection.addClass('vertical');
break;
}

Expand Down

0 comments on commit eeed4d8

Please sign in to comment.