Skip to content

Commit 89037cd

Browse files
committed
Add slider value rule and update existing sliders - PR_26159_049-slider-value-visibility
1 parent 2ba702b commit 89037cd

11 files changed

Lines changed: 269 additions & 28 deletions

File tree

admin/controls.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ <h3>Numeric Inputs</h3>
115115
<div class="control-demo">
116116
<div class="control-row"><label for="number">Numeric Input - Number - textbox</label><input
117117
id="number" type="number" value="100" min="0" max="999"></div>
118-
<div class="control-row"><label for="range">Numeric Input - Range - slider</label><input
119-
id="range" type="range" min="0" max="100" value="68"></div>
118+
<div class="control-row control-row--with-value"><label for="range">Numeric Input - Range - slider</label><input
119+
id="range" type="range" min="0" max="100" value="68"><output class="slider-current-value" for="range" data-slider-value-for="range">68</output></div>
120120
</div>
121121
</article>
122122
<article class="control-card side-green">

assets/theme-v2/css/forms.css

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,13 +364,31 @@ input[type="range"] {
364364
width: 100%
365365
}
366366

367-
.palette-generator-slider-row {
367+
.slider-value-row {
368368
display: grid;
369-
grid-template-columns: calc(var(--space-78) + var(--space-22)) minmax(var(--space-0), calc(var(--space-78) * 2));
369+
grid-template-columns: minmax(calc(var(--space-78) + var(--space-22)), max-content) minmax(var(--space-0), calc(var(--space-78) * 2)) minmax(var(--space-44), max-content);
370370
align-items: center;
371371
gap: var(--space-12)
372372
}
373373

374+
.control-row--with-value {
375+
grid-template-columns: var(--control-row-columns) minmax(var(--space-44), max-content)
376+
}
377+
378+
.slider-current-value {
379+
justify-self: end;
380+
min-width: var(--space-44);
381+
color: var(--text);
382+
font-weight: var(--font-weight-bold);
383+
font-variant-numeric: tabular-nums;
384+
text-align: right;
385+
white-space: nowrap
386+
}
387+
388+
.palette-generator-slider-row {
389+
grid-template-columns: minmax(calc(var(--space-78) + var(--space-22)), max-content) minmax(var(--space-0), calc(var(--space-78) * 2)) minmax(var(--space-44), max-content)
390+
}
391+
374392
textarea {
375393
min-height: var(--size-textarea-min);
376394
resize: vertical
Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,46 @@
11
(function () {
22
const selects = Array.from(document.querySelectorAll("[data-controls-theme-select]"));
33
const preview = document.querySelector("[data-controls-preview]");
4-
if (!selects.length || !preview) return;
54

6-
const groups = Array.from(selects[0].options).map((option) => option.value);
5+
if (selects.length && preview) {
6+
const groups = Array.from(selects[0].options).map((option) => option.value);
7+
8+
function applyTheme(selectedValue) {
9+
groups.forEach((group) => preview.classList.remove(group));
10+
preview.classList.add(selectedValue);
11+
selects.forEach((select) => {
12+
select.value = selectedValue;
13+
});
14+
}
715

8-
function applyTheme(selectedValue) {
9-
groups.forEach((group) => preview.classList.remove(group));
10-
preview.classList.add(selectedValue);
1116
selects.forEach((select) => {
12-
select.value = selectedValue;
17+
select.addEventListener("change", function () {
18+
applyTheme(select.value);
19+
});
1320
});
21+
applyTheme(selects[0].value);
1422
}
1523

16-
selects.forEach((select) => {
17-
select.addEventListener("change", function () {
18-
applyTheme(select.value);
19-
});
24+
function sliderDisplayValue(slider, output) {
25+
const unit = output.dataset.sliderUnit || "";
26+
const prefix = output.dataset.sliderSigned === "true" && Number(slider.value) > 0 ? "+" : "";
27+
return `${prefix}${slider.value}${unit}`;
28+
}
29+
30+
document.querySelectorAll("[data-slider-value-for]").forEach((output) => {
31+
const slider = document.getElementById(output.dataset.sliderValueFor);
32+
if (!slider) {
33+
return;
34+
}
35+
36+
const updateOutput = function () {
37+
const value = sliderDisplayValue(slider, output);
38+
output.value = value;
39+
output.textContent = value;
40+
};
41+
42+
slider.addEventListener("input", updateOutput);
43+
slider.addEventListener("change", updateOutput);
44+
updateOutput();
2045
});
21-
applyTheme(selects[0].value);
2246
}());

docs_build/dev/PROJECT_INSTRUCTIONS.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,37 @@ Required report output:
101101
- Current branch
102102
- Branch validation PASS/FAIL
103103

104+
## SLIDER VALUE VISIBILITY REQUIREMENT
105+
106+
All user-adjustable slider controls must display their current value while being adjusted.
107+
108+
Rules:
109+
- Value display must update live during drag/input.
110+
- Users must not need to release the slider to see the value.
111+
- Value display must remain visible at all times.
112+
- Value display must not rely solely on browser-native tooltips.
113+
- Sliders should prefer:
114+
- Label + Slider + Current Value
115+
- Example:
116+
- `Contrast [------^------] 40%`
117+
- `Saturation [------^------] 75%`
118+
- `Hue Shift [------^------] +15°`
119+
- Units should be displayed when meaningful:
120+
- `%`
121+
- degrees
122+
- pixels
123+
- milliseconds
124+
- volume
125+
- opacity
126+
- Floating thumb tooltips are optional.
127+
- Persistent visible values are required.
128+
- Applies to:
129+
- Toolbox tools
130+
- Project Workspace controls
131+
- Account/Admin pages
132+
- Theme V2 controls
133+
- Future tools and pages
134+
104135
## RULE PRECEDENCE
105136

106137
Newer appended sections override earlier overlapping rules.

docs_build/dev/reports/coverage_changed_js_guardrail.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ Missing changed runtime JS files are WARN, not FAIL.
66
Source: Playwright/Chromium built-in V8 coverage from the active Playwright run.
77

88
Changed runtime JS files considered:
9-
(100%) none changed - no changed runtime JS files
9+
(86%) toolbox/colors/colors.js - executed lines 2111/2111; executed functions 180/209
10+
(91%) assets/theme-v2/js/account-controls.js - executed lines 39/39; executed functions 10/11
1011

1112
Guardrail warnings:
12-
(100%) none changed - no changed runtime JS files
13+
(100%) none - no changed runtime JS coverage warnings

docs_build/dev/reports/playwright_v8_coverage_report.txt

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,26 @@ Note: coverage entries are aggregated across every page/tool where coverageRepor
1414
Exercised tool entry points detected:
1515
(85%) Toolbox Index - exercised 3 runtime JS files
1616
(0%) Tool Template V2 - not exercised by this Playwright run
17-
(64%) Theme V2 Shared JS - exercised 2 runtime JS files
17+
(76%) Theme V2 Shared JS - exercised 3 runtime JS files
1818

1919
Changed runtime JS files covered:
20-
(100%) none changed - no changed runtime JS files
20+
(86%) toolbox/colors/colors.js - executed lines 2111/2111; executed functions 180/209
21+
(91%) assets/theme-v2/js/account-controls.js - executed lines 39/39; executed functions 10/11
2122

2223
Files with executed line/function counts where available:
2324
(58%) src/engine/api/server-api-client.js - executed lines 159/159; executed functions 11/19
24-
(64%) assets/theme-v2/js/gamefoundry-partials.js - executed lines 525/525; executed functions 28/44
2525
(64%) assets/theme-v2/js/tool-display-mode.js - executed lines 201/201; executed functions 9/14
26+
(76%) assets/theme-v2/js/gamefoundry-partials.js - executed lines 525/525; executed functions 35/46
2627
(78%) toolbox/tool-registry-api-client.js - executed lines 148/148; executed functions 21/27
27-
(86%) toolbox/colors/colors.js - executed lines 2093/2093; executed functions 177/206
28+
(86%) toolbox/colors/colors.js - executed lines 2111/2111; executed functions 180/209
29+
(91%) assets/theme-v2/js/account-controls.js - executed lines 39/39; executed functions 10/11
2830
(100%) toolbox/colors/palette-api-client.js - executed lines 19/19; executed functions 4/4
2931

3032
Uncovered or low-coverage changed JS files:
31-
(100%) none changed - no changed runtime JS files
33+
(100%) none - no low-coverage changed runtime JS files
3234

3335
Changed JS files considered:
34-
(100%) none - no changed JS files
36+
(0%) tests/helpers/playwrightV8CoverageReporter.mjs - changed JS file not collected as browser runtime coverage
37+
(0%) tests/playwright/tools/PaletteToolMockRepository.spec.mjs - changed JS file not collected as browser runtime coverage
38+
(86%) toolbox/colors/colors.js - changed JS file with browser V8 coverage
39+
(91%) assets/theme-v2/js/account-controls.js - changed JS file with browser V8 coverage
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# PR_26159_049-slider-value-visibility
2+
3+
Status: PASS
4+
5+
## Branch Guard
6+
7+
| Requirement | Status | Evidence |
8+
|---|---|---|
9+
| Current branch must be `main` before BUILD work | PASS | `git branch --show-current` returned `main`. |
10+
11+
## Requirement Checklist
12+
13+
| Requirement | Status | Evidence |
14+
|---|---|---|
15+
| Read `docs_build/dev/PROJECT_INSTRUCTIONS.md` first | PASS | Read before branch validation and implementation. |
16+
| Add global `SLIDER VALUE VISIBILITY REQUIREMENT` governance section | PASS | `docs_build/dev/PROJECT_INSTRUCTIONS.md` includes the new section with live value, persistent visibility, unit, and scope rules. |
17+
| Find all active existing user-adjustable sliders | PASS | Active range inputs found in `toolbox/colors/index.html` and `admin/controls.html`; deprecated archive/start_of_day and docs-only mentions excluded. |
18+
| Update all active sliders to show persistent current values | PASS | Colors sliders have visible `<output>` values; Admin Controls range demo has a visible `<output>` value. |
19+
| Values update live during `input`, not only release/change | PASS | Colors values update through `renderPaletteGeneratorPreview()` on `input`; Admin Controls values update through `account-controls.js` on `input`. Playwright dispatches `input` and verifies visible text changes. |
20+
| Colors Contrast shows `%` | PASS | `data-palette-generator-contrast-value` displays `40%`, `80%`, and restored values in Playwright. |
21+
| Colors Saturation shows `%` | PASS | `data-palette-generator-saturation-value` displays `100%`, `20%`, and restored values in Playwright. |
22+
| Colors Hue Shift shows `°` | PASS | `data-palette-generator-hue-shift-value` displays ``, `+45°`, and `-35°` in Playwright. |
23+
| Colors Step Range shows `%` | PASS | `data-palette-generator-step-range-value` displays `50%`, `0%`, `100%`, and `70%` in Playwright. |
24+
| Any other active sliders show appropriate unit/raw value | PASS | Admin Controls generic numeric range displays raw values `68` and `42`. |
25+
| Use existing Theme V2/control patterns where possible | PASS | Added reusable Theme V2 `.slider-value-row`, `.control-row--with-value`, and `.slider-current-value` support in `assets/theme-v2/css/forms.css`. |
26+
| Do not add inline script/style/event handlers | PASS | Static scan found no inline script/style/event handlers in changed active HTML files. |
27+
| Do not add page-local CSS | PASS | CSS change is reusable Theme V2 support under `assets/theme-v2/css/forms.css`. |
28+
| Validate no console errors | PASS | Targeted Playwright lane collected no page errors, request failures, or console errors for covered pages. |
29+
| Produce required reports and ZIP | PASS | Review artifacts and `tmp/PR_26159_049-slider-value-visibility_delta.zip` produced. |
30+
31+
## Active Slider Inventory
32+
33+
| Slider | File | Unit | Update Path | Status |
34+
|---|---|---|---|---|
35+
| Contrast | `toolbox/colors/index.html` | `%` | `toolbox/colors/colors.js` `input` listener -> `renderPaletteGeneratorPreview()` -> visible output | PASS |
36+
| Saturation | `toolbox/colors/index.html` | `%` | `toolbox/colors/colors.js` `input` listener -> `renderPaletteGeneratorPreview()` -> visible output | PASS |
37+
| Hue Shift | `toolbox/colors/index.html` | degrees | `toolbox/colors/colors.js` `input` listener -> `renderPaletteGeneratorPreview()` -> signed degree output | PASS |
38+
| Step Range | `toolbox/colors/index.html` | `%` | `toolbox/colors/colors.js` `input` listener -> `renderPaletteGeneratorPreview()` -> visible output | PASS |
39+
| Numeric Input - Range demo | `admin/controls.html` | raw value | `assets/theme-v2/js/account-controls.js` `input` listener -> visible output | PASS |
40+
41+
Intentionally skipped: none. CSS selectors such as `input[type="range"]` are styling rules, not user-adjustable controls. Deprecated `archive/v1-v2` and `start_of_day` paths were excluded per request.
42+
43+
## Validation
44+
45+
| Command / Lane | Result | Notes |
46+
|---|---|---|
47+
| `node --check toolbox/colors/colors.js` | PASS | Colors runtime JS syntax. |
48+
| `node --check assets/theme-v2/js/account-controls.js` | PASS | Admin Controls external JS syntax. |
49+
| `node --check tests/playwright/tools/PaletteToolMockRepository.spec.mjs` | PASS | Targeted Playwright test syntax. |
50+
| `node --check tests/helpers/playwrightV8CoverageReporter.mjs` | PASS | Coverage helper syntax after Theme V2 JS runtime classification update. |
51+
| `rg --pcre2 ... toolbox/colors/index.html admin/controls.html` | PASS | No inline `<script>`, `<style>`, `oninput`, `onchange`, or `onclick` in changed active HTML. |
52+
| `npx playwright test tests/playwright/tools/PaletteToolMockRepository.spec.mjs` | PASS | 9 passed; covers Colors slider live values and Admin Controls range live value. |
53+
| `git diff --check` | PASS | No whitespace errors. |
54+
55+
## Playwright Impact
56+
57+
Playwright impacted: Yes.
58+
59+
Validated behavior:
60+
- Colors slider values are visible at rest and update during `input`.
61+
- Contrast, Saturation, Hue Shift, and Step Range display the requested units.
62+
- Reset and Restore Picker Settings refresh visible slider values.
63+
- Admin Controls range demo displays a persistent value and updates during `input`.
64+
- Covered pages report no console errors.
65+
66+
## Coverage
67+
68+
`docs_build/dev/reports/playwright_v8_coverage_report.txt` reports:
69+
- `(86%) toolbox/colors/colors.js`
70+
- `(91%) assets/theme-v2/js/account-controls.js`
71+
72+
No low-coverage changed runtime JS warnings were reported.
73+
74+
## Skipped Lanes
75+
76+
Full samples validation: SKIP. This PR changes governance, Theme V2 slider display support, Colors slider UI, and an Admin Controls demo slider; no sample loader/framework or sample JSON changed.
77+
78+
Broader workspace/tool suites: SKIP. The targeted Palette Tool lane covers the changed Colors runtime behavior and the Admin Controls slider demo. No shared persistence, engine, sample, or cross-tool launch behavior changed.

tests/helpers/playwrightV8CoverageReporter.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ export class PlaywrightV8CoverageReporter {
276276
return false;
277277
}
278278
return filePath.startsWith("src/")
279+
|| filePath.startsWith("assets/theme-v2/js/")
279280
|| filePath.startsWith("games/Asteroids/")
280281
|| filePath.startsWith("toolbox/")
281282
|| filePath.startsWith("common/");

0 commit comments

Comments
 (0)