mirror of
https://github.com/unraid/webgui.git
synced 2026-01-06 17:49:58 -06:00
refactor: enhance ThemeHelper class to support unlimited width and update DefaultPageLayout.php for new constructor parameters
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
?>
|
||||
<?
|
||||
require_once "$docroot/plugins/dynamix/include/ThemeHelper.php";
|
||||
$themeHelper = new ThemeHelper($display['theme']);
|
||||
$themeHelper = new ThemeHelper($display['theme'], $display['width']);
|
||||
$theme = $themeHelper->getThemeName(); // keep $theme, $themes1, $themes2 vars for plugin backwards compatibility for the time being
|
||||
$themes1 = $themeHelper->isTopNavTheme();
|
||||
$themes2 = $themeHelper->isSidebarTheme();
|
||||
|
||||
@@ -31,19 +31,44 @@ class ThemeHelper {
|
||||
private bool $sidebarTheme;
|
||||
private bool $darkTheme;
|
||||
private bool $lightTheme;
|
||||
private string $themeHtmlClass;
|
||||
private string $fgcolor;
|
||||
private bool $unlimitedWidth = false;
|
||||
|
||||
/**
|
||||
* Constructor for ThemeHelper
|
||||
*
|
||||
* @param string|null $theme The theme name (optional)
|
||||
* @param '1'|null $width The width of the theme (optional)
|
||||
*/
|
||||
public function __construct(?string $theme = null) {
|
||||
if ($theme === null) {
|
||||
throw new \RuntimeException(self::INIT_ERROR);
|
||||
public function __construct(?string $theme = null, ?string $width = null) {
|
||||
if ($theme !== null) {
|
||||
$this->initWithCurrentThemeSetting($theme);
|
||||
}
|
||||
$this->initWithCurrentThemeSetting($theme);
|
||||
|
||||
if ($width !== null) {
|
||||
$this->setWidth($width);
|
||||
}
|
||||
|
||||
throw new \RuntimeException(self::INIT_ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the width setting
|
||||
*
|
||||
* @param string $width The width setting ('1' for unlimited, empty string for boxed)
|
||||
* @return void
|
||||
*/
|
||||
public function setWidth(string $width): void {
|
||||
$this->unlimitedWidth = ($width === '1');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if unlimited width is enabled
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isUnlimitedWidth(): bool {
|
||||
return $this->unlimitedWidth;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -60,11 +85,6 @@ class ThemeHelper {
|
||||
$this->darkTheme = in_array($this->themeName, self::DARK_THEMES);
|
||||
$this->lightTheme = in_array($this->themeName, self::LIGHT_THEMES);
|
||||
|
||||
$this->themeHtmlClass = "Theme--{$this->themeName}";
|
||||
if ($this->sidebarTheme) {
|
||||
$this->themeHtmlClass .= " Theme--sidebar";
|
||||
}
|
||||
|
||||
$this->fgcolor = self::FGCOLORS[$this->themeName] ?? self::COLOR_BLACK;
|
||||
}
|
||||
|
||||
@@ -88,8 +108,26 @@ class ThemeHelper {
|
||||
return $this->lightTheme;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the theme HTML class string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getThemeHtmlClass(): string {
|
||||
return $this->themeHtmlClass;
|
||||
|
||||
$classes = ["Theme--{$this->themeName}"];
|
||||
|
||||
if ($this->sidebarTheme) {
|
||||
$classes[] = "Theme--sidebar";
|
||||
}
|
||||
|
||||
if ($this->topNavTheme) {
|
||||
$classes[] = "Theme--nav-top";
|
||||
}
|
||||
|
||||
$classes[] = $this->unlimitedWidth ? "Theme--unlimited-width" : "Theme--boxed-width";
|
||||
|
||||
return implode(' ', $classes);
|
||||
}
|
||||
|
||||
public function getFgColor(): string {
|
||||
|
||||
@@ -114,7 +114,7 @@ Files like `UserList.css`, `ShareList.css` that provide reusable styles:
|
||||
### Theme Classes
|
||||
|
||||
- Main theme: `.Theme--{themename}`
|
||||
- Layout variants: `.Theme--sidebar`, `.Theme--topnav`
|
||||
- Layout variants: `.Theme--sidebar`, `.Theme--nav-top`
|
||||
|
||||
## Best Practices
|
||||
|
||||
|
||||
Reference in New Issue
Block a user