Skip to content
Open
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
5 changes: 5 additions & 0 deletions app/controller/_base.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ public function __construct($layout = '')

if (($theme) && (is_dir(public_path() . '/themes/' . $theme))) {
ThemeModule::load(public_path() . '/themes/' . $theme);
} else {
// Load default theme if no user theme is set
if (is_dir(public_path() . '/themes/default')) {
ThemeModule::load(public_path() . '/themes/default');
}
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions app/lang/en/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,10 @@
'danger_count' => '{count} in danger',
'all_in_good_standing' => 'All fine',
'theme' => 'Theme',
'toggle_theme' => 'Toggle theme',
'light_mode' => 'Light Mode',
'dark_mode' => 'Dark Mode',
'auto_mode' => 'Auto Mode',
'themes' => 'Themes',
'confirm_generate_new_token' => 'Generating a new token will invalidate the previous one. Do you want to proceed?',
'themes_hint' => 'Here you can import themes. Select a zip-file of your theme you want to import and once import succeeded, the theme will be available to all users. Note: If the zip-archive contains multiple themes, then the system will try to import all of them.',
Expand Down
57 changes: 57 additions & 0 deletions app/modules/ThemeModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,63 @@ public static function getList()
}
}

/**
* Get CSS variables for theme customization
* @return array
*/
public static function getCssVariables()
{
if (!self::ready()) {
return [];
}

$variables = [];

// Add theme-specific CSS variables if defined
if (isset(self::$theme_data->css_variables)) {
foreach (self::$theme_data->css_variables as $key => $value) {
$variables[$key] = $value;
}
}

return $variables;
}

/**
* Generate inline CSS for theme variables
* @return string
*/
public static function getCssVariablesInline()
{
$variables = self::getCssVariables();

if (empty($variables)) {
return '';
}

$css = '<style id="theme-variables">:root {';
foreach ($variables as $key => $value) {
$css .= '--' . $key . ': ' . $value . ';';
}
$css .= '}</style>';

return $css;
}

/**
* Check if theme supports light/dark mode
* @return bool
*/
public static function supportsLightDarkMode()
{
if (!self::ready()) {
return false;
}

return isset(self::$theme_data->supports_light_dark_mode) &&
self::$theme_data->supports_light_dark_mode === true;
}

/**
* @param $theme
* @return void
Expand Down
Loading