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

[Theme] - Change Primary Buttons colors for Secondary Theme #651

Merged
merged 9 commits into from
Dec 17, 2020
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ const statefulLoader = keyframes`
`;

const primaryLoadingStyles = (theme: ThemeType) => `
background-color: ${theme.COLORS.white};
background-color: ${
theme.__type === 'primary' ? theme.COLORS.white : theme.COLORS.primary
daigof marked this conversation as resolved.
Show resolved Hide resolved
};
`;

const accentLoadingStyles = (buttonColor: ThemeColors) => `
Expand Down
28 changes: 22 additions & 6 deletions src/shared-components/button/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,37 @@ import { textColorsAssociatedWithColors } from './constants';

import { ButtonTypeWithAction } from '.';

const primaryStyles = (buttonColor: ThemeColors, theme: ThemeType) => `
background-color: ${buttonColor};
border-color: ${buttonColor};
color: ${theme.COLORS.white};
fill: ${theme.COLORS.white};
const primaryStyles = (buttonColor: ThemeColors, theme: ThemeType) => {
let backgroundColor = buttonColor;
daigof marked this conversation as resolved.
Show resolved Hide resolved
// If it is not a custom color and the theme is secondary
if (
backgroundColor === theme.COLORS.primary &&
theme.__type === 'secondary'
) {
backgroundColor = theme.COLORS.secondary;
}

const fontColor =
theme.__type === 'primary' ? theme.COLORS.white : theme.COLORS.primary;

return `
background-color: ${backgroundColor};
border-color: ${backgroundColor};
color: ${fontColor};
fill: ${fontColor};

&:visited,
&:hover {
opacity: 0.8;
}

&:focus,
&:not([href]):not([tabindex]):hover,
&:not([href]):not([tabindex]):focus {
color: ${theme.COLORS.white};
color: ${fontColor};
}
`;
};

const secondaryStyles = (
isLoading: boolean,
Expand Down