Closed
Description
The Problem
There are at least 5 different "hiding" methods in code:
- Fomantic-UI's
.hidden
class - Browser and Fomantic-UI's
[hidden]
attribute - Gitea's
.hide
class - Inline
style="display: none"
- jQuery's
hide()
(show/toggle)
Some of these mechanisms just conflict:
[hidden]
is the weakest one, it will be affected bydisplay: xxx
- Sometimes, it should use
display: none !important
to overwrite other style'sdisplay: block
- Fomantic-UI's
.hidden
has other definitions for different selectors - jQuery's
hide()
may not work well with somedisplay: none !important
The Solution
- Introduce our own
.gt-hidden { display: none !important; }
- the
!important
is necessary because there are alwaysblock
orflex
elements need to be hidden - done in Move helpers to be prefixed with
gt-
#22879
- the
- Hijack jQuery's
hide()
and related functions to use our.gt-hidden
- Extend jQuery with customized show/hide/toggle #22884
- Update: replaced by our own showElem and related function, all-in-one step. Refactor hiding-methods, remove jQuery show/hide, remove
.hide
class, remove inline style=display:none #22950
- Drop all other classes/attributes, only use the
.gt-hidden
to hide
FAQ
Why the gu-
prefix? (Or something else like gt-
, etc...)
- It means "Gitea UI", it's time to have our own frontend framework and have a global design, instead of patching everything again and again.
- It is a clear style, won't be polluted by Fomantic UI
- It makes the refactoring clear, every changed line could be reviewed to check whether something is affected.
- It makes it easier to be searched from whole code base, since it's a dedicated name.
- It's widely accepted to add prefixes for frameworks. For example, tailwind also supports prefix: https://tailwindcss.com/docs/configuration#prefix