Skip to content

Commit a3844af

Browse files
committed
added defaults and resets
1 parent 9669527 commit a3844af

5 files changed

Lines changed: 101 additions & 4 deletions

File tree

src/core/config.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,57 @@ export const EVENT_BUS_LOGGING = {
7474
* filter: [] // Log all events
7575
*/
7676
filter: ['command:']
77+
};
78+
79+
/**
80+
* Default color schemes for neighbor count and symmetry group modes.
81+
* These provide a rich, visually distinct palette for different rule configurations.
82+
*/
83+
export const DEFAULT_COLOR_SCHEMES = {
84+
customNeighborColors: {
85+
"0-0": { "on": "#FF0000", "off": "#2A0000" },
86+
"0-1": { "on": "#FED400", "off": "#2A2300" },
87+
"0-2": { "on": "#2AFF2A", "off": "#072A07" },
88+
"0-3": { "on": "#00FEFF", "off": "#002A2A" },
89+
"0-4": { "on": "#002AFF", "off": "#00072A" },
90+
"0-5": { "on": "#AA00FF", "off": "#1C002A" },
91+
"0-6": { "on": "#FF007F", "off": "#2A0015" },
92+
"1-0": { "on": "#FF0000", "off": "#2A0000" },
93+
"1-1": { "on": "#FED400", "off": "#2A2300" },
94+
"1-2": { "on": "#2AFF2A", "off": "#072A07" },
95+
"1-3": { "on": "#00FEFF", "off": "#002A2A" },
96+
"1-4": { "on": "#002AFF", "off": "#00072A" },
97+
"1-5": { "on": "#AA00FF", "off": "#1C002A" },
98+
"1-6": { "on": "#FF007F", "off": "#2A0015" }
99+
},
100+
customSymmetryColors: {
101+
"0-0": { "on": "#FF0000", "off": "#2A0000" },
102+
"0-1": { "on": "#FF6200", "off": "#2A1000" },
103+
"0-3": { "on": "#FEC400", "off": "#2A2000" },
104+
"0-5": { "on": "#C3FF00", "off": "#202A00" },
105+
"0-7": { "on": "#3AFF0A", "off": "#092A02" },
106+
"0-9": { "on": "#0AFF6B", "off": "#022A12" },
107+
"0-11": { "on": "#00FECE", "off": "#002A22" },
108+
"0-13": { "on": "#00CDFF", "off": "#00222A" },
109+
"0-15": { "on": "#006BFF", "off": "#00122A" },
110+
"0-21": { "on": "#000AFF", "off": "#00022A" },
111+
"0-23": { "on": "#5800FF", "off": "#0F002A" },
112+
"0-27": { "on": "#BA00FF", "off": "#1F002A" },
113+
"0-31": { "on": "#FF00E1", "off": "#2A0025" },
114+
"0-63": { "on": "#FF007F", "off": "#2A0015" },
115+
"1-0": { "on": "#FF0000", "off": "#2A0000" },
116+
"1-1": { "on": "#FF6200", "off": "#2A1000" },
117+
"1-3": { "on": "#FEC400", "off": "#2A2000" },
118+
"1-5": { "on": "#C3FF00", "off": "#202A00" },
119+
"1-7": { "on": "#3AFF0A", "off": "#092A02" },
120+
"1-9": { "on": "#0AFF6B", "off": "#022A12" },
121+
"1-11": { "on": "#00FECE", "off": "#002A22" },
122+
"1-13": { "on": "#00CDFF", "off": "#00222A" },
123+
"1-15": { "on": "#006BFF", "off": "#00122A" },
124+
"1-21": { "on": "#000AFF", "off": "#00022A" },
125+
"1-23": { "on": "#5800FF", "off": "#0F002A" },
126+
"1-27": { "on": "#BA00FF", "off": "#1F002A" },
127+
"1-31": { "on": "#FF00E1", "off": "#2A0025" },
128+
"1-63": { "on": "#FF007F", "off": "#2A0015" }
129+
}
77130
};

src/services/PersistenceService.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,8 @@ export function loadColorSettings() {
212212
on: ['#3cb44b', '#ffe119'],
213213
off: ['#1a4a23', '#665a0a']
214214
},
215-
customNeighborColors: {},
216-
customSymmetryColors: {}
215+
customNeighborColors: Config.DEFAULT_COLOR_SCHEMES.customNeighborColors,
216+
customSymmetryColors: Config.DEFAULT_COLOR_SCHEMES.customSymmetryColors
217217
};
218218
const loaded = _getItem(KEYS.COLOR_SETTINGS);
219219

