From 15b3a52bb9964b08bab3ce5f76eb8d5e25bc7e45 Mon Sep 17 00:00:00 2001 From: johnny1093 <46250921+jsmorabito@users.noreply.github.com> Date: Sat, 11 Jul 2026 10:30:55 -0400 Subject: [PATCH] feat: add restore-default button to SliderComponent Adds an optional defaultValue prop to SliderComponent; when set, a small reset icon (matching the existing "reset to default" pattern used for advanced-toolbar icons) appears next to the value and resets it back to that default on click. Wired up for the General tab's "custom spacing" slider using DEFAULT_SETTINGS.spacing so it stays in sync if the default ever changes. MacroBuilder's per-item Delay slider is unaffected (no defaultValue passed, so no button shows - there's no persistent default for a one-off macro action value). Adds the new "Restore default" string to locale/en.json plus the ten other filled locale files (untranslated, English placeholder) so the locale completeness test suite still passes. --- locale/cz.json | 1 + locale/de.json | 1 + locale/en.json | 1 + locale/fr.json | 1 + locale/hr.json | 1 + locale/nl.json | 1 + locale/ru.json | 1 + locale/sv.json | 1 + locale/vi.json | 1 + locale/zh-cn.json | 1 + locale/zh-tw.json | 1 + src/ui/components/settingComponent.tsx | 22 ++++++++++++++++++++-- src/ui/components/settingTabComponent.tsx | 2 ++ 13 files changed, 33 insertions(+), 2 deletions(-) diff --git a/locale/cz.json b/locale/cz.json index 2dcdb91..8582e43 100755 --- a/locale/cz.json +++ b/locale/cz.json @@ -68,6 +68,7 @@ "Hide": "Skrýt", "Hide other Commands": "Skrýt ostatní příkazy", "Double click to enter custom value": "Dvakrát klikněte pro zadání vlastní hodnoty", + "Restore default": "Restore default", "Choose custom spacing for Command Buttons": "Vyberte vlastní odsazení pro tlačítka příkazů", "Change the spacing between commands. You can set different values on mobile and desktop.": "Změna odsazení mezi příkazy. Můžete nastavit různé hodnoty na mobilních a stolních zařízeních.", "Warning": "Varování", diff --git a/locale/de.json b/locale/de.json index b044f7e..795cee7 100755 --- a/locale/de.json +++ b/locale/de.json @@ -68,6 +68,7 @@ "Hide": "Verstecken", "Hide other Commands": "Andere Befehle verstecken", "Double click to enter custom value": "Doppelklicken um eigenen Wert einzutragen", + "Restore default": "Restore default", "Choose custom spacing for Command Buttons": "Wähle den Abstand zwischen Befehlen", "Change the spacing between commands. You can set different values on mobile and desktop.": "Verändert den Abstand zwischen Befehlen.", "Warning": "Achtung", diff --git a/locale/en.json b/locale/en.json index 09338bf..cb66923 100755 --- a/locale/en.json +++ b/locale/en.json @@ -68,6 +68,7 @@ "Hide": "Hide", "Hide other Commands": "Hide other Commands", "Double click to enter custom value": "Double click to enter custom value", + "Restore default": "Restore default", "Choose custom spacing for Command Buttons": "Choose custom spacing for Command Buttons", "Change the spacing between commands. You can set different values on mobile and desktop.": "Change the spacing between commands.", "Warning": "Warning", diff --git a/locale/fr.json b/locale/fr.json index f1352ec..9cec170 100755 --- a/locale/fr.json +++ b/locale/fr.json @@ -68,6 +68,7 @@ "Hide": "Masquer", "Hide other Commands": "Masquer les autres commandes", "Double click to enter custom value": "Double-cliquez pour entrer une valeur personnalisée", + "Restore default": "Restore default", "Choose custom spacing for Command Buttons": "Choisissez un espacement personnalisé pour les boutons de commande", "Change the spacing between commands. You can set different values on mobile and desktop.": "Modifier l'espacement entre les commandes.", "Warning": "Avertissement", diff --git a/locale/hr.json b/locale/hr.json index 759c461..a0a7697 100644 --- a/locale/hr.json +++ b/locale/hr.json @@ -68,6 +68,7 @@ "Hide": "Sakrij", "Hide other Commands": "Sakrij druge naredbe", "Double click to enter custom value": "Dvostruki klik za unos prilagođene vrijednosti", + "Restore default": "Restore default", "Choose custom spacing for Command Buttons": "Odaberi prilagođeni razmak za gumbe naredbi", "Change the spacing between commands. You can set different values on mobile and desktop.": "Promijeni razmak između naredbi.", "Warning": "Upozorenje", diff --git a/locale/nl.json b/locale/nl.json index c135d80..89c9dd3 100755 --- a/locale/nl.json +++ b/locale/nl.json @@ -68,6 +68,7 @@ "Hide": "Verberg", "Hide other Commands": "Verberg andere Commando's", "Double click to enter custom value": "Dubbel klik om een aangepaste waarde in te vullen", + "Restore default": "Restore default", "Choose custom spacing for Command Buttons": "Kies aangepaste regelafstand voor Commando Knoppen", "Change the spacing between commands. You can set different values on mobile and desktop.": "Verander regelafstand tussen Commando's. Dit kan verschillen tussen mobiel en dekstop.", "Warning": "Waarschuwing", diff --git a/locale/ru.json b/locale/ru.json index ac3cfe1..450926b 100755 --- a/locale/ru.json +++ b/locale/ru.json @@ -68,6 +68,7 @@ "Hide": "Спрятать", "Hide other Commands": "Спрятать другие команды", "Double click to enter custom value": "Дважды щелкните, чтобы ввести пользовательское значение", + "Restore default": "Restore default", "Choose custom spacing for Command Buttons": "Выберите пользовательский интервал между командными кнопками", "Change the spacing between commands. You can set different values on mobile and desktop.": "Измените расстояние между командами.", "Warning": "Предупреждение", diff --git a/locale/sv.json b/locale/sv.json index 65abe92..a03c5c6 100644 --- a/locale/sv.json +++ b/locale/sv.json @@ -68,6 +68,7 @@ "Hide": "Dölj", "Hide other Commands": "Dölj andra kommandon", "Double click to enter custom value": "Dubbelklicka för att fylla i valfritt värde", + "Restore default": "Restore default", "Choose custom spacing for Command Buttons": "Välj valfri distans mellan kommandoknappar", "Change the spacing between commands. You can set different values on mobile and desktop.": "Ändra distans mellan komandon. Du har möjlighet att sätta olika värden för stationära och mobila enheter.", "Warning": "Varning", diff --git a/locale/vi.json b/locale/vi.json index 99481c2..8fe4a2c 100644 --- a/locale/vi.json +++ b/locale/vi.json @@ -68,6 +68,7 @@ "Hide": "Ẩm", "Hide other Commands": "Ẩn các lệnh khác", "Double click to enter custom value": "Nhấn đúp(x2) để thêm giá trị tuỳ chỉnh", + "Restore default": "Restore default", "Choose custom spacing for Command Buttons": "Chọn độ giãn cách giữa các nút", "Change the spacing between commands. You can set different values on mobile and desktop.": "Thay đổi khoảng các giữa các lệnh", "Warning": "Cảnh báo", diff --git a/locale/zh-cn.json b/locale/zh-cn.json index 5afdaf1..2ab2b66 100755 --- a/locale/zh-cn.json +++ b/locale/zh-cn.json @@ -68,6 +68,7 @@ "Hide": "隐藏", "Hide other Commands": "隐藏其余命令", "Double click to enter custom value": "双击以添加自定义值", + "Restore default": "Restore default", "Choose custom spacing for Command Buttons": "为命令按钮选择自定义间距", "Change the spacing between commands. You can set different values on mobile and desktop.": "改变命令之间的间距。你可以为移动和桌面设备设置不同的值。", "Warning": "警告", diff --git a/locale/zh-tw.json b/locale/zh-tw.json index 9ceeea4..666a7a1 100755 --- a/locale/zh-tw.json +++ b/locale/zh-tw.json @@ -68,6 +68,7 @@ "Hide": "隱藏", "Hide other Commands": "隱藏其他命令", "Double click to enter custom value": "連按兩下以輸入自訂值", + "Restore default": "Restore default", "Choose custom spacing for Command Buttons": "選擇命令按鈕的自訂間距", "Change the spacing between commands. You can set different values on mobile and desktop.": "變更命令之間的間距。您可以為行動和桌面裝置設定不同的值。", "Warning": "警告", diff --git a/src/ui/components/settingComponent.tsx b/src/ui/components/settingComponent.tsx index 3e18de1..2ffe7d6 100644 --- a/src/ui/components/settingComponent.tsx +++ b/src/ui/components/settingComponent.tsx @@ -90,7 +90,13 @@ export function EyeToggleComponent({ ); } -export function SliderComponent(props: SettingProps): h.JSX.Element { +interface SliderProps extends SettingProps { + defaultValue?: number; +} +export function SliderComponent({ + defaultValue, + ...props +}: SliderProps): h.JSX.Element { const [val, setVal] = useState(props.value); return ( @@ -99,7 +105,19 @@ export function SliderComponent(props: SettingProps): h.JSX.Element { name={props.name} className="cmdr-slider" > -
+
+ {defaultValue !== undefined && ( + { + setVal(defaultValue); + props.changeHandler(defaultValue); + }} + /> + )}