diff --git a/config/assets.php b/config/assets.php index 25113e8..409f8fd 100644 --- a/config/assets.php +++ b/config/assets.php @@ -6,7 +6,6 @@ return [ 'base' => [ 'css/app-layers.css', 'css/base/variables.base.css', - 'css/base/variables.theme-dark-green.css', 'css/base/variables.contrast.css', ], 'shared' => [ diff --git a/config/themes.php b/config/themes.php deleted file mode 100644 index 2d461b2..0000000 --- a/config/themes.php +++ /dev/null @@ -1,7 +0,0 @@ - 'Light', - 'dark' => 'Dark', - 'dark-green' => 'Dark green', -]; diff --git a/core/App/Container/Registrars/SettingsRegistrar.php b/core/App/Container/Registrars/SettingsRegistrar.php index 5509b42..219b3bd 100644 --- a/core/App/Container/Registrars/SettingsRegistrar.php +++ b/core/App/Container/Registrars/SettingsRegistrar.php @@ -26,7 +26,6 @@ use MintyPHP\Service\Settings\SettingsSessionGateway; use MintyPHP\Service\Settings\SettingsSmtpGateway; use MintyPHP\Service\Settings\SettingsSystemAuditGateway; use MintyPHP\Service\Settings\SettingsUserLifecycleGateway; -use MintyPHP\Service\Settings\ThemeConfigGateway; use MintyPHP\Service\Tenant\TenantService; final class SettingsRegistrar implements ContainerRegistrar @@ -65,7 +64,6 @@ final class SettingsRegistrar implements ContainerRegistrar $c->get(ApiTokenRepository::class), $c->get(AuditRecorderInterface::class) )); - $container->set(ThemeConfigGateway::class, static fn (AppContainer $c): ThemeConfigGateway => $c->get(SettingServicesFactory::class)->createThemeConfigGateway()); // Branding services are registered here because they depend on settings gateways // and are consumed alongside settings (e.g. in UserAccessPdfService and the admin UI). $container->set(BrandingLogoService::class, static fn (AppContainer $c): BrandingLogoService => $c->get(BrandingServicesFactory::class)->createBrandingLogoService()); diff --git a/core/Service/Settings/SettingServicesFactory.php b/core/Service/Settings/SettingServicesFactory.php index 2f80e59..fde1ef7 100644 --- a/core/Service/Settings/SettingServicesFactory.php +++ b/core/Service/Settings/SettingServicesFactory.php @@ -9,7 +9,6 @@ use MintyPHP\Repository\Tenant\TenantRepositoryInterface; class SettingServicesFactory { - private ?ThemeConfigGateway $themeConfigService = null; private ?SettingCacheService $settingCacheService = null; private ?SettingsCryptoGatewayInterface $settingsCryptoGateway = null; private ?SettingsMetadataGateway $settingsMetadataGateway = null; @@ -53,7 +52,6 @@ class SettingServicesFactory { return $this->settingsAppGateway ??= new SettingsAppGateway( $this->createSettingsMetadataGateway(), - $this->createThemeConfigGateway(), ); } @@ -108,11 +106,6 @@ class SettingServicesFactory ); } - public function createThemeConfigGateway(): ThemeConfigGateway - { - return $this->themeConfigService ??= new ThemeConfigGateway(); - } - public function createSettingsCryptoGateway(): SettingsCryptoGatewayInterface { return $this->settingsCryptoGateway ??= new SettingsCryptoGateway(); diff --git a/core/Service/Settings/SettingsAppGateway.php b/core/Service/Settings/SettingsAppGateway.php index 0f330f9..f2c0d61 100644 --- a/core/Service/Settings/SettingsAppGateway.php +++ b/core/Service/Settings/SettingsAppGateway.php @@ -13,15 +13,18 @@ use MintyPHP\I18n; * * The theme CATALOG utilities (listThemes, isAllowedTheme, normalizeTheme, * resolveDefaultTheme) stay because consumers across Tenant / Auth / User - * flows need to validate a theme value and resolve a safe default. There is - * no global setting lookup in these helpers anymore — the default is a - * hardcoded 'light' falling back to the first available catalog entry. + * flows need to validate a theme value and resolve a safe default. The + * catalog is a fixed two-entry list; 'light' is the hardcoded default. */ class SettingsAppGateway { + private const THEMES = [ + 'light' => 'Light', + 'dark' => 'Dark', + ]; + public function __construct( private readonly SettingsMetadataGateway $settingsMetadataGateway, - private readonly ThemeConfigGateway $themeConfigService ) { } @@ -82,14 +85,11 @@ class SettingsAppGateway } /** - * Catalog of available themes — purely code-level (config/themes.php), - * not a global setting. - * * @return array */ public function listThemes(): array { - return $this->themeConfigService->all(); + return self::THEMES; } public function isAllowedTheme(?string $theme): bool diff --git a/core/Service/Settings/ThemeConfigGateway.php b/core/Service/Settings/ThemeConfigGateway.php deleted file mode 100644 index 103902f..0000000 --- a/core/Service/Settings/ThemeConfigGateway.php +++ /dev/null @@ -1,46 +0,0 @@ - 'Light', - 'dark' => 'Dark', - ]; - - private ?array $themes = null; - - public function all(): array - { - if ($this->themes !== null) { - return $this->themes; - } - - $file = dirname(__DIR__, 3) . '/config/themes.php'; - if (!is_file($file)) { - $this->themes = self::DEFAULT_THEMES; - return $this->themes; - } - - $loaded = include $file; - if (!is_array($loaded)) { - $this->themes = self::DEFAULT_THEMES; - return $this->themes; - } - - $clean = []; - foreach ($loaded as $key => $label) { - $themeKey = strtolower(trim((string) $key)); - $themeLabel = trim((string) $label); - if ($themeKey === '' || $themeLabel === '') { - continue; - } - $clean[$themeKey] = $themeLabel; - } - - // Fall back to defaults if the file returns an empty or invalid list — system must always have themes. - $this->themes = $clean ?: self::DEFAULT_THEMES; - return $this->themes; - } -} diff --git a/core/Support/helpers/branding.php b/core/Support/helpers/branding.php index adf7d9a..23c9eb7 100644 --- a/core/Support/helpers/branding.php +++ b/core/Support/helpers/branding.php @@ -7,18 +7,16 @@ */ /** - * Load configured themes with a safe fallback list. + * Available themes. Fixed two-entry catalog — light and dark. + * + * @return array */ function appThemes(): array { - if (!class_exists('MintyPHP\\Service\\Settings\\ThemeConfigGateway')) { - return [ - 'light' => 'Light', - 'dark' => 'Dark', - ]; - } - - return app(\MintyPHP\Service\Settings\ThemeConfigGateway::class)->all(); + return [ + 'light' => 'Light', + 'dark' => 'Dark', + ]; } /** diff --git a/db/updates/2026-04-24-theme-simplification.sql b/db/updates/2026-04-24-theme-simplification.sql new file mode 100644 index 0000000..7d07799 --- /dev/null +++ b/db/updates/2026-04-24-theme-simplification.sql @@ -0,0 +1,7 @@ +-- Theme simplification: collapse catalog to light + dark. +-- Migrates any leftover 'dark-green' values back to safe defaults. +-- Idempotent — re-runs are a no-op because the WHERE clauses filter +-- on the exact legacy value that the preceding run already replaced. + +UPDATE users SET theme = 'light' WHERE theme = 'dark-green'; +UPDATE tenants SET default_theme = NULL WHERE default_theme = 'dark-green'; diff --git a/i18n/default_de.json b/i18n/default_de.json index f48b3f4..1473cfe 100644 --- a/i18n/default_de.json +++ b/i18n/default_de.json @@ -255,7 +255,6 @@ "Theme": "Theme", "Light": "Hell", "Dark": "Dunkel", - "Dark green": "Dunkelgrün", "Main menu": "Hauptmenü", "Toggle Sidebar": "Sidebar umschalten", "Toggle Detail Sidebar": "Detail-Seitenleiste umschalten", diff --git a/i18n/default_en.json b/i18n/default_en.json index 3f79d53..50799ce 100644 --- a/i18n/default_en.json +++ b/i18n/default_en.json @@ -255,7 +255,6 @@ "Theme": "Theme", "Light": "Light", "Dark": "Dark", - "Dark green": "Dark green", "Main menu": "Main menu", "Toggle Sidebar": "Toggle Sidebar", "Toggle Detail Sidebar": "Toggle Detail Sidebar", diff --git a/tests/Architecture/ConfigContractsTest.php b/tests/Architecture/ConfigContractsTest.php index e3b3744..eb6e260 100644 --- a/tests/Architecture/ConfigContractsTest.php +++ b/tests/Architecture/ConfigContractsTest.php @@ -14,7 +14,6 @@ final class ConfigContractsTest extends TestCase 'config/assets.php', 'config/routes.php', 'config/modules.php', - 'config/themes.php', 'config/config.php.example', ]; foreach ($required as $file) { diff --git a/tests/Service/Settings/SettingsAppGatewayTest.php b/tests/Service/Settings/SettingsAppGatewayTest.php index f431703..a913ee7 100644 --- a/tests/Service/Settings/SettingsAppGatewayTest.php +++ b/tests/Service/Settings/SettingsAppGatewayTest.php @@ -5,17 +5,13 @@ namespace MintyPHP\Tests\Service\Settings; use MintyPHP\Repository\Settings\SettingRepositoryInterface; use MintyPHP\Service\Settings\SettingsAppGateway; use MintyPHP\Service\Settings\SettingsMetadataGateway; -use MintyPHP\Service\Settings\ThemeConfigGateway; use PHPUnit\Framework\TestCase; class SettingsAppGatewayTest extends TestCase { private function createGateway(SettingRepositoryInterface $settings): SettingsAppGateway { - $themeConfig = $this->createMock(ThemeConfigGateway::class); - $themeConfig->method('all')->willReturn(['light' => 'Light', 'dark' => 'Dark']); - - return new SettingsAppGateway(new SettingsMetadataGateway($settings), $themeConfig); + return new SettingsAppGateway(new SettingsMetadataGateway($settings)); } public function testGetAppTitleReturnsNullWhenEmpty(): void diff --git a/tests/Service/Settings/SettingsGatewayNormalizationTest.php b/tests/Service/Settings/SettingsGatewayNormalizationTest.php index 734fc83..bf2e140 100644 --- a/tests/Service/Settings/SettingsGatewayNormalizationTest.php +++ b/tests/Service/Settings/SettingsGatewayNormalizationTest.php @@ -8,7 +8,6 @@ use MintyPHP\Service\Settings\SettingsFrontendTelemetryGateway; use MintyPHP\Service\Settings\SettingsMetadataGateway; use MintyPHP\Service\Settings\SettingsSmtpGateway; use MintyPHP\Service\Settings\SettingsSystemAuditGateway; -use MintyPHP\Service\Settings\ThemeConfigGateway; use PHPUnit\Framework\TestCase; final class SettingsGatewayNormalizationTest extends TestCase @@ -124,9 +123,6 @@ final class SettingsGatewayNormalizationTest extends TestCase private function newAppGateway(SettingRepositoryInterface $settingRepository): SettingsAppGateway { - $themeConfig = $this->createMock(ThemeConfigGateway::class); - $themeConfig->method('all')->willReturn(['light' => 'Light', 'dark' => 'Dark']); - - return new SettingsAppGateway(new SettingsMetadataGateway($settingRepository), $themeConfig); + return new SettingsAppGateway(new SettingsMetadataGateway($settingRepository)); } } diff --git a/tests/Support/ThemeResolutionTest.php b/tests/Support/ThemeResolutionTest.php index 8395880..51034e5 100644 --- a/tests/Support/ThemeResolutionTest.php +++ b/tests/Support/ThemeResolutionTest.php @@ -4,7 +4,6 @@ namespace MintyPHP\Tests\Support; use MintyPHP\App\AppContainer; use MintyPHP\Service\Settings\SettingCacheService; -use MintyPHP\Service\Settings\ThemeConfigGateway; use PHPUnit\Framework\TestCase; /** @@ -27,10 +26,6 @@ class ThemeResolutionTest extends TestCase $this->container = new AppContainer(); - $themeConfig = $this->createMock(ThemeConfigGateway::class); - $themeConfig->method('all')->willReturn(['light' => 'Light', 'dark' => 'Dark']); - $this->container->set(ThemeConfigGateway::class, fn () => $themeConfig); - $this->setAppSettings([]); $this->pushAppContainer($this->container); diff --git a/web/css/base/variables.base.css b/web/css/base/variables.base.css index ccf48f2..3c59970 100644 --- a/web/css/base/variables.base.css +++ b/web/css/base/variables.base.css @@ -602,7 +602,7 @@ } } -[data-theme^="dark"] { +[data-theme="dark"] { color-scheme: dark; --app-background-color: rgb(19, 22.5, 30.5); --app-sidebar-background-color: var(--app-background-color); @@ -830,7 +830,7 @@ --app-icon-invalid: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='rgb(149.5, 74, 80)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'%3E%3C/circle%3E%3Cline x1='12' y1='8' x2='12' y2='12'%3E%3C/line%3E%3Cline x1='12' y1='16' x2='12.01' y2='16'%3E%3C/line%3E%3C/svg%3E"); } -[data-theme^="dark"] +[data-theme="dark"] input:is( [type="submit"], [type="button"], diff --git a/web/css/base/variables.contrast.css b/web/css/base/variables.contrast.css index 2e78561..91d6bef 100644 --- a/web/css/base/variables.contrast.css +++ b/web/css/base/variables.contrast.css @@ -37,8 +37,8 @@ html[data-contrast="high"][data-theme="light"], --app-action-danger-outline-background: rgba(143, 0, 0, 0.2); } -html[data-contrast="high"][data-theme^="dark"], -[data-contrast="high"][data-theme^="dark"] { +html[data-contrast="high"][data-theme="dark"], +[data-contrast="high"][data-theme="dark"] { --app-background-color: #000; --app-sidebar-background-color: var(--app-background-color); --app-color: #f8fafc; diff --git a/web/css/base/variables.theme-dark-green.css b/web/css/base/variables.theme-dark-green.css deleted file mode 100644 index 713a86d..0000000 --- a/web/css/base/variables.theme-dark-green.css +++ /dev/null @@ -1,45 +0,0 @@ -@charset "UTF-8"; - -@layer tokens { -[data-theme="dark-green"] { - --app-background-color: #0f1713; - --app-sidebar-background-color: var(--app-background-color); - --app-color: #cfe0d6; - --app-text-selection-color: rgba(64, 170, 118, 0.25); - --app-muted-color: #8a9b91; - --app-muted-border-color: #223028; - --app-form-element-background-color: #141f19; - --app-form-element-border-color: #26362d; - --app-form-element-color: #d5e6dc; - --app-form-element-placeholder-color: #7f9187; - --app-card-background-color: #141f19; - --app-card-border-color: #223028; - --app-card-sectioning-background-color: #1a261f; - --app-details-card-open-summary-bg: #203026; - --app-dropdown-background-color: #141f19; - --app-dropdown-border-color: #223028; - --app-dropdown-hover-background-color: #1f2a24; - --app-modal-overlay-background-color: rgba(7, 10, 8, 0.75); - --app-progress-background-color: #223028; - --app-primary-h-base: 145; - --app-primary-s-base: 38%; - --app-primary-l-base: 38%; - --badge-success-bg: #123225; - --badge-success-color: #8de2b4; - --badge-success-border: #1f4a36; - --badge-danger-bg: #361a1d; - --badge-danger-color: #f4a3ad; - --badge-danger-border: #5a2b32; - --badge-info-bg: #142735; - --badge-info-color: #9ad2e0; - --badge-info-border: #214156; - --badge-warn-bg: #3a2a12; - --badge-warn-color: #ffdf9e; - --badge-warn-border: #5a401b; - --badge-neutral-bg: #1b2620; - --badge-neutral-color: #cfe0d6; - --badge-neutral-border: #2a3a31; - --app-tile-bg: rgb(20 28 24); - --app-blockquote-background-color: rgb(20 28 24); -} -} diff --git a/web/css/vendor-overrides/gridjs.css b/web/css/vendor-overrides/gridjs.css index f1bbfd6..48ec52b 100644 --- a/web/css/vendor-overrides/gridjs.css +++ b/web/css/vendor-overrides/gridjs.css @@ -691,11 +691,6 @@ filter: invert(1); } - html[data-theme="dark-green"] button.gridjs-sort, - html[data-theme="dark-green"] button.gridjs-sort-neutral { - filter: invert(1); - } - button.gridjs-sort { background-color: transparent; background-position-x: center; diff --git a/web/js/components/app-theme-toggle.js b/web/js/components/app-theme-toggle.js index c6b401a..11a6d5e 100644 --- a/web/js/components/app-theme-toggle.js +++ b/web/js/components/app-theme-toggle.js @@ -8,7 +8,7 @@ const setTheme = (theme) => { document.documentElement.dataset.theme = theme; }; -const isDarkTheme = (theme) => theme && theme.startsWith('dark'); +const isDarkTheme = (theme) => theme === 'dark'; const setIcon = (iconEl, theme) => { if (!iconEl) {