Skip to content

Commit 98db587

Browse files
authored
Add primary button modifier (#2140)
1 parent 233d9c7 commit 98db587

File tree

5 files changed

+37
-4
lines changed

5 files changed

+37
-4
lines changed

.changeset/clean-peas-suffer.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@cloudfour/patterns': minor
3+
---
4+
5+
Added a new `primary` modifier for buttons when particular visual emphasis is desired.

src/components/button/button.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@
44
@include button.default;
55
}
66

7+
/**
8+
* Modifier: Primary
9+
*/
10+
11+
.c-button--primary {
12+
@include button.primary;
13+
}
14+
715
/**
816
* Modifier: Secondary
917
*/

src/components/button/button.stories.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ The `c-button` class may be applied to button and link elements. The button appe
8181

8282
## Styles
8383

84-
Some buttons may not require as much emphasis as others. The `c-button--secondary` and `c-button--tertiary` modifiers reflect lesser importance with reduced contrast.
84+
The `c-button--primary` modifier may be used when a single call to action requires unique emphasis. The `c-button--secondary` and `c-button--tertiary` modifiers reflect lesser importance with reduced contrast.
8585

8686
<Canvas>
8787
<Story

src/components/button/demo/styles.twig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{% embed '@cloudfour/objects/button-group/button-group.twig' %}
22
{% block content %}
3+
{% include '@cloudfour/components/button/button.twig' with { label: 'Primary', class: 'c-button--primary' } %}
34
{% include '@cloudfour/components/button/button.twig' with { label: 'Default' } %}
45
{% include '@cloudfour/components/button/button.twig' with { label: 'Secondary', class: 'c-button--secondary' } %}
56
{% include '@cloudfour/components/button/button.twig' with { label: 'Tertiary', class: 'c-button--tertiary' } %}

src/mixins/_button.scss

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,26 @@
1616

1717
@include theme.props {
1818
--theme-color-background-button-default: #{color.$brand-primary};
19-
--theme-color-background-button-secondary: transparent;
19+
--theme-color-background-button-primary: #{color.$base-purple};
20+
--theme-color-background-button-secondary: var(--theme-color-background-base);
2021
--theme-color-border-button-default: #{color.$brand-primary-dark};
22+
--theme-color-border-button-primary: #{color.$base-purple-dark};
2123
--theme-color-border-button-secondary: #{color.$brand-primary-light};
24+
--theme-color-text-button-default: #{color.$text-light-emphasis};
25+
--theme-color-text-button-primary: #{color.$text-light-emphasis};
2226
--theme-color-text-button-secondary: var(--theme-color-text-action);
2327
--theme-color-text-button-tertiary: var(--theme-color-text-action);
2428
}
2529

2630
@include theme.props(dark) {
2731
--theme-color-background-button-default: #{color.$brand-primary-dark};
28-
--theme-color-background-button-secondary: transparent;
32+
--theme-color-background-button-primary: #{color.$base-white};
33+
--theme-color-background-button-secondary: var(--theme-color-background-base);
2934
--theme-color-border-button-default: #{color.$brand-primary-darker};
30-
--theme-color-border-button-secondary: #{color.$brand-primary-dark};
35+
--theme-color-border-button-primary: #{color.$brand-primary-darker};
36+
--theme-color-border-button-secondary: #{color.$brand-primary-darker};
37+
--theme-color-text-button-default: #{color.$text-light-emphasis};
38+
--theme-color-text-button-primary: #{color.$brand-primary};
3139
--theme-color-text-button-secondary: var(--theme-color-text-action);
3240
--theme-color-text-button-tertiary: var(--theme-color-text-action);
3341
}
@@ -57,6 +65,7 @@
5765
border-style: solid;
5866
border-width: size.$edge-control;
5967
color: color.$text-light-emphasis;
68+
color: var(--theme-color-text-button-default);
6069
cursor: pointer; /* 2 */
6170
display: inline-flex;
6271
font: inherit; /* 3 */
@@ -143,6 +152,16 @@
143152
}
144153
}
145154

155+
/**
156+
* Modifier: Primary
157+
*/
158+
159+
@mixin primary {
160+
background-color: var(--theme-color-background-button-primary);
161+
border-color: var(--theme-color-border-button-primary);
162+
color: var(--theme-color-text-button-primary);
163+
}
164+
146165
/**
147166
* Modifier: Secondary
148167
*/

0 commit comments

Comments
 (0)