Skip to content

Maintenance: Refactor CSS & Themes - #2092

Merged
Jixabon merged 14 commits into
masterfrom
mtx/refactor-styles-themes
Apr 11, 2026
Merged

Maintenance: Refactor CSS & Themes#2092
Jixabon merged 14 commits into
masterfrom
mtx/refactor-styles-themes

Conversation

@Jixabon

@Jixabon Jixabon commented Apr 5, 2026

Copy link
Copy Markdown
Contributor

This PR revamps the css and theme system while adding system color scheme support.

Adds Theme controls to the System->Theme page for transparent control.

Updates functions with better naming with takeaways from #2088 as well as addresses the feature request in #2087

The base.css file should be strictly used for styles that establish strucutre and layout to the pages and elements. There is light theming in this file simply to make things "functional". In theory the theme stylesheets should be able to be removed and everything should still work/look as intended.

The app/css/themes contains the two included themes. Each theme file should include styles for both light and dark mode using the data attribute html[data-bs-theme="dark"] to apply them.

Where to put new styles

A comment based structure has been introduced to the stylesheets (the following) to better reduce dead classes and/or redundant styles. This structure should ideally exist for both light and dark styles.

  • Typography
  • Elements
  • Icons
  • Buttons
  • Forms
  • Layout
  • Page Specific

Custom Theme

To add a custom theme simply put the stylesheet in the /app/css/themes directory. Putting it in this director is not a requirement but is just where the other themes are stored. If it is put in a different location then be sure to set it in the theme definition. Then update the themes variables in two spots: app/js/ui/main.js and includes/defaults.php. Use the below format to define the theme.

"default" => [
    "name" => "RaspAP (default)",
    "url" => "app/css/themes/default.php",
    "modes" => ["light", "dark"]
],

or for javascript

"default": {
    "name": "RaspAP (default)",
    "url": "app/css/themes/default.php",
    "modes": ["light", "dark"]
},

Dead Styles?

The following styles were removed due to there being no apparent application for them. If this is in error please make note of this in a comment.

.toggle-off.btn {
  padding-left: 1.2rem;
  font-size: 0.9rem!important;
}

.toggle-on.btn {
  font-size: 0.9rem!important;
}

.gs-edit {
  border: 1px dashed #ccc;
  background-color: #f1faee;
  border-radius: 4px;
}

#passwd-toggle:active,
#passwd-toggle:hover,
#passwd-toggle:focus {
  border: 1px solid #ced4da;
}

.card-wrapper {
  margin: 1rem;
}

@keyframes flash {
  50% {
    opacity: 0;
  }
}

@Jixabon
Jixabon marked this pull request as ready for review April 5, 2026 15:20
@billz

billz commented Apr 6, 2026

Copy link
Copy Markdown
Member

Session related?

image

$_SESSION['theme'] = app/css/custom.php

lighttpd error log:

FastCGI-stderr:PHP message: PHP Warning:  Undefined array key "custom.php" in /var/www/html/includes/functions.php on line 583

@Jixabon

Jixabon commented Apr 6, 2026

Copy link
Copy Markdown
Contributor Author

I missed updating what it'll set as the default theme. It should ignore any values that aren't in the list of themes gracefully and set it to default.

@billz

billz commented Apr 6, 2026

Copy link
Copy Markdown
Member

Pulled the latest commit. Theme is set to 'default' now but error persists.

image

getThemeOpt() returns a string like 'app/css/default', but elsewhere I think the full theme array from RASPI_THEMES is expected. Check my commit and let me know if this is the right fix?

@Jixabon

Jixabon commented Apr 6, 2026

Copy link
Copy Markdown
Contributor Author

Looks like I missed that too 😂🤦. Just a visual check looks good. Expected behavior is the theme index (eg 'default') in the 'theme' cookie and the theme value (array) from the list in the session 'theme'.

@billz

billz commented Apr 7, 2026

Copy link
Copy Markdown
Member

Just noticed the theme toggle settings. Nice touch!

image

I'll handle adding locale strings for this.

@billz

billz commented Apr 7, 2026

Copy link
Copy Markdown
Member

I'll handle adding locale strings for this.

Disregard! I see now that this is already done 😅

@billz

billz commented Apr 8, 2026

Copy link
Copy Markdown
Member

This (and the Insiders PR) are looking good to merge.

@Jixabon
Jixabon merged commit 2175591 into master Apr 11, 2026
3 checks passed
@billz
billz deleted the mtx/refactor-styles-themes branch July 6, 2026 02:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants