BlueGit

projects-timfalken-com microchess

Show custom colours by default; restyle checkbox/radio controls.

Disable-custom opts in via localStorage instead of defaulting on.
Native form controls now use the green Microchess look.

timfa Tim Falken · pushed by timfa

Authored 2026-09-13 · 2 months ago

Hash
f96fcb203eea46d64c4ba9580c8b75ea494ceb01
Parent
d80c51eb
2 files changed +89 −3
web/assets/app.css +87 −2
@@ -1125,12 +1125,85 @@ dialog input {
1125 1125 .settings-check {
1126 1126 display: flex;
1127 1127 align-items: center;
1128 gap: 8px;
1128 gap: 10px;
1129 1129 margin: 12px 0 4px;
1130 padding: 10px 12px;
1131 border: 1px solid var(--line);
1132 border-radius: 12px;
1133 background: var(--paper);
1130 1134 font-size: 13px;
1131 1135 cursor: pointer
1132 1136 }
1133 1137
1138 .settings-check:hover {
1139 border-color: #c9d2b8
1140 }
1141
1142 /* Match Microchess green controls instead of native OS widgets. */
1143 input[type="checkbox"],
1144 input[type="radio"] {
1145 appearance: none;
1146 -webkit-appearance: none;
1147 width: 1.1rem;
1148 height: 1.1rem;
1149 margin: 0;
1150 flex-shrink: 0;
1151 border: 2px solid var(--green);
1152 background: var(--paper);
1153 display: inline-grid;
1154 place-content: center;
1155 cursor: pointer;
1156 transition: background .15s, border-color .15s, box-shadow .15s
1157 }
1158
1159 input[type="checkbox"] {
1160 border-radius: 4px
1161 }
1162
1163 input[type="radio"] {
1164 border-radius: 50%
1165 }
1166
1167 input[type="checkbox"]::before,
1168 input[type="radio"]::before {
1169 content: "";
1170 width: .55rem;
1171 height: .55rem;
1172 transform: scale(0);
1173 transition: transform .12s ease-in-out;
1174 box-shadow: inset 1em 1em var(--paper)
1175 }
1176
1177 input[type="checkbox"]::before {
1178 clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0, 43% 62%)
1179 }
1180
1181 input[type="radio"]::before {
1182 border-radius: 50%;
1183 box-shadow: inset 1em 1em var(--green)
1184 }
1185
1186 input[type="checkbox"]:checked {
1187 background: var(--green);
1188 border-color: var(--green)
1189 }
1190
1191 input[type="checkbox"]:checked::before,
1192 input[type="radio"]:checked::before {
1193 transform: scale(1)
1194 }
1195
1196 input[type="radio"]:checked {
1197 background: var(--paper);
1198 border-color: var(--green)
1199 }
1200
1201 input[type="checkbox"]:focus-visible,
1202 input[type="radio"]:focus-visible {
1203 outline: 2px solid var(--green);
1204 outline-offset: 2px
1205 }
1206
1134 1207 .color-mode-options {
1135 1208 display: grid;
1136 1209 gap: 10px;
@@ -1144,7 +1217,19 @@ dialog input {
1144 1217 padding: 12px;
1145 1218 border: 1px solid var(--line);
1146 1219 border-radius: 12px;
1147 cursor: pointer
1220 background: var(--paper);
1221 cursor: pointer;
1222 transition: border-color .15s, background .15s, box-shadow .15s
1223 }
1224
1225 .color-mode-option:hover {
1226 border-color: #c9d2b8
1227 }
1228
1229 .color-mode-option:has(input:checked) {
1230 border-color: var(--green);
1231 background: #eef5e4;
1232 box-shadow: 0 0 0 1px rgba(54, 93, 69, 0.2)
1148 1233 }
1149 1234
1150 1235 .color-mode-option strong {
@@ -1125,12 +1125,85 @@ dialog input {
1125.settings-check {
1125.settings-check {
1126 display: flex;
1126 display: flex;
1127 align-items: center;
1127 align-items: center;
1128 gap: 8px;
1128 gap: 10px;
1129 margin: 12px 0 4px;
1129 margin: 12px 0 4px;
1130 padding: 10px 12px;
1131 border: 1px solid var(--line);
1132 border-radius: 12px;
1133 background: var(--paper);
1130 font-size: 13px;
1134 font-size: 13px;
1131 cursor: pointer
1135 cursor: pointer
1132}
1136}
1133
1137
1138.settings-check:hover {
1139 border-color: #c9d2b8
1140}
1141
1142/* Match Microchess green controls instead of native OS widgets. */
1143input[type="checkbox"],
1144input[type="radio"] {
1145 appearance: none;
1146 -webkit-appearance: none;
1147 width: 1.1rem;
1148 height: 1.1rem;
1149 margin: 0;
1150 flex-shrink: 0;
1151 border: 2px solid var(--green);
1152 background: var(--paper);
1153 display: inline-grid;
1154 place-content: center;
1155 cursor: pointer;
1156 transition: background .15s, border-color .15s, box-shadow .15s
1157}
1158
1159input[type="checkbox"] {
1160 border-radius: 4px
1161}
1162
1163input[type="radio"] {
1164 border-radius: 50%
1165}
1166
1167input[type="checkbox"]::before,
1168input[type="radio"]::before {
1169 content: "";
1170 width: .55rem;
1171 height: .55rem;
1172 transform: scale(0);
1173 transition: transform .12s ease-in-out;
1174 box-shadow: inset 1em 1em var(--paper)
1175}
1176
1177input[type="checkbox"]::before {
1178 clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0, 43% 62%)
1179}
1180
1181input[type="radio"]::before {
1182 border-radius: 50%;
1183 box-shadow: inset 1em 1em var(--green)
1184}
1185
1186input[type="checkbox"]:checked {
1187 background: var(--green);
1188 border-color: var(--green)
1189}
1190
1191input[type="checkbox"]:checked::before,
1192input[type="radio"]:checked::before {
1193 transform: scale(1)
1194}
1195
1196input[type="radio"]:checked {
1197 background: var(--paper);
1198 border-color: var(--green)
1199}
1200
1201input[type="checkbox"]:focus-visible,
1202input[type="radio"]:focus-visible {
1203 outline: 2px solid var(--green);
1204 outline-offset: 2px
1205}
1206
1134.color-mode-options {
1207.color-mode-options {
1135 display: grid;
1208 display: grid;
1136 gap: 10px;
1209 gap: 10px;
@@ -1144,7 +1217,19 @@ dialog input {
1144 padding: 12px;
1217 padding: 12px;
1145 border: 1px solid var(--line);
1218 border: 1px solid var(--line);
1146 border-radius: 12px;
1219 border-radius: 12px;
1147 cursor: pointer
1220 background: var(--paper);
1221 cursor: pointer;
1222 transition: border-color .15s, background .15s, box-shadow .15s
1223}
1224
1225.color-mode-option:hover {
1226 border-color: #c9d2b8
1227}
1228
1229.color-mode-option:has(input:checked) {
1230 border-color: var(--green);
1231 background: #eef5e4;
1232 box-shadow: 0 0 0 1px rgba(54, 93, 69, 0.2)
1148}
1233}
1149
1234
1150.color-mode-option strong {
1235.color-mode-option strong {
web/assets/app.js +2 −1
@@ -9,7 +9,8 @@ const pieceFileNames = { k: 'king', q: 'queen', r: 'rook', b: 'bishop', n: 'knig
9 9 const DISABLE_CUSTOM_COLOURS_KEY = 'microchess-disable-custom-colours';
10 10 function customColoursDisabled ()
11 11 {
12 try { return localStorage.getItem(DISABLE_CUSTOM_COLOURS_KEY) !== '0'; } catch { return true; }
12 // Default off → custom colours visible unless the player opted out.
13 try { return localStorage.getItem(DISABLE_CUSTOM_COLOURS_KEY) === '1'; } catch { return false; }
13 14 }
14 15 function setCustomColoursDisabled (disabled)
15 16 {
@@ -9,7 +9,8 @@ const pieceFileNames = { k: 'king', q: 'queen', r: 'rook', b: 'bishop', n: 'knig
9const DISABLE_CUSTOM_COLOURS_KEY = 'microchess-disable-custom-colours';
9const DISABLE_CUSTOM_COLOURS_KEY = 'microchess-disable-custom-colours';
10function customColoursDisabled ()
10function customColoursDisabled ()
11{
11{
12 try { return localStorage.getItem(DISABLE_CUSTOM_COLOURS_KEY) !== '0'; } catch { return true; }
12 // Default off → custom colours visible unless the player opted out.
13 try { return localStorage.getItem(DISABLE_CUSTOM_COLOURS_KEY) === '1'; } catch { return false; }
13}
14}
14function setCustomColoursDisabled (disabled)
15function setCustomColoursDisabled (disabled)
15{
16{