Skip to content

Commit 3c7f148

Browse files
committed
Prevent duplicate User Defined swatch adds and show Hex preview - PR_26156_181-palette-user-defined-add-state
1 parent 4fef530 commit 3c7f148

7 files changed

Lines changed: 233 additions & 49 deletions

File tree

assets/theme-v2/css/forms.css

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,21 @@ form {
3434
gap: var(--space-14)
3535
}
3636

37+
.field-inline {
38+
display: flex;
39+
gap: var(--space-8);
40+
align-items: center;
41+
max-width: 100%
42+
}
43+
44+
.field-inline input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),
45+
.field-inline textarea,
46+
.field-inline select {
47+
flex: 1 1 auto;
48+
min-width: var(--space-0);
49+
width: auto
50+
}
51+
3752
.field-hint {
3853
color: var(--muted);
3954
font-size: var(--font-size-sm);
@@ -114,6 +129,21 @@ input[type="color"][data-palette-swatch-preview]::-webkit-color-swatch {
114129
border-radius: var(--radius-xs)
115130
}
116131

132+
input[type="color"][data-palette-preview-state="invalid"] {
133+
background: repeating-linear-gradient(45deg, var(--panel), var(--panel) var(--space-4), var(--steel-soft) var(--space-4), var(--steel-soft) var(--space-8));
134+
border-style: dashed
135+
}
136+
137+
input[type="color"][data-palette-preview-state="invalid"]::-webkit-color-swatch {
138+
background: repeating-linear-gradient(45deg, var(--panel), var(--panel) var(--space-4), var(--steel-soft) var(--space-4), var(--steel-soft) var(--space-8));
139+
border-style: dashed
140+
}
141+
142+
input[type="color"][data-palette-preview-state="invalid"]::-moz-color-swatch {
143+
background: repeating-linear-gradient(45deg, var(--panel), var(--panel) var(--space-4), var(--steel-soft) var(--space-4), var(--steel-soft) var(--space-8));
144+
border-style: dashed
145+
}
146+
117147
input[type="color"][data-palette-swatch-size="small"] {
118148
width: var(--space-28);
119149
min-width: var(--space-28);
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# PR_26156_181 Palette User Defined Add State Report
2+
3+
## Result
4+
PASS
5+
6+
## Summary
7+
- Fixed User Defined Swatch add state so `Add User Defined` is disabled until Symbol, Hex, and Name form a valid new unique user-defined swatch.
8+
- After a successful add, the added Symbol, Hex, and Name remain visible and `Add User Defined` becomes disabled because the displayed swatch already exists.
9+
- Repeat-click duplicate add failure is prevented by the disabled add state and submit guard.
10+
- Editing Symbol, Hex, or Name to a valid unique swatch re-enables `Add User Defined`.
11+
- Selecting source/harmony/project colors continues to populate or clear User Defined fields according to the existing selection rules.
12+
- Added a Hex preview swatch in the left column immediately after the Hex label that updates for valid hex values and shows a visible invalid/empty state for blank or invalid values.
13+
- Tooltip Source remains on its own newline through the existing browser `title` format.
14+
15+
## Theme V2 Gap
16+
Existing Theme V2 form utilities had no reusable inline field layout for a compact preview plus full-width input, and no reusable invalid color-preview state.
17+
18+
Reusable Theme V2 additions:
19+
- `.field-inline` lays out compact inline field controls without page-local CSS.
20+
- `input[type="color"][data-palette-preview-state="invalid"]` shows a dashed patterned preview for blank/invalid color values.
21+
22+
## Validation
23+
- `node --check toolbox/colors/colors.js`
24+
- PASS
25+
- `node --check toolbox/colors/palette-workspace-repository.js`
26+
- PASS
27+
- `node --check tests/playwright/tools/PaletteToolMockRepository.spec.mjs`
28+
- PASS
29+
- `rg -n "DEFAULT_SOURCE_PALETTES|style=|<style|onclick|onchange|oninput|onsubmit" toolbox/colors/index.html toolbox/colors/colors.js toolbox/colors/palette-workspace-repository.js tests/playwright/tools/PaletteToolMockRepository.spec.mjs assets/theme-v2/css/forms.css`
30+
- PASS, no matches
31+
- `npx playwright test tests/playwright/tools/PaletteToolMockRepository.spec.mjs --project=playwright --workers=1 --reporter=list`
32+
- PASS, 3 tests
33+
- `npm run test:playwright:static`
34+
- PASS
35+
- `git diff --check -- assets/theme-v2/css/forms.css toolbox/colors/index.html toolbox/colors/colors.js toolbox/colors/palette-workspace-repository.js tests/playwright/tools/PaletteToolMockRepository.spec.mjs`
36+
- PASS with Git LF-to-CRLF warnings for touched files
37+
38+
## Verification Coverage
39+
- Add User Defined disables when the form is blank or invalid.
40+
- Add User Defined enables for a valid new unique user-defined swatch.
41+
- Successful add keeps Symbol, Hex, and Name visible.
42+
- Successful add disables Add User Defined while the displayed swatch already exists.
43+
- Repeat duplicate add is prevented by disabled Add User Defined state.
44+
- Changing Symbol, Hex, and Name to a valid unique swatch re-enables Add User Defined.
45+
- Selecting a source-backed color clears User Defined fields.
46+
- Selecting a user-defined color populates User Defined fields.
47+
- Hex preview appears in the left column immediately after the Hex label.
48+
- Hex preview updates for valid values and shows a visible invalid state for blank/invalid values.
49+
- Browser tooltip Source remains on its own newline before Tags.
50+
51+
## Skipped
52+
- Full samples smoke was not run, per BUILD instruction.
53+
- Broader tool/runtime lanes were skipped because this PR touches Palette Tool User Defined behavior and a small reusable Theme V2 form utility covered by the targeted Palette Tool runtime/UI lane plus static validation.

docs_build/dev/reports/playwright_v8_coverage_report.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ Exercised tool entry points detected:
1818

1919
Changed runtime JS files covered:
2020
(89%) toolbox/colors/palette-workspace-repository.js - executed lines 1244/1244; executed functions 125/140
21-
(96%) toolbox/colors/colors.js - executed lines 794/794; executed functions 78/81
21+
(96%) toolbox/colors/colors.js - executed lines 831/831; executed functions 82/85
2222

2323
Files with executed line/function counts where available:
2424
(65%) toolbox/project-workspace/project-workspace-mock-repository.js - executed lines 402/402; executed functions 20/31
2525
(75%) toolbox/toolRegistry.js - executed lines 1754/1754; executed functions 27/36
2626
(80%) assets/theme-v2/js/gamefoundry-partials.js - executed lines 205/205; executed functions 16/20
2727
(87%) assets/theme-v2/js/tool-display-mode.js - executed lines 201/201; executed functions 13/15
2828
(89%) toolbox/colors/palette-workspace-repository.js - executed lines 1244/1244; executed functions 125/140
29-
(96%) toolbox/colors/colors.js - executed lines 794/794; executed functions 78/81
29+
(96%) toolbox/colors/colors.js - executed lines 831/831; executed functions 82/85
3030
(100%) toolbox/colors/palette-source-mock-db.js - executed lines 927/927; executed functions 6/6
3131

3232
Uncovered or low-coverage changed JS files:
Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# PR_26156_180 Testing Lane Execution Report
1+
# PR_26156_181 Testing Lane Execution Report
22

33
## Result
44
PASS
@@ -10,44 +10,43 @@ PASS
1010
- PASS
1111
- `node --check tests/playwright/tools/PaletteToolMockRepository.spec.mjs`
1212
- PASS
13-
- `rg -n "DEFAULT_SOURCE_PALETTES|style=|<style|onclick|onchange|oninput|onsubmit" toolbox/colors/index.html toolbox/colors/colors.js toolbox/colors/palette-workspace-repository.js tests/playwright/tools/PaletteToolMockRepository.spec.mjs`
13+
- `rg -n "DEFAULT_SOURCE_PALETTES|style=|<style|onclick|onchange|oninput|onsubmit" toolbox/colors/index.html toolbox/colors/colors.js toolbox/colors/palette-workspace-repository.js tests/playwright/tools/PaletteToolMockRepository.spec.mjs assets/theme-v2/css/forms.css`
1414
- PASS, no matches
1515
- `npx playwright test tests/playwright/tools/PaletteToolMockRepository.spec.mjs --project=playwright --workers=1 --reporter=list`
1616
- PASS, 3 tests
1717
- `npm run test:playwright:static`
1818
- PASS
19-
- `git diff --check -- toolbox/colors/colors.js toolbox/colors/palette-workspace-repository.js tests/playwright/tools/PaletteToolMockRepository.spec.mjs`
20-
- PASS with Git LF-to-CRLF warning for the touched Playwright spec
19+
- `git diff --check -- assets/theme-v2/css/forms.css toolbox/colors/index.html toolbox/colors/colors.js toolbox/colors/palette-workspace-repository.js tests/playwright/tools/PaletteToolMockRepository.spec.mjs`
20+
- PASS with Git LF-to-CRLF warnings for touched files
2121

2222
## Required Lanes
23-
- Targeted Palette Tool runtime/UI lane: PASS.
23+
- Targeted Palette Tool User Defined runtime/UI lane: PASS.
2424
- Changed-file/static validation: PASS.
2525

2626
## Playwright Coverage
27-
- Source Palette Browser direct pin/add selects the newly added active swatch: PASS.
28-
- Source Pin All selects the last newly added swatch: PASS.
29-
- Duplicate-only Source Pin All keeps the existing selected swatch: PASS.
30-
- User Defined Swatch add selects the newly added custom swatch: PASS.
31-
- Harmony pin/add selects the newly added harmony swatch: PASS.
32-
- Harmony Add All selects the last newly added harmony swatch: PASS.
33-
- Duplicate-only Harmony Add All keeps the current selected swatch: PASS.
34-
- Browser tooltip order is Name, Hex, Source, Tags: PASS.
35-
- Empty active user-tag sets omit the Tags line: PASS.
27+
- Add User Defined disabled after successful add: PASS.
28+
- Successful add keeps Symbol/Hex/Name visible: PASS.
29+
- Repeat-click duplicate add failure prevented by disabled Add state: PASS.
30+
- Add User Defined re-enables only for a valid unique new swatch: PASS.
31+
- Selecting a source-backed color clears User Defined fields: PASS.
32+
- Selecting a user-defined color populates User Defined fields: PASS.
33+
- Hex preview appears in the left column immediately after the Hex label: PASS.
34+
- Hex preview updates valid/invalid state: PASS.
35+
- Tooltip Source remains newline-separated in browser title text: PASS.
3636

3737
## Impacted Lane
38-
- Palette Tool runtime/UI lane.
38+
- Palette Tool User Defined runtime/UI lane.
3939
- Changed-file/static validation lane.
4040

4141
## Skipped Lanes
4242
- Full samples smoke was skipped by BUILD instruction.
43-
- Shared Tool Center fullscreen UI lane was skipped because PR180 does not modify shared Tool Center or Theme V2 behavior.
44-
- Broader tool lanes were skipped because changes are confined to Palette Tool repository/UI behavior and targeted Palette spec assertions.
43+
- Broader tool lanes were skipped because behavior changes are confined to Palette Tool User Defined state and a reusable Theme V2 form utility exercised by the targeted Palette Tool spec.
4544

4645
## Not Run
4746
- Full samples smoke was not run, per BUILD instruction.
4847

4948
## Notes
50-
- Static validation generated companion reports during the run; non-required generated companion report updates were restored to their prior contents so the PR remains scoped to the requested report artifacts.
49+
- Static validation generated companion reports during the run; non-required generated companion report updates were restored to prior contents so the PR remains scoped to requested report artifacts.
5150

5251
## Coverage Artifact
5352
- Final V8 coverage artifact: `docs_build/dev/reports/playwright_v8_coverage_report.txt`.

0 commit comments

Comments
 (0)