discourse/app
Martin Brennan 6ad9e4ad06
FEATURE: Add CSS class generation for category colors and hashtags (#20951)
This commit adds a system to generate CSS variables and classes for categories
and hashtags, which will be used in an effort to remove baked icons for hashtags
and add color to those icons.

This is in two parts. First I added an initializer generate a category color CSS
variable style tag in the head tag that looks like this:

```css
:root {
--category-1-color: #0088CC;
--category-2-color: #808281;
--category-3-color: #E45735;
--category-4-color: #A461EF;
--category-5-color: #ee56c9;
--category-6-color: #da28c2;
--category-7-color: #ab8b0a;
--category-8-color: #45da37;
...
}
```

The number is the category ID. This only generates CSS variables for categories
the user can access based on `site.categories`. If you need the parent color variable
you can just use the `category.parentCategory.id` to get it.

Then, I added an initializer to generate a hashtag CSS style tag using these variables.
Only the category and channel hashtags need this, the category one generates the
background-gradient needed for the swatch, and the channel just generates a color
for the icon. This is done in an extendable way using the new `api.registerHashtagType`
JS plugin API:

```css
hashtag-color--category-1 {
  background: linear-gradient(90deg, var(--category-1-color) 50%, var(--category-1-color) 50%);
}
hashtag-color--category-2 {
  background: linear-gradient(90deg, var(--category-2-color) 50%, var(--category-2-color) 50%);
}
hashtag-color--category-5 {
  background: linear-gradient(90deg, var(--category-5-color) 50%, var(--category-4-color) 50%);
}
...
.hashtag-color--channel-4 {
  color: var(--category-12-color);
}
.hashtag-color--channel-92 {
  color: var(--category-24-color);
}
```

Note if a category has a parent, its color is used in the gradient correctly. The numbers
here are again IDs (e.g. channel ID, category ID) and the channel’s chatable ID is used
to find the category color variable.
2023-04-05 13:02:35 +10:00
..
assets FEATURE: Add CSS class generation for category colors and hashtags (#20951) 2023-04-05 13:02:35 +10:00
controllers FIX: public sidebar sections belong to system user (#20972) 2023-04-05 10:52:18 +10:00
helpers UX: Improve login required page (#20847) 2023-03-28 07:09:44 -05:00
jobs FEATURE: Move bootstrap mode indicator to header (#20663) 2023-03-24 15:59:03 +02:00
mailers DEV: Replace #pluck_first freedom patch with AR #pick in core (#19893) 2023-02-13 12:39:45 +08:00
models FIX: public sidebar sections belong to system user (#20972) 2023-04-05 10:52:18 +10:00
serializers DEV: Get headline excerpt config from GroupedSearchResult in serializer. (#20942) 2023-04-03 15:02:42 -03:00
services DEV: Remove lazy-yt and replace with lazy-videos (#20722) 2023-03-29 11:54:25 -04:00
views FEATURE: use "Comment" schema type for post replies. (#20932) 2023-04-03 14:36:47 +05:30