Skip to content

[Thread] CSS Optimization and Testing Summary #14639

Closed
@kdumontnu

Description

@kdumontnu

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:
image
image

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:
image
image

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).
image

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:
image

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 with helpers.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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/proposalThe new feature has not been accepted yet but needs to be discussed first.type/summaryThis issue aggregates a bunch of other issues

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions