Skip to content

Commit

Permalink
Group ai, bot badges under "user" group
Browse files Browse the repository at this point in the history
  • Loading branch information
dancormier committed Nov 7, 2024
1 parent aaab882 commit ed555a5
Show file tree
Hide file tree
Showing 77 changed files with 229 additions and 165 deletions.
37 changes: 16 additions & 21 deletions docs/_data/badges.json
Original file line number Diff line number Diff line change
Expand Up @@ -192,27 +192,6 @@
]
}
],
"ai": [
{
"title": "AI badges",
"class": "s-badge__ai",
"classes": [
{
"title": "AI",
"html": "s-badge s-badge__ai",
"label": "AI",
"description": "AI badge. Can be used to indicate AI generated content."
},
{
"title": "Small",
"class": "s-badge__sm",
"html": "s-badge s-badge__ai s-badge__sm",
"label": "AI",
"description": "Small variant of the AI badge"
}
]
}
],
"users": [
{
"title": "User badges",
Expand Down Expand Up @@ -240,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
62 changes: 6 additions & 56 deletions docs/product/components/badges.html
Original file line number Diff line number Diff line change
Expand Up @@ -360,62 +360,6 @@
</div>
</div>

{% header "h3", "AI badges" %}
<div class="stacks-preview">
{% highlight html %}
<span class="s-badge s-badge__ai">
AI
</span>
<span class="s-badge s-badge__ai s-badge__sm">
AI
</span>
{% endhighlight %}
<div class="stacks-preview--example">
<div class="overflow-x-auto" tabindex="0">
<table class="wmn5 s-table s-table__bx-simple">
<thead>
<tr>
<th scope="col">Example</th>
<th scope="col" class="s-table--cell4">Class</th>
<th scope="col">Description</th>
</tr>
</thead>
<tbody>
{% for badge in badges.ai %}
{% assign types = badge.classes %}
{% for type in types %}
<tr>
<td class="va-middle pr8">
<span class="{{ type.html }}">
{% if type.icon != nil %}
{% icon type.icon %}
{{ type.label }}
{% else %}
{{ type.label }}
{% endif %}
</span>
</td>
<td class="va-middle">
<div class="d-flex g4 fw-wrap">
<code class="stacks-code">.s-badge</code>
{% if type.class != nil %}
<code class="stacks-code">.{{ type.class }}</code>
{% endif %}
{% if badge.class != nil %}
<code class="flex--item stacks-code">.{{ badge.class }}</code>
{% endif %}
</div>
</td>
<td class="va-middle">{{ type.description }}</td>
</tr>
{% endfor %}
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>

{% header "h3", "User badges" %}
<div class="stacks-preview">
{% highlight html %}
Expand All @@ -428,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
19 changes: 1 addition & 18 deletions lib/components/badge/badge.a11y.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ const variants = {
numbers: ["answered", "bounty", "important", "rep", "rep-down", "votes"],
filled: ["danger", "muted"],
states: ["danger", "muted", "info", "new", "warning"],
ai: ["ai"],
users: ["admin", "moderator", "staff"],
users: ["admin", "moderator", "staff", "ai", "bot"],
};

describe("badge", () => {
Expand Down Expand Up @@ -111,22 +110,6 @@ describe("badge", () => {
tag: "span",
});

// AI badges
runA11yTests({
baseClass: "s-badge",
variants: variants.ai,
modifiers: {
primary: ["sm"],
},
children: {
default: "AI",
},
options: {
includeNullVariant: false,
},
tag: "span",
});

// User badges
runA11yTests({
baseClass: "s-badge",
Expand Down
17 changes: 13 additions & 4 deletions lib/components/badge/badge.less
Original file line number Diff line number Diff line change
Expand Up @@ -179,19 +179,28 @@
--_ba-bg: var(--black-050);
--_ba-fc: var(--orange-500);
--_ba-fs: var(--fs-body3);
--_ba-lh: var(--lh-sm);
--_ba-lh: var(--lh-xs);
--_ba-px: var(--su4);
--_ba-py: var(--su2);
--_ba-py: var(--su4);
--_ba-tt: uppercase;

&.s-badge__sm {
--_ba-fs: var(--fs-caption);
--_ba-lh: var(--lh-xs);
--_ba-px: var(--su1);
--_ba-px: var(--su4);
}

&.s-badge__xs {
--_ba-fs: var(--fs-fine);
--_ba-lh: var(--lh-sm);
--_ba-px: 0;
--_ba-py: var(--su2);
}
}

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

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

// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down Expand Up @@ -131,22 +130,6 @@ describe("badge", () => {
template,
});

// AI badges
runVisualTests({
baseClass: "s-badge",
variants: variants.ai,
modifiers: {
primary: ["sm"],
},
children: {
default: "AI",
},
options: {
includeNullVariant: false,
},
tag: "span",
});

// User badges
runVisualTests({
baseClass: "s-badge",
Expand Down
4 changes: 2 additions & 2 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.
4 changes: 2 additions & 2 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.
4 changes: 2 additions & 2 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.
4 changes: 2 additions & 2 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.
4 changes: 2 additions & 2 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
4 changes: 2 additions & 2 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
4 changes: 2 additions & 2 deletions screenshots/Firefox/baseline/s-badge-highcontrast-dark-ai.png
Loading

0 comments on commit ed555a5

Please sign in to comment.