Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix(theming): enforce theme should still provide dark as fallback
Signed-off-by: skjnldsv <[email protected]>
  • Loading branch information
skjnldsv committed Jul 16, 2024
commit 86ccba3714df3f96ed4bb2e0a316d04032a5a6ae
8 changes: 7 additions & 1 deletion apps/theming/lib/Service/ThemesService.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,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 @@ -76,9 +76,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 @@ -7,7 +7,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 @@ -67,6 +70,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 @@ -83,6 +90,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.