Skip to content

Commit

Permalink
[WFX-594] Update Look & Feel preset buttons. (#2893)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamp01 authored and MrAlex94 committed Nov 10, 2022
1 parent 694a210 commit 45a9517
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
</hbox>
<hbox>
<checkbox id="tabContextLine" preference="userChrome.tab.photon_like_contextline"
data-l10n-id="tab-context-line" />
data-l10n-id="tab-context-line" />

<div class="popup-container">
<img class="preferences-info-button" />
Expand Down Expand Up @@ -278,7 +278,7 @@
</hbox>

<!-- MacOS uses native context menus, so we cannot modify them with userChrome. Moz listed allowing this as a WONTFIX. -->
#ifndef XP_MACOSX
#ifndef XP_MACOSX
<hbox>
<checkbox id="squareMenuPopup" preference="userChrome.rounding.square_menupopup"
data-l10n-id="square-menu-popup" />
Expand All @@ -292,7 +292,7 @@

<checkbox id="squareMenuItem" preference="userChrome.rounding.square_menuitem"
data-l10n-id="square-menu-item" />
#endif
#endif

<hbox>
<vbox>
Expand Down Expand Up @@ -387,22 +387,17 @@
<html:h2 style="-moz-box-flex: 1;" class="presets-header" data-l10n-id="preset-title" />
<button id="waterfoxDefaults" is="highlightable-button"
class="themepage-button check-theme-page-controlled" data-l10n-id="waterfox-defaults" />
<button id="smoothCorners" is="highlightable-button"
class="themepage-button check-theme-page-controlled" data-l10n-id="smooth-corners" />
<button id="squareCorners" is="highlightable-button"
class="themepage-button check-theme-page-controlled" data-l10n-id="square-corners" />
<button id="autohideAll" is="highlightable-button" class="themepage-button check-theme-page-controlled"
data-l10n-id="autohide-all" />
<button id="autohideNone" is="highlightable-button" class="themepage-button check-theme-page-controlled"
data-l10n-id="autohide-none" />
<button id="centerAll" is="highlightable-button" class="themepage-button check-theme-page-controlled"
data-l10n-id="center-all" />
<button id="centerNone" is="highlightable-button" class="themepage-button check-theme-page-controlled"
data-l10n-id="center-none" />
<button id="reducePadding" is="highlightable-button"
class="themepage-button check-theme-page-controlled" data-l10n-id="reduce-padding" />
<button id="increasePadding" is="highlightable-button"
class="themepage-button check-theme-page-controlled" data-l10n-id="increase-padding" />
<button id="roundedCorners" is="highlightable-button"
class="themepage-button check-theme-page-controlled" data-l10n-id="rounded-corners"
data-l10n-args="{&quot;isRounded&quot;:true}" />
<button id="autohideElements" is="highlightable-button"
class="themepage-button check-theme-page-controlled" data-l10n-id="autohide-all"
data-l10n-args="{&quot;isAutohide&quot;:true}" />
<button id="centerElements" is="highlightable-button"
class="themepage-button check-theme-page-controlled" data-l10n-id="center-all"
data-l10n-args="{&quot;isCentered&quot;:true}" />
<button id="padElements" is="highlightable-button" class="themepage-button check-theme-page-controlled"
data-l10n-id="reduce-padding" data-l10n-args="{&quot;isPadded&quot;:true}" />
</vbox>
</hbox>

Expand Down
65 changes: 35 additions & 30 deletions waterfox/browser/components/preferences/content/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ var gThemePane = {
get presets() {
return [
{
id: "smoothCorners",
prefs: [
id: "roundedCorners",
on: [
{ id: "userChrome.tab.squareTabCorners", value: false },
{ id: "userChrome.rounding.square_button", value: false },
{ id: "userChrome.rounding.square_panel", value: false },
Expand All @@ -117,10 +117,7 @@ var gThemePane = {
{ id: "userChrome.rounding.square_field", value: false },
{ id: "userChrome.rounding.square_checklabel", value: false },
],
},
{
id: "squareCorners",
prefs: [
off: [
{ id: "userChrome.tab.squareTabCorners", value: true },
{ id: "userChrome.rounding.square_button", value: true },
{ id: "userChrome.rounding.square_panel", value: true },
Expand All @@ -132,8 +129,8 @@ var gThemePane = {
],
},
{
id: "autohideAll",
prefs: [
id: "autohideElements",
on: [
{ id: "userChrome.autohide.tab", value: true },
{ id: "userChrome.autohide.tab.blur", value: true },
{ id: "userChrome.autohide.tabbar", value: true },
Expand All @@ -144,10 +141,7 @@ var gThemePane = {
{ id: "userChrome.autohide.sidebar", value: true },
{ id: "userChrome.hidden.urlbar_iconbox", value: true },
],
},
{
id: "autohideNone",
prefs: [
off: [
{ id: "userChrome.autohide.tab", value: false },
{ id: "userChrome.autohide.tab.blur", value: false },
{ id: "userChrome.autohide.tabbar", value: false },
Expand All @@ -160,39 +154,33 @@ var gThemePane = {
],
},
{
id: "centerAll",
prefs: [
id: "centerElements",
on: [
{ id: "userChrome.centered.tab", value: true },
{ id: "userChrome.centered.tab.label", value: true },
{ id: "userChrome.centered.urlbar", value: true },
],
},
{
id: "centerNone",
prefs: [
off: [
{ id: "userChrome.centered.tab", value: false },
{ id: "userChrome.centered.tab.label", value: false },
{ id: "userChrome.centered.urlbar", value: false },
],
},
{
id: "reducePadding",
prefs: [
id: "padElements",
on: [
{ id: "userChrome.padding.drag_space", value: false },
{ id: "userChrome.padding.urlView_expanding", value: false },
{ id: "userChrome.padding.urlView_expanding", value: true },
{ id: "userChrome.padding.menu_compact", value: true },
{ id: "userChrome.padding.bookmark_menu.compact", value: true },
{ id: "userChrome.padding.panel_header", value: false },
{ id: "userChrome.padding.panel_header", value: true },
],
},
{
id: "increasePadding",
prefs: [
off: [
{ id: "userChrome.padding.drag_space", value: true },
{ id: "userChrome.padding.urlView_expanding", value: true },
{ id: "userChrome.padding.urlView_expanding", value: false },
{ id: "userChrome.padding.menu_compact", value: false },
{ id: "userChrome.padding.bookmark_menu.compact", value: false },
{ id: "userChrome.padding.panel_header", value: true },
{ id: "userChrome.padding.panel_header", value: false },
],
},
];
Expand All @@ -214,8 +202,25 @@ var gThemePane = {
for (let preset of this.presets) {
let button = document.getElementById(preset.id);
if (button) {
button.addEventListener("click", () => {
for (let pref of preset.prefs) {
button.addEventListener("click", event => {
const target = event.target.getAttribute("data-l10n-args");
if (!target) {
// Something has gone wrong as all our event targets should
// have a data-l10n-args attr.
return;
}

const [presetKey, presetValue] = Object.entries(
JSON.parse(target)
)[0];
event.target.setAttribute(
"data-l10n-args",
JSON.stringify({ [presetKey]: !presetValue })
);

// If the button is initially true, we want to set the
// false preset values.
for (let pref of preset[presetValue ? "off" : "on"]) {
PrefUtils.set(pref.id, pref.value);
}
});
Expand Down
33 changes: 21 additions & 12 deletions waterfox/browser/locales/en-US/waterfox.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -123,22 +123,31 @@ category-theme =
preset-title = Presets
waterfox-defaults =
.label = Waterfox Defaults
smooth-corners =
rounded-corners =
.label = Rounded Corners
square-corners =
.label = Sharp Corners
.label =
{ $isRounded ->
[true] Toggle Square Corners
*[false] Toggle Smooth Corners
}
autohide-all =
.label = Autohide All
autohide-none =
.label = Autohide None
.label =
{ $isAutohide ->
[true] Toggle Autohide Off
*[false] Toggle Autohide On
}
center-all =
.label = Center Text
center-none =
.label = Left Align Text
.label =
{ $isCentered ->
[true] Toggle Centered Off
*[false] Toggle Centered On
}
reduce-padding =
.label = Compact
increase-padding =
.label = Spacious
.label =
{ $isPadded ->
[true] Toggle Compact Off
*[false] Toggle Compact On
}
enable-waterfox-theme-0 =
.label = Enable Waterfox theme customisations on all themes
enable-waterfox-theme-1 =
Expand Down

0 comments on commit 45a9517

Please sign in to comment.