Skip to content

Commit

Permalink
fix(theming): enforce theme should still provide dark as fallback
Browse files Browse the repository at this point in the history
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
  • Loading branch information
skjnldsv committed Jul 13, 2024
1 parent 4b296c7 commit 1d00f48
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
8 changes: 7 additions & 1 deletion apps/theming/lib/Service/ThemesService.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function __construct(
private LoggerInterface $logger,
private DefaultTheme $defaultTheme,
LightTheme $lightTheme,
DarkTheme $darkTheme,
private DarkTheme $darkTheme,
HighContrastTheme $highContrastTheme,
DarkHighContrastTheme $darkHighContrastTheme,
DyslexiaFont $dyslexiaFont) {
Expand Down Expand Up @@ -59,9 +59,15 @@ public function getThemes(): array {
}

$defaultTheme = $this->themesProviders[$this->defaultTheme->getId()];
$darkTheme = $this->themesProviders[$this->darkTheme->getId()];
$theme = $this->themesProviders[$enforcedTheme];
return [
// Leave the default theme as a fallback
$defaultTheme->getId() => $defaultTheme,
// Make sure we also have the dark theme to allow apps
// to scope sections of their UI to the dark theme
$darkTheme->getId() => $darkTheme,
// Finally, the enforced theme
$theme->getId() => $theme,
];
}
Expand Down
13 changes: 12 additions & 1 deletion apps/theming/src/components/ItemPreview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
<span v-if="enforced" class="theming__preview-warning" role="note">
{{ t('theming', 'Theme selection is enforced') }}
</span>
<NcCheckboxRadioSwitch class="theming__preview-toggle"

<!-- Only show checkbox if we can change themes -->
<NcCheckboxRadioSwitch v-show="!enforced"
class="theming__preview-toggle"
:checked.sync="checked"
:disabled="enforced"
:name="name"
Expand Down Expand Up @@ -73,6 +76,10 @@ export default {
return this.selected
},
set(checked) {
if (this.enforced) {
return
}
console.debug('Changed theme', this.theme.id, checked)
// If this is a radio, we can only enable
Expand All @@ -89,6 +96,10 @@ export default {
methods: {
onToggle() {
if (this.enforced) {
return
}
if (this.switchType === 'radio') {
this.checked = true
return
Expand Down
4 changes: 2 additions & 2 deletions dist/theming-personal-theming.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/theming-personal-theming.js.map

Large diffs are not rendered by default.

0 comments on commit 1d00f48

Please sign in to comment.