Description
I wanted to put together a list of proposals for CSS refactor and consolidation.
I've been working on some styling bugfixes lately and found the state of the CSS code to be quite frustrating. I wanted to discuss some options to improve performance, consistency, and reduce bugs.
Problems
UI Bugs
I'm fairly new to this project, but I've found quite a few UI bugs that really take away from the professional feel of Gitea. Many are reported in open issues, but most are not.
Here are a couple I found just now clicking around:
Consistency
There is a lot of inconsistency with how classes are defined and styled. There is some use of semantic.css
, but also helpers.less
(which is completely counter to Semantic UI ideology), and extreme usage of class overrides in web_src/less
.
This makes it very difficult to develop, but also results in some visual discrepancies. For instance, see the badges being styled 3 different ways below:
Further, we are effectively hard-forked from Fomantic source because of changes in ./web_src/fomantic/build/semantic.css
. I'm sure there were good reasons for these changes, but it will increasingly become impossible to update the dependency (btw, Semantic has support for theming, even demonstrating how to emulate GitHub's old styling).
Performance
index.css is flagged by Chrome dev tools as the highest network utilization when loading a page and a critical-path file, which takes 500ms + to load on my computer with a good internet connection (with caching disabled).
The is largely because of the general file size.
Priority: Highest
Encoded Data: 128 kB
Decoded Body: 845 kB
The utilization of CSS classes on a given page is extremely low. 96% of the css classes are unused on any given page:
Proposed Solutions
I'm not writing this for the purpose of putting the project or anyone down - there is incredible progress on the app! However, a lot of the focus is on adding new features without much consideration for the architecture. It's less glorious, but important stuff 😄
I propose the following tentative solutions:
- Create a style guide for Gitea
- Review new PRs against the style guide
- Add a CI test for CSS - there are many options to choose from (BackstopJS, Karma, etc.)
- Use webpack plugin to remove unused CSS (PurifyCSS)
- Refactor to remove ALL files in
web_src/less
& use Semantic's supported.variables
and.overrides
, beginning withhelpers.less
and all_*.less
files - Revert all changes to
web_src/fomantic/build/semantic.css
Questions
Am I missing anything else?
Is there significant desire to continue using Fomantic UI? It would be very painful to move away, but something like Tailwind would solve half of the suggestions above (including the precompiler)
This is certainly a huge undertaking, but I wanted to test to see if others agree with this analysis or it's not of interest. I also don't want to bring up all of these issues without helping towards a solution, so I plan to contribute to some of these resolutions.