Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(button): add "featured" variant #1857

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from
  •  
  •  
  •  
62 changes: 62 additions & 0 deletions docs/_data/buttons.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,26 @@
}
]
}
]
,
"featured": [
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went with featured for this variant name.

I figured it's best to avoid coupling naming with visual that could change (purple) and new felt too restrictive since I could see this button being used just to grab some attention generally. featured felt like the best fit but I'm glad to change it if you feel differently @CGuindon.

{
"title": "Featured",
"class": "s-btn__featured",
"classes": [
{
"title": "Clear"
},
{
"title": "Outlined",
"class": "s-btn__outlined"
},
{
"title": "Filled",
"class": "s-btn__filled"
}
]
}
],
"muted": [
{
Expand Down Expand Up @@ -85,6 +105,20 @@
"class": "s-btn__danger",
"class2": "s-btn__filled"
},
{
dancormier marked this conversation as resolved.
Show resolved Hide resolved
"title": "Featured, Clear",
"class": "s-btn__featured"
},
{
"title": "Featured, Outlined",
"class": "s-btn__featured",
"class2": "s-btn__outlined"
},
{
"title": "Featured, Filled",
"class": "s-btn__featured",
"class2": "s-btn__filled"
},
{
"title": "Muted, Clear",
"class": "s-btn__muted"
Expand Down Expand Up @@ -127,6 +161,20 @@
"class": "s-btn__danger",
"class2": "s-btn__filled"
},
{
dancormier marked this conversation as resolved.
Show resolved Hide resolved
"title": "Featured, Clear",
"class": "s-btn__featured"
},
{
"title": "Featured, Outlined",
"class": "s-btn__featured",
"class2": "s-btn__outlined"
},
{
"title": "Featured, Filled",
"class": "s-btn__featured",
"class2": "s-btn__filled"
},
{
"title": "Muted, Clear",
"class": "s-btn__muted"
Expand Down Expand Up @@ -169,6 +217,20 @@
"class": "s-btn__danger",
"class2": "s-btn__filled"
},
{
dancormier marked this conversation as resolved.
Show resolved Hide resolved
"title": "Featured, Clear",
"class": "s-btn__featured"
},
{
"title": "Featured, Outlined",
"class": "s-btn__featured",
"class2": "s-btn__outlined"
},
{
"title": "Featured, Filled",
"class": "s-btn__featured",
"class2": "s-btn__filled"
},
{
"title": "Muted, Clear",
"class": "s-btn__muted"
Expand Down
56 changes: 56 additions & 0 deletions docs/product/components/buttons.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<ol class="stacks-list">
<li><a href="#base">Base</a></li>
<li><a href="#danger">Danger</a></li>
<li><a href="#featured">Featured</a></li>
<li><a href="#muted">Muted</a></li>
</ol>
<p class="stacks-copy">Each style is explained below, detailing how and where to use these styles.</p>
Expand Down Expand Up @@ -119,6 +120,61 @@
</div>
</div>


{% header "h3", "Featured" %}
<!-- TODO add featured button description -->
<p class="stacks-copy">Featured buttons are…</p>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CGuindon Here's where the description for the "featured" buttons would go. Feel free to make a commit or pass a description along to me and I'll plug it in.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't push to Stacks so here you go — let me know what you think. I looked at the other buttons and the color purple description in the color fundamentals:

Featured buttons are a secondary button style, used to visually draw attention to something new or temporary, usually as part of onboarding or to announce a new feature. These should be used sparingly, and permanent placements should be avoided


<div class="stacks-preview">
{% highlight html %}
<button class="s-btn s-btn__featured" type="button">…</button>
<button class="s-btn s-btn__outlined s-btn__featured" type="button">…</button>
<button class="s-btn s-btn__filled s-btn__featured" type="button">…</button>
{% endhighlight %}
<div class="stacks-preview--example">
<div class="overflow-x-auto">
<table class="wmn5 s-table s-table__bx-simple">
<thead>
<tr>
<th scope="col">Type</th>
<th scope="col" class="s-table--cell4">Class</th>
<th scope="col" class="ta-center">Default State</th>
<th scope="col" class="ta-center">Selected State</th>
<th scope="col" class="ta-center">Disabled State</th>
</tr>
</thead>
<tbody>
{% for btn in buttons.featured %}
{% assign types = btn.classes %}
{% for class in types %}
<tr>
<th scope="row" class="va-middle">
{{ class.title }}
</th>
<td class="va-middle">
<div class="d-flex g4 fw-wrap">
<code class="flex--item stacks-code">.s-btn</code>
{% if btn.class != nil %}
<code class="flex--item stacks-code">.{{ btn.class }}</code>
{% endif %}
{% if class.class != nil %}
<code class="flex--item stacks-code">.{{ class.class }}</code>
{% endif %}
</div>
</td>
<td class="va-middle ta-center px4"><button class="ws-nowrap s-btn {{ btn.class }} {{ class.class }}" type="button">Ask question</button></td>
<td class="va-middle ta-center px4"><button class="ws-nowrap s-btn {{ btn.class }} {{ class.class }} is-selected" type="button" aria-pressed="true">Ask question</button></td>
<td class="va-middle ta-center px4"><button class="ws-nowrap s-btn {{ btn.class }} {{ class.class }}" type="button" disabled>Ask question</button></td>
</tr>
{% endfor %}
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</section>

{% header "h3", "Muted" %}
<p class="stacks-copy">Muted buttons are a secondary button style, a grayscale visual treatment. Used in layouts for the least important items or currently inactive actions.</p>

Expand Down
4 changes: 2 additions & 2 deletions lib/components/button/button.a11y.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ describe("button", () => {
/s-btn-(light|dark).*?badge/,
// matches tests with a badge in highcontrast-light modes, excluding filled, danger, github, facebook, sm, or xs
/s-btn-highcontrast-light-(?!.*(filled|danger|github|facebook|sm|xs)).*?badge/,
// matches tests with a badge in highcontrast-light modes, are muted and/or outlined, and are sm or xs
/s-btn-highcontrast-light-(?:muted-outlined-|muted-|outlined-)?(?:sm|xs).*?badge/,
// matches tests with a badge in highcontrast-light modes, are muted or featured and/or outlined, and are sm or xs
giamir marked this conversation as resolved.
Show resolved Hide resolved
/s-btn-highcontrast-light-(?:muted-|featured-)?(?:outlined-)?(?:sm|xs).*?badge/,
],
});
});
36 changes: 34 additions & 2 deletions lib/components/button/button.less
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
.highcontrast-mode({
--_bu-bc: currentColor;
--_bu-outlined-bc: var(--_bu-bc);
--_bu-bc-selected: var(--_bu-bc);
--_bu-fc-selected: var(--white);
--_bu-outlined-fc-selected: var(--white);
--_bu-badge-o: 0.8;
Expand Down Expand Up @@ -236,6 +235,7 @@

// VARIANTS
&&__danger,
&&__featured,
&&__muted {
.highcontrast-mode({
--_bu-filled-bc: transparent;
Expand Down Expand Up @@ -268,6 +268,36 @@
--_bu-number-fc-filled: var(--black);
}

&&__featured {
--_bu-bg-active: var(--purple-300);
--_bu-bg-hover: var(--purple-200);
--_bu-bg-selected: var(--purple-300);
--_bu-fc: var(--purple-500);
--_bu-fc-active: var(--_bu-fc);
--_bu-fc-hover: var(--purple-500);
--_bu-fc-selected: var(--purple-600);
--_bu-filled-bc: transparent;
--_bu-filled-bc-selected: var(--_bu-filled-bc);
--_bu-filled-bg: var(--purple-400);
--_bu-filled-bg-active: var(--purple-500);
--_bu-filled-bg-hover: var(--purple-500);
--_bu-filled-bg-selected: var(--purple-600);
--_bu-filled-fc: var(--white);
--_bu-filled-fc-active: var(--_bu-filled-fc);
--_bu-filled-fc-hover: var(--_bu-filled-fc);
--_bu-filled-fc-selected: var(--_bu-filled-fc);
--_bu-outlined-bc: var(--purple-400);
--_bu-outlined-bc-selected: var(--purple-500);
--_bu-outlined-bg-selected: var(--_bu-bg-selected);
--_bu-outlined-fc-selected: var(--_bu-fc-selected);
--_bu-number-fc: var(--white);
--_bu-number-fc-filled: var(--black);

.highcontrast-mode({
--_bu-filled-bg: var(--purple-500);
});
}

&&__muted {
--_bu-bc-hover: var(--black-300);
--_bu-bg-active: var(--black-150);
Expand Down Expand Up @@ -300,6 +330,7 @@
--_bu-number-fc-focus: var(--black-500);

.highcontrast-mode({
--_bu-bc-hover: currentColor;
--_bu-bg-hover: var(--black-225);
// // The filled modifier on the muted button is deprecated and is to be
// // removed in Stacks Classic v2
Expand All @@ -309,6 +340,7 @@
--_bu-filled-bg-selected: var(--black-500);
--_bu-filled-fc: var(--white);
--_bu-filled-fc-selected: var(--_bu-filled-fc);
--_bu-bc-selected: currentColor;
--_bu-fc-selected: var(--black);
--_bu-number-fc: var(--white);
--_bu-number-fc-filled: var(--black);
Expand Down Expand Up @@ -408,7 +440,7 @@
color: var(--_bu-filled-fc-hover);
}

&:not(.s-btn__outlined) {
&:not(.s-btn__outlined):not(.s-btn__filled) {
border-color: var(--_bu-bc-hover);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/components/button/button.test.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const getChild = (child?: string): string => {
// TODO test disabled states, interaction pseudo-classes
const testArgs: TestVariationArgs = {
baseClass: "s-btn",
variants: ["danger", "muted"],
variants: ["danger", "featured", "muted"],
modifiers: {
primary: ["filled", "outlined"],
secondary: [...["xs", "sm", "md"], ...["dropdown", "icon"]],
Expand Down
3 changes: 3 additions & 0 deletions screenshots/Chromium/baseline/s-btn-dark-featured-badge.ico
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
3 changes: 3 additions & 0 deletions screenshots/Chromium/baseline/s-btn-dark-featured-filled.ico
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
3 changes: 3 additions & 0 deletions screenshots/Chromium/baseline/s-btn-dark-featured-icon.ico
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Loading
Loading