Skip to content

Commit

Permalink
feat(badge): add ai variant (#1853)
Browse files Browse the repository at this point in the history
* feat(badge): add ai variant

[STACKS-686](https://stackoverflow.atlassian.net/browse/STACKS-686)

* fix minor typo

* Group ai, bot badges under "user" group

* Unify AI badge styles with badges
  • Loading branch information
dancormier authored Nov 13, 2024
1 parent dae15d6 commit 5599a51
Show file tree
Hide file tree
Showing 77 changed files with 251 additions and 2 deletions.
16 changes: 16 additions & 0 deletions docs/_data/badges.json
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,22 @@
"label": "Staff",
"labelSm": "Staff",
"description": "Badge indicating user is staff."
},
{
"title": "AI",
"class": "s-badge__ai",
"html": "s-badge s-badge__ai",
"label": "AI",
"labelSm": "AI",
"description": "Badge indicating content is AI generated."
},
{
"title": "Bot",
"class": "s-badge__bot",
"html": "s-badge s-badge__bot",
"label": "Bot",
"labelSm": "Bot",
"description": "Badge indicating user is a bot."
}
]
}
Expand Down
6 changes: 6 additions & 0 deletions docs/product/components/badges.html
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,12 @@
<span class="s-badge s-badge__staff">Staff</span>
<span class="s-badge s-badge__staff s-badge__sm">Staff</span>
<span class="s-badge s-badge__staff s-badge__xs">Staff</span>
<span class="s-badge s-badge__bot">Bot</span>
<span class="s-badge s-badge__bot s-badge__sm">Bot</span>
<span class="s-badge s-badge__bot s-badge__xs">Bot</span>
<span class="s-badge s-badge__ai">AI</span>
<span class="s-badge s-badge__ai s-badge__sm">AI</span>
<span class="s-badge s-badge__ai s-badge__xs">AI</span>
{% endhighlight %}
<div class="stacks-preview--example">
<div class="overflow-x-auto" tabindex="0">
Expand Down
2 changes: 1 addition & 1 deletion lib/components/badge/badge.a11y.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const variants = {
numbers: ["answered", "bounty", "important", "rep", "rep-down", "votes"],
filled: ["danger", "muted"],
states: ["danger", "muted", "info", "new", "warning"],
users: ["admin", "moderator", "staff"],
users: ["admin", "moderator", "staff", "ai", "bot"],
};

describe("badge", () => {
Expand Down
11 changes: 11 additions & 0 deletions lib/components/badge/badge.less
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,17 @@
}

// VARIANTS
&&__ai {
--_ba-bc: var(--_ba-fc);
--_ba-bg: var(--black-050);
--_ba-fc: var(--orange-500);
--_ba-tt: uppercase;
}

&&__bot {
--_ba-bc: var(--black-300);
}

&&__danger,
&&__muted {
&.s-badge__filled {
Expand Down
2 changes: 1 addition & 1 deletion lib/components/badge/badge.visual.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const variants = {
numbers: ["answered", "bounty", "important", "rep", "rep-down", "votes"],
filled: ["danger", "muted"],
states: ["danger", "muted", "info", "new", "warning"],
users: ["admin", "moderator", "staff"],
users: ["admin", "moderator", "staff", "ai", "bot"],
};

// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down
3 changes: 3 additions & 0 deletions screenshots/Chromium/baseline/s-badge-dark-ai-sm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions screenshots/Chromium/baseline/s-badge-dark-ai-xs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions screenshots/Chromium/baseline/s-badge-dark-ai.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions screenshots/Chromium/baseline/s-badge-dark-bot-sm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions screenshots/Chromium/baseline/s-badge-dark-bot-xs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions screenshots/Chromium/baseline/s-badge-dark-bot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions screenshots/Chromium/baseline/s-badge-light-ai-sm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions screenshots/Chromium/baseline/s-badge-light-ai-xs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions screenshots/Chromium/baseline/s-badge-light-ai.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions screenshots/Chromium/baseline/s-badge-light-bot-sm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions screenshots/Chromium/baseline/s-badge-light-bot-xs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions screenshots/Chromium/baseline/s-badge-light-bot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions screenshots/Firefox/baseline/s-badge-dark-ai-sm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions screenshots/Firefox/baseline/s-badge-dark-ai-xs.png
3 changes: 3 additions & 0 deletions screenshots/Firefox/baseline/s-badge-dark-ai.png
3 changes: 3 additions & 0 deletions screenshots/Firefox/baseline/s-badge-dark-bot-sm.png
3 changes: 3 additions & 0 deletions screenshots/Firefox/baseline/s-badge-dark-bot-xs.png
3 changes: 3 additions & 0 deletions screenshots/Firefox/baseline/s-badge-dark-bot.png
3 changes: 3 additions & 0 deletions screenshots/Firefox/baseline/s-badge-highcontrast-dark-ai.png
3 changes: 3 additions & 0 deletions screenshots/Firefox/baseline/s-badge-light-ai-sm.png
3 changes: 3 additions & 0 deletions screenshots/Firefox/baseline/s-badge-light-ai-xs.png
3 changes: 3 additions & 0 deletions screenshots/Firefox/baseline/s-badge-light-ai.png
3 changes: 3 additions & 0 deletions screenshots/Firefox/baseline/s-badge-light-bot-sm.png
3 changes: 3 additions & 0 deletions screenshots/Firefox/baseline/s-badge-light-bot-xs.png
3 changes: 3 additions & 0 deletions screenshots/Firefox/baseline/s-badge-light-bot.png
3 changes: 3 additions & 0 deletions screenshots/Webkit/baseline/s-badge-dark-ai-sm.png
3 changes: 3 additions & 0 deletions screenshots/Webkit/baseline/s-badge-dark-ai-xs.png
3 changes: 3 additions & 0 deletions screenshots/Webkit/baseline/s-badge-dark-ai.png
3 changes: 3 additions & 0 deletions screenshots/Webkit/baseline/s-badge-dark-bot-sm.png
3 changes: 3 additions & 0 deletions screenshots/Webkit/baseline/s-badge-dark-bot-xs.png
3 changes: 3 additions & 0 deletions screenshots/Webkit/baseline/s-badge-dark-bot.png
3 changes: 3 additions & 0 deletions screenshots/Webkit/baseline/s-badge-highcontrast-dark-ai.png
3 changes: 3 additions & 0 deletions screenshots/Webkit/baseline/s-badge-highcontrast-dark-bot.png
3 changes: 3 additions & 0 deletions screenshots/Webkit/baseline/s-badge-highcontrast-light-ai.png
3 changes: 3 additions & 0 deletions screenshots/Webkit/baseline/s-badge-light-ai-sm.png
3 changes: 3 additions & 0 deletions screenshots/Webkit/baseline/s-badge-light-ai-xs.png
3 changes: 3 additions & 0 deletions screenshots/Webkit/baseline/s-badge-light-ai.png
3 changes: 3 additions & 0 deletions screenshots/Webkit/baseline/s-badge-light-bot-sm.png
3 changes: 3 additions & 0 deletions screenshots/Webkit/baseline/s-badge-light-bot-xs.png
3 changes: 3 additions & 0 deletions screenshots/Webkit/baseline/s-badge-light-bot.png

0 comments on commit 5599a51

Please sign in to comment.