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

[Design2-111] DSCO - Buttons - Add gray color, add fill to secondary and tertiary types #58636

Merged
merged 8 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions apps/src/componentLibrary/button/Button.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,15 @@ GroupOfColorsOfButtons.args = {
onClick: () => null,
},
{
text: 'Button Secondary Purple',
color: buttonColors.purple,
text: 'Button Secondary Black',
color: buttonColors.black,
type: 'secondary',
size: 'm',
onClick: () => null,
},
{
text: 'Button Secondary Black',
color: buttonColors.black,
text: 'Button Secondary Gray',
color: buttonColors.gray,
type: 'secondary',
size: 'm',
onClick: () => null,
Expand Down Expand Up @@ -165,15 +165,15 @@ GroupOfColorsOfButtons.args = {
},
{
icon: {iconName: 'smile', iconStyle: 'solid'},
color: buttonColors.purple,
color: buttonColors.black,
type: 'secondary',
isIconOnly: true,
size: 'm',
onClick: () => null,
},
{
icon: {iconName: 'smile', iconStyle: 'solid'},
color: buttonColors.black,
color: buttonColors.gray,
type: 'secondary',
isIconOnly: true,
size: 'm',
Expand Down
1 change: 1 addition & 0 deletions apps/src/componentLibrary/button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {ButtonColor} from './types';
export const buttonColors: {[key in ButtonColor]: ButtonColor} = {
purple: 'purple',
black: 'black',
gray: 'gray',
white: 'white',
};

Expand Down
6 changes: 6 additions & 0 deletions apps/src/componentLibrary/button/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

All notable changes to this project will be documented in this file.

## [0.4.0]()

* added background fill color to secondary black and white buttons
* added ```gray``` secondary button
* deprecated ```purple``` secondary button

## [0.3.0](https://github.com/code-dot-org/code-dot-org/pull/58469)

* added support of all `aria-` attributes by `Button` components
Expand Down
12 changes: 6 additions & 6 deletions apps/src/componentLibrary/button/LinkButton.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,15 @@ GroupOfColorsOfLinkButtons.args = {
href: 'https://www.google.com',
},
{
text: 'Button Secondary Purple',
color: buttonColors.purple,
text: 'Button Secondary Black',
color: buttonColors.black,
type: 'secondary',
size: 'm',
href: 'https://www.google.com',
},
{
text: 'Button Secondary Black',
color: buttonColors.black,
text: 'Button Secondary Gray',
color: buttonColors.gray,
type: 'secondary',
size: 'm',
href: 'https://www.google.com',
Expand Down Expand Up @@ -171,15 +171,15 @@ GroupOfColorsOfLinkButtons.args = {
},
{
icon: {iconName: 'smile', iconStyle: 'solid'},
color: buttonColors.purple,
color: buttonColors.black,
type: 'secondary',
isIconOnly: true,
size: 'm',
href: 'https://www.google.com',
},
{
icon: {iconName: 'smile', iconStyle: 'solid'},
color: buttonColors.black,
color: buttonColors.gray,
type: 'secondary',
isIconOnly: true,
size: 'm',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,15 @@ GroupOfColorsOf_BaseButtons.args = {
onClick: () => null,
},
{
text: 'Button Secondary Purple',
color: buttonColors.purple,
text: 'Button Secondary Black',
color: buttonColors.black,
type: 'secondary',
size: 'm',
onClick: () => null,
},
{
text: 'Button Secondary Black',
color: buttonColors.black,
text: 'Button Secondary Gray',
color: buttonColors.gray,
type: 'secondary',
size: 'm',
onClick: () => null,
Expand Down Expand Up @@ -200,15 +200,15 @@ GroupOfColorsOf_BaseButtons.args = {
},
{
icon: {iconName: 'smile', iconStyle: 'solid'},
color: buttonColors.purple,
color: buttonColors.black,
type: 'secondary',
isIconOnly: true,
size: 'm',
onClick: () => null,
},
{
icon: {iconName: 'smile', iconStyle: 'solid'},
color: buttonColors.black,
color: buttonColors.gray,
type: 'secondary',
isIconOnly: true,
size: 'm',
Expand Down
16 changes: 14 additions & 2 deletions apps/src/componentLibrary/button/_baseButton/_BaseButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,19 @@ const checkButtonPropsForErrors = ({
download,
text,
isIconOnly,
color,
type,
}: _BaseButtonProps) => {
if (color === 'gray' && type !== 'secondary') {
throw new Error('Expect type prop to be secondary when color is gray');
}

if (color === 'purple' && type === 'secondary') {
console.warn(
'Warning: Button - Secondary Purple color is now deprecated. Please use different color or type. Secondary purple combination will be removed very soon.'
);
}

if (useAsLink) {
if (!href) {
throw new Error('Expect href prop when useAsLink is true');
Expand Down Expand Up @@ -169,7 +181,6 @@ const BaseButton: React.FunctionComponent<_BaseButtonProps> = ({
disabled = false,
isPending = false,
ariaLabel,

size = 'm',
type = 'primary',
color = 'purple',
Expand Down Expand Up @@ -225,8 +236,9 @@ const BaseButton: React.FunctionComponent<_BaseButtonProps> = ({
download,
text,
isIconOnly,
color,
}),
[type, icon, useAsLink, onClick, href, download, text, isIconOnly]
[type, icon, useAsLink, onClick, href, download, text, isIconOnly, color]
);

/** Handling isPending state content & spinner show logic here.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ a.button-primary {

.button-secondary,
a.button-secondary {
// ! Warning!! Secondary purple button is deprecated and will be removed soon.
&.button-purple {
border: 1px solid $light_secondary_500;
color: $light_secondary_500;
Expand All @@ -129,6 +130,7 @@ a.button-secondary {

&.button-black {
border: 1px solid $light_black;
background-color: $light_white;
color: $light_black;

&:hover {
Expand All @@ -149,8 +151,32 @@ a.button-secondary {
}
}

&.button-gray {
border: 1px solid $light_gray_400;
background-color: $light_white;
color: $light_black;

&:hover {
background-color: $light_gray_100;
border: 1px solid $light_gray_400;
color: $light_black;
}

&:active {
// !important is used here to override the ./apps/style/common.scss line 655 styles
border: 1px solid $light_gray_400 !important;
}

&:disabled, &[aria-disabled="true"] {
border-color: $light_gray_200 !important;
color: $light_gray_200;
background-color: unset;
}
}

&.button-white {
border: 1px solid $light_white;
background-color: $light_black;
color: $light_white;

&:hover {
Expand Down
2 changes: 1 addition & 1 deletion apps/src/componentLibrary/button/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export type ButtonType = 'primary' | 'secondary' | 'tertiary';

export type ButtonColor = 'purple' | 'black' | 'white';
export type ButtonColor = 'purple' | 'black' | 'gray' | 'white';
1 change: 1 addition & 0 deletions shared/css/color.scss
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ $light_gray_50: #F7F8FA;
$light_gray_100: #EAEBEB;
$light_gray_200: #D4D5D7;
$light_gray_300: #BFC1C3;
$light_gray_400: #A9ACAF;
$light_gray_500: #94979B;
$light_gray_700: #6A6E73;
$light_gray_800: #54595E;
Expand Down