Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Miscellaneous parameter improvements #538

Merged
merged 4 commits into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@
"help:preview:cmd": "echo Previews w/o rebuild; needed for e2e tests.",
"preview:cmd": "vite --config etc/vite.config.ts preview",
"help:test:unit": "echo Typechecks and runs unit tests.",
"test:unit": "sh -c 'make -f etc/Makefile testunit \"cl_args=$@\"' phony",
"test:unit": "sh -xc 'make -f etc/Makefile testunit \"cl_args=$*\"' phony",
"help:test:e2e": "echo Runs end-to-end in-browser tests via Docker.",
"test:e2e": "sh -c 'make -f etc/Makefile e2e/certificate \"cl_args=$@\"' phony",
"test:e2e": "sh -xc 'make -f etc/Makefile e2e/certificate \"cl_args=$*\"' phony",
"help:test:e2e:cmd": "run-s -s help:test:e2e:cmd-*",
"help:test:e2e:cmd-1": "echo Runs end-to-end tests directly.",
"help:test:e2e:cmd-2": "echo However, note that it does not rebuild",
Expand All @@ -52,7 +52,7 @@
"help:test:e2e:cmd-6": "echo use by other scripts.",
"test:e2e:cmd": "playwright test -c e2e/playwright.config.ts",
"help:test:e2e:report": "echo Runs e2e and opens report in browser",
"test:e2e:report": "sh -c 'make -f etc/Makefile playreport \"cl_args=$@\"' phony",
"test:e2e:report": "sh -xc 'make -f etc/Makefile playreport \"cl_args=$*\"' phony",
"help:test:e2e:ui": "echo Runs interactive end-to-end tests directly.",
"test:e2e:ui": "npm run build && npm run test:e2e:cmd -- --ui",
"help:typecheck": "run-s -s help:typecheck:*",
Expand Down
12 changes: 10 additions & 2 deletions src/components/ParamEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -222,15 +222,23 @@
}

.stacked-param {
margin-top: 24px;
margin-top: 16px;
margin-bottom: 0px;
}

.stacked-param + .stacked-param {
margin-top: 24px;
}

.inline-param {
margin-top: 16px;
margin-top: 8px;
margin-bottom: 0px;
}

.stacked-param + .inline-param {
margin-top: 16px;
}

.sub-stacked-param {
border-left: 1px solid var(--ns-color-black);
margin-left: 8px;
Expand Down
43 changes: 38 additions & 5 deletions src/components/ParamField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
:id="paramName"
v-model:value="colorValue"
v-model:show-picker="showPicker"
show-alpha
:add-color="param.type === ParamType.COLOR_ARRAY"
@click="maybeTogglePicker"
@update:show-picker="reconcilePicker" />
Expand All @@ -29,14 +30,22 @@
{{ name }}
</option>
</select>
<textarea
v-else-if="param.type === ParamType.FORMULA"
:id="paramName"
:class="!status.isValid() ? 'error-field' : ''"
:value="value"
:placeholder="placehold(param)"
@keyup.enter="growArea($event)"
@input="updateString($event)" />
<input
v-else
:id="paramName"
type="text"
:class="!status.isValid() ? 'error-field' : ''"
:value="value"
:placeholder="placehold(param)"
@keyup.enter="blurField(paramName)"
@keyup.enter="blurField($event)"
@input="updateString($event)">
</label>

Expand Down Expand Up @@ -99,19 +108,31 @@
return map
}

function blurField(id: string) {
window.document.getElementById(id)?.blur()
function blurField(e: Event) {
const field = e.target
if (field instanceof HTMLElement) field.blur()
}
function growArea(e: Event) {
const area = e.target
if (area instanceof HTMLTextAreaElement) {
const curheight = area.getBoundingClientRect().height
area.style.height = `${curheight + 14}px`
}
}

function updateBoolean(e: Event) {
blurField(props.paramName)
blurField(e)
const inp = e.target as HTMLInputElement
emit('updateParam', inp.checked + '')
}

function updateString(e: Event) {
const t = e.target
if (t instanceof HTMLSelectElement || t instanceof HTMLInputElement) {
if (
t instanceof HTMLSelectElement
|| t instanceof HTMLInputElement
|| t instanceof HTMLTextAreaElement
) {
emit('updateParam', t.value)
}
}
Expand Down Expand Up @@ -253,6 +274,18 @@
}
}

textarea {
display: block;
border: none;
border-bottom: 1.5px solid var(--ns-color-black);
padding-bottom: 0px;
margin: 0px;
width: 100%;
height: 30px;
font-size: 14px;
resize: vertical;
}

.param-description {
font-size: 12px;
color: var(--ns-color-grey);
Expand Down
2 changes: 1 addition & 1 deletion src/shared/ParamType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ export const typeFunctions: {
status.forbid(
freeVars.size,
`free variables limited to ${inputSymbols}; `
+ `please remove '${freeVars}'`
+ `please remove '${Array.from(freeVars).join(', ')}'`
)
status.forbid(
fmla.freefuncs.size,
Expand Down
9 changes: 5 additions & 4 deletions src/shared/defineFeatured.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,11 @@ const featuredSIMs = [
'Wait For It',
'Turtle',
'Formula',
'domain=-1+1&angles=30+120&steps=30+30&widths=2&strokeColor=%237a9f6f'
+ '&bgColor=363071&speed=3&ruleMode=1&angleFormula=%7B%22-1%22%3A'
+ '+30%2C+%221%22%3A+120%7D%5Bstring%28a%29%5D&stepFormula=%7B%22'
+ '-1%22%3A+30%2C+%221%22%3A+30%7D%5Bstring%28a%29%5D&widthFormula'
'domain=-1+1&angles=30+120&steps=30+30&widths=2'
+ '&strokeColor=%237a106080+%237a9f6f50&bgColor=363071&speed=3'
+ '&angleFormula=%7B%22-1%22%3A+30%2C+%221%22%3A+120%7D'
+ '%5Bstring%28a%29%5D&stepFormula=%7B%22-1%22%3A+30%2C'
+ '+%221%22%3A+30%7D%5Bstring%28a%29%5D&widthFormula'
+ '=%7B%22-1%22%3A+2%2C+%221%22%3A+2%7D%5Bstring%28a%29%5D'
+ '&colorFormula=%7B%22-1%22%3A+%237a106080%2C+%221%22%3A'
+ '+%237a9f6f50%7D%5Bstring%28a%29%5D',
Expand Down