src/ui/components/ChromaLabComponent.css

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,13 @@
121121
gap: 4px;
122122
}
123123

124-
.select-all-buttons {
124+
.column-actions {
125125
display: flex;
126126
align-items: center;
127+
justify-content: center;
127128
gap: 4px;
128129
font-size: 0.8em;
130+
font-weight: normal; /* Keep action text normal weight */
129131
}
130132

131133
.select-all-swatches {
@@ -321,4 +323,23 @@
321323
margin-bottom: 15px;
322324
background-color: #222;
323325
transition: background 0.3s ease;
326+
}
327+
328+
/* Reset Button Styling */
329+
.reset-column-defaults {
330+
font-size: 0.75em;
331+
padding: 2px 6px;
332+
border: 1px solid #7c3a3a; /* Reddish border */
333+
background-color: #4a3a3a;
334+
color: #fca5a5; /* Light red text */
335+
border-radius: 3px;
336+
cursor: pointer;
337+
transition: all 0.2s ease;
338+
margin-left: 8px; /* Add some space */
339+
}
340+
341+
.reset-column-defaults:hover {
342+
background-color: #5a4a4a;
343+
border-color: #ef4444;
344+
color: #fecaca;
324345
}

src/ui/components/ChromaLabComponent.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,10 @@ export class ChromaLabComponent extends BaseComponent {
114114
html += `<div class="color-group-column" data-center-state="${centerState}">
115115
<h5>
116116
Cell ${stateName}
117-
<div class="select-all-buttons">
117+
<div class="column-actions">
118118
<button class="button-link select-all-swatches" data-state-type="off">Select OFFs</button> |
119119
<button class="button-link select-all-swatches" data-state-type="on">Select ONs</button>
120+
<button class="button-link reset-column-defaults" data-mode="${groupType}" title="Reset all colors for this mode to defaults">Reset Mode</button>
120121
</div>
121122
</h5>`;
122123
groups.forEach(group => {
@@ -195,6 +196,15 @@ export class ChromaLabComponent extends BaseComponent {
195196
return;
196197
}
197198

199+
if (e.target.matches('.reset-column-defaults')) {
200+
const mode = e.target.dataset.mode;
201+
const modeDisplayName = mode === 'neighbor_count' ? 'Neighbor Count' : 'Symmetry';
202+
if (confirm(`Are you sure you want to reset all colors for '${modeDisplayName}' mode to their defaults?`)) {
203+
this.colorController.resetToDefaults(mode);
204+
}
205+
return;
206+
}
207+
198208
const swatchWrapper = e.target.closest('.color-swatch-wrapper');
199209
if (swatchWrapper) {
200210
const groupKey = swatchWrapper.closest('.color-group').dataset.groupKey;

src/ui/controllers/ColorController.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as PersistenceService from '../../services/PersistenceService.js';
22
import { EventBus, EVENTS } from '../../services/EventBus.js';
33
import { PRESET_PALETTES } from '../../core/colorPalettes.js';
4+
import { DEFAULT_COLOR_SCHEMES } from '../../core/config.js';
45

56
export class ColorController {
67
constructor() {
@@ -75,6 +76,18 @@ export class ColorController {
7576
this.#saveAndDispatch();
7677
}
7778

79+
resetToDefaults(mode) {
80+
if (mode === 'neighbor_count') {
81+
// Use structuredClone for a deep copy to prevent reference issues
82+
this.settings.customNeighborColors = structuredClone(DEFAULT_COLOR_SCHEMES.customNeighborColors);
83+
} else if (mode === 'symmetry') {
84+
this.settings.customSymmetryColors = structuredClone(DEFAULT_COLOR_SCHEMES.customSymmetryColors);
85+
}
86+
87+
// Save the updated settings and notify the UI
88+
this.#saveAndDispatch();
89+
}
90+
7891
applyGradientToSelection(orderedSwatchKeys, gradientColors) {
7992
if (!orderedSwatchKeys || orderedSwatchKeys.length === 0 || !gradientColors || gradientColors.length === 0) {
8093
return;

0 commit comments

Comments
 (0)