Skip to content

Commit fd89afd

Browse files
Update button colors (#1365)
* Update background colors * Update TSdoc * Add changeset * Fix format
1 parent 149c818 commit fd89afd

File tree

3 files changed

+38
-22
lines changed

3 files changed

+38
-22
lines changed

.changeset/few-poets-return.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
"@obosbbl/grunnmuren-react": major
3+
---
4+
5+
Changes background colors on buttons. The `green` color prop value is now replaced by `blue`. So upgrading to this version means you have to migrate any `<Button color="green">` to `<Button color="blue">`. You also have to make sure the new colors have sufficent contranst against your backgrounds.
6+
7+
Buttons like these will need a visual check against their backgrounds:
8+
- `<Button>`
9+
- `<Button variant="primary">`
10+
- `<Button color="blue">`
11+
- `<Button color="blue" variant="primary" >`
12+
- `<Button variant="secondary">`
13+
- `<Button color="blue" variant="secondary">`
14+
15+
16+
Since `blue` is the new default for `color`, you *probably* only have <Button> or <Button variant="secondary"> and maybe <Button variant="primary"> in your code base. As the rest of the combinations would be verbose considering the the defaults.

packages/react/src/button/button.stories.tsx

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const meta: Meta<typeof Button> = {
1515
let bgColor = '';
1616

1717
if (props.color === 'mint') {
18-
bgColor = 'bg-green-dark';
18+
bgColor = 'bg-blue-dark';
1919
} else if (props.color === 'white') {
2020
bgColor = 'bg-blue';
2121
}
@@ -37,7 +37,6 @@ type Story = StoryObj<typeof Button>;
3737

3838
export const Primary: Story = {
3939
args: {
40-
color: 'green',
4140
variant: 'primary',
4241
isPending: false,
4342
},
@@ -105,33 +104,33 @@ export const ButtonSandbox = () => {
105104
<Button variant="tertiary">Tertiary</Button>
106105
</div>
107106

108-
<div className="bg-mint-lightest p-8">
107+
<div className="bg-sky-lightest p-8">
109108
<div className="flex gap-8">
110109
<Button>Primary</Button>
111110
<Button variant="secondary">Secondary</Button>
112111
<Button variant="tertiary">Tertiary</Button>
113112
</div>
114113
</div>
115114

116-
<div className="bg-green-dark">
115+
<div className="bg-blue-dark">
117116
<div className="flex gap-8 p-8">
118-
<Button color="mint">Primary</Button>
119-
<Button color="mint" variant="secondary">
117+
<Button color="white">Primary</Button>
118+
<Button color="white" variant="secondary">
120119
Secondary
121120
</Button>
122-
<Button color="mint" variant="tertiary">
121+
<Button color="white" variant="tertiary">
123122
Tertiary
124123
</Button>
125124
</div>
126125
</div>
127126

128-
<div className="bg-blue p-8">
127+
<div className="bg-green-dark p-8">
129128
<div className="flex gap-8">
130-
<Button color="white">Primary</Button>
131-
<Button color="white" variant="secondary">
129+
<Button color="mint">Primary</Button>
130+
<Button color="mint" variant="secondary">
132131
Secondary
133132
</Button>
134-
<Button color="white" variant="tertiary">
133+
<Button color="mint" variant="tertiary">
135134
Tertiary
136135
</Button>
137136
</div>

packages/react/src/button/button.tsx

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,16 @@ const buttonVariants = cva({
2929
variant: {
3030
primary: 'no-underline',
3131
// by using an inset box-shadow to emulate a border instead of an actual border, the button size will be equal regardless of the variant
32-
secondary: 'no-underline shadow-[inset_0_0_0_2px]',
32+
secondary:
33+
'border-2 border-current no-underline hover:border-transparent',
3334
tertiary: 'underline hover:no-underline',
3435
},
3536
/**
3637
* Adjusts the color of the button for usage on different backgrounds.
37-
* @default green
38+
* @default blue
3839
*/
3940
color: {
40-
green: 'focus-visible:outline-focus',
41+
blue: 'focus-visible:outline-focus',
4142
mint: 'focus-visible:outline-focus focus-visible:outline-mint',
4243
white: 'focus-visible:outline-focus focus-visible:outline-white',
4344
},
@@ -54,20 +55,20 @@ const buttonVariants = cva({
5455
},
5556
compoundVariants: [
5657
{
57-
color: 'green',
58+
color: 'blue',
5859
variant: 'primary',
5960
// Darken bg by 20% on hover. The color is manually crafted
6061
className:
61-
'bg-green text-white hover:bg-green-dark active:bg-[#007352] [&_[role="progressbar"]]:text-white',
62+
'bg-blue-dark text-white hover:bg-blue active:bg-[#0536A0] active:text-white [&_[role="progressbar"]]:text-white',
6263
},
6364
{
64-
color: 'green',
65+
color: 'blue',
6566
variant: 'secondary',
6667
className:
67-
'text-black shadow-green hover:bg-green hover:text-white active:bg-green [&:hover_[role="progressbar"]]:text-white [&_[role="progressbar"]]:text-black',
68+
'text-blue-dark hover:border-transparent hover:bg-blue hover:text-blue-dark hover:text-white active:bg-[#0536A0] [&:hover_[role="progressbar"]]:text-white [&_[role="progressbar"]]:text-blue-dark',
6869
},
6970
{
70-
color: 'green',
71+
color: 'blue',
7172
variant: 'tertiary',
7273
className: '[&_[role="progressbar"]]:text-black',
7374
},
@@ -82,7 +83,7 @@ const buttonVariants = cva({
8283
color: 'mint',
8384
variant: 'secondary',
8485
className:
85-
'text-mint shadow-mint hover:bg-mint hover:text-black [&:hover_[role="progressbar"]]:text-black [&_[role="progressbar"]]:text-mint',
86+
'text-mint hover:bg-mint hover:text-black [&:hover_[role="progressbar"]]:text-black [&_[role="progressbar"]]:text-mint',
8687
},
8788
{
8889
color: 'mint',
@@ -99,7 +100,7 @@ const buttonVariants = cva({
99100
color: 'white',
100101
variant: 'secondary',
101102
className:
102-
'text-white shadow-white hover:bg-white hover:text-black [&:hover_[role="progressbar"]]:text-black [&_[role="progressbar"]]:text-white',
103+
'text-white hover:bg-white hover:text-black [&:hover_[role="progressbar"]]:text-black [&_[role="progressbar"]]:text-white',
103104
},
104105
{
105106
color: 'white',
@@ -109,7 +110,7 @@ const buttonVariants = cva({
109110
],
110111
defaultVariants: {
111112
variant: 'primary',
112-
color: 'green',
113+
color: 'blue',
113114
isIconOnly: false,
114115
isPending: false,
115116
},

0 commit comments

Comments
 (0)