当前用户的组的CSS类

|||
-|-|-|
:discourse2: | 摘要 | 为当前用户所属群组添加 CSS 类 将用户所属的群组添加为 <body> 标签上的 CSS 类。
| :eyeglasses: | 预览 | 在 theme-creator.discourse.org 上预览 |
:hammer_and_wrench: | 代码库链接 | \u003chttps://github.com/discourse/discourse-groups-css-classes-in-body\u003e
:open_book: |首次使用 Discourse 主题? | Discourse 主题使用入门指南\n\n[wrap=theme-install-button repoUrl="https://github.com/discourse/discourse-groups-css-classes-in-body\" repoName="Discourse 为当前用户所属群组添加 CSS 类"]\n安装此主题组件\n[/wrap]\n\n\n之前:\n\nimage\n\n之后:\n\nimage\n\n默认情况下,Discourse 只会将当前用户的首要群组添加为 CSS 类。此组件对此进行了更改,以便将当前用户所属的所有群组都添加为类——包括内置的信任级别等。\n\n该组件将每个群组名称转换为 CSS 类,如下所示:\n\nxml\ngroup-NAME\n\n\n安装并激活此主题组件后,您可以像这样向主题添加 CSS 来定位特定群组:\n\nscss\n.group-NAME {\n .some-selector {\n color: red;\n }\n}\n

28 个赞
Does adding groups to CSS theme component still work?
User profile page / CSS class for groups / how to add it to page?
Change Default Username Color
Discourse groups css classes in body
Staff color by default for group members
CSS classes for current groups who can view topic?
Display different content within a topic based on user's groups membership?
Show component only to a specific group via script?
Welcome Link Banner
Versatile Banner
Customized CSS based on user role/groups
Limit Translator use to certain groups only
Discourse Signatures
Adding category description OR text at end of thread
Hide Staff Notices from non-Staff
Disable likes/reaction individual user
MD Composer extras
Hide parts of a post
Hide some preference sub-tabs under the user profile?
Theme - identify the trust level?
Silence status to block ability to use reactions as well
Add a link to user profile in the navigation
Bringing popular features to Discourse: Header search, welcome banner, and category icons / emoji
Finding CSS selectors for page layout, user groups
Finding CSS selectors for page layout, user groups
How can I make a theme that is transparent?
Can I make a theme available to specific user groups only?
Customizing your site with existing theme components
CSS username colors only working for admin/moderators?
How restrict access to button pin/unpin
Copy & Paste Code Button as a Selectable feature per group
Add a specific class to enable targeting Category Moderators
Flagged posts appear to everyone, instead of being hidden for users who aren't logged
Finding all groups of the poster in a topic
Granular group-based permissions for anonymous and logged in users
Hiding GUI elements for new users (less overwhelming)
Group inboxes and archives are visible even when empty
Limit certain reactions to specific trust levels
CSS username colors only working for admin/moderators?
Copy & Paste Code Button as a Selectable feature per group
Add per-user CSS in a plugin?
User Group class not always being applied to post content's wrapper div
Looking to hide Likes & Decorate Op
How to create a theme which only administrators can use?
Versatile Banner
User custom field toggle for sidebar (SFW Mode)
Hide the "Interface" section

这个主题组件是否会更新以反映最近对 user.groups 的弃用?

我在控制台中看到以下警告:

弃用通知:调用 user.groups 已弃用,请改用 user.visibleGroups。它能更准确地反映该组数组所代表的内容,因为并非用户的所有组成员身份都会被序列化到客户端。对于权限检查,请在服务器端检查用户的组,并在 User/CurrentUserSerializer 中添加一个属性,或者为主题设置使用 resolve_group_memberships: true

1 个赞