Open pixtur opened 1 year ago
Thanks a lot @pixtur for such detailed feedback. I'm tagging it as v6 as it can be studied in depth when we start working on the new major version of Bootstrap where we plan some CSS refactoring, especially regarding the themes (and so the Sass/CSS vars linked to that). I'll read your feedback thoroughly as soon as possible.
@julien-deramond Thank you. I hope I didn't come across too negative here. While writing the issue and reading the documentation more thoroughly, I had to remove and adjust many of my initial complaints. This is just my way of learning stuff. BS really has come a long way. So, if I can slightly contribute to upcoming releases, perfect!
Prerequisites
Proposal
I am currently working on a Figma design to incorporate variable-based theme support for a BS5-based site. During the process, I found the CSS Variable documentation to be particularly helpful.
I understand that the Bootstrap team invested significant time and effort in determining these names, likely with good reasons for maintaining the status quo. However, I firmly believe that constructive feedback is always beneficial, hence I would like to share my thoughts.
Expectations
To begin with, I have certain expectations from a variable collection:
status-
,text-
,bg-
would be beneficial when sorting alphabetically, though I recognize this may be a personal preference.While developing the variable specification, I found the current naming conventions rather challenging to work with. As a result, I created a mapping table to prevent any errors. I am sharing my findings with the hope that they might be considered for inclusion in a future version of Bootstrap.
Suggestions
--bs-gray-XXX
variables, as their inversion for the dark theme could lead to misleading names. A potential alternative could be naming it--bs-foreground-???
, where--bs-foreground-full
represents the pure color for the light theme and--bs-foreground-000
represents the background color. (Although there might be better names forforeground
).-rgb
. It's extremely unfortunate that CSS does not allow RGBA variables to be used in rules like...background-color: rgba(var(--bs-danger-rgb),var(--bs-bg-opacity))
But I strongly believe that placing the burden on the theme-developer is confusing, adds unnecessary duplication, is error-prone, and bloats the size of the variable collections. I would prefer to enforce all variable definitions as rgb(23,23,23) as most of them don't use transparency anyways.
-color
suffix with-text
to avoid confusion and maintain consistency with variables such as--bs-warning-text-emphasis
or--bs-border-color
.-light
and-dark
with alternative wording. My suggestion is to use terms like-muted
and-invert
.subtle
,(normal)
,emphasis
, should be orthogonal to signals likewarning
,success
, and usagetext
,bg
,border
. I can see how it can be nice for things like defining rules like.alert-danger{}
. I just would have preferred separate variables for default-text
and-bg
colors to clarify that--bs-danger
is never used for text and-emphasize
is actually the default. If there is a--bs-secondary-bg
, shouldn't there be--bs-danger-bg
? I have the feeling that the naming for layout colors (e.g.--bs-secondary-rgb
) collides with levels for signals like--bs-secondary-bg-subtle
.I propose the following mapping:
--bs-primary
--bs-primary-fill
--bs-primary-text-emphasis
--bs-primary-text
--bs-primary-bg-subtle
--bs-primary-bg
--bs-primary-border-subtle
--bs-primary-border
--bs-primary-bg
-table-bg
--bs-body-bg
--bs-bg-body
--bs-secondary-rgb
--bs-bg-secondary
input-fill
,input-border
,input-placeholder
and states likefocused
,required
,disabled
. But after checking the source-code of the Button-example, I noticed that there actually is a variable--bs-btn-disabled-color
and the documentation was just incomplete. A link to the complete list would have helped me.--bs-emphasis-color
shouldn't there be a--bs-subtle-color
? I would found that more intuitive thansecondary
.Proposal (RFC).
For my project, I have created the following mapping. If things go well, I can release the figma-library with the correct mapping for dev export.
Motivation and context
see above.