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

Refine outline and inverse button styling for :hover and :focus states #160

Merged
merged 2 commits into from
Mar 21, 2020
Merged
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
43 changes: 23 additions & 20 deletions src/components/Button.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import styled from 'styled-components';
import { darken, rgba } from 'polished';
import { darken, rgba, opacify } from 'polished';
import { color, typography } from './shared/styles';
import { easing } from './shared/animation';

Expand Down Expand Up @@ -215,43 +215,46 @@ const StyledButton = styled.button`
box-shadow: rgba(0, 0, 0, 0.1) 0 0 0 3em inset;
}
&:focus {
box-shadow: ${rgba(color.tertiary, 0.4)} 0 1px 9px 2px;
box-shadow: ${rgba(color.darkest, 0.15)} 0 1px 9px 2px;
}
&:focus:hover {
box-shadow: ${rgba(color.tertiary, 0.2)} 0 8px 18px 0px;
box-shadow: ${rgba(color.darkest, 0.05)} 0 8px 18px 0px;
}
`}
`}

${props =>
props.appearance === APPEARANCES.OUTLINE &&
`
box-shadow: ${color.medium} 0 0 0 1px inset;
box-shadow: ${opacify(0.05, color.border)} 0 0 0 1px inset;
color: ${color.dark};
background: transparent;

${!props.isLoading &&
`
&:hover {
box-shadow: ${color.mediumdark} 0 0 0 1px inset;
box-shadow: ${opacify(0.3, color.border)} 0 0 0 1px inset;
}

&:active {
background: ${color.medium};
box-shadow: ${color.medium} 0 0 0 1px inset;
background: ${opacify(0.05, color.border)};
box-shadow: transparent 0 0 0 1px inset;
color: ${color.darkest};
}

&:active:focus:hover {
${/* This prevents the semi-transparent border from appearing atop the background */ ''}
background: ${opacify(0.05, color.border)};
box-shadow: ${rgba(color.darkest, 0.15)} 0 1px 9px 2px;
}

&:focus {
box-shadow: ${color.medium} 0 0 0 1px inset, ${rgba(
color.secondary,
0.4
)} 0 1px 9px 2px;
box-shadow: ${opacify(0.05, color.border)} 0 0 0 1px inset,
${rgba(color.darkest, 0.15)} 0 1px 9px 2px;
}
&:focus:hover {
box-shadow: ${color.medium} 0 0 0 1px inset, ${rgba(
color.secondary,
0.2
)} 0 8px 18px 0px;
box-shadow: ${opacify(0.05, color.border)} 0 0 0 1px inset,
${rgba(color.darkest, 0.05)} 0 8px 18px 0px;
}
`};
`};
Expand Down Expand Up @@ -321,10 +324,10 @@ const StyledButton = styled.button`
box-shadow: rgba(0, 0, 0, 0.1) 0 0 0 3em inset;
}
&:focus {
box-shadow: ${rgba(color.secondary, 0.4)} 0 1px 9px 2px;
box-shadow: ${rgba(color.primary, 0.4)} 0 1px 9px 2px;
}
&:focus:hover {
box-shadow: ${rgba(color.secondary, 0.2)} 0 8px 18px 0px;
box-shadow: ${rgba(color.primary, 0.2)} 0 8px 18px 0px;
}
`}
`}
Expand Down Expand Up @@ -366,15 +369,15 @@ const StyledButton = styled.button`
&:active {
background: ${color.lightest};
box-shadow: ${color.lightest} 0 0 0 1px inset;
color: ${color.lightest};
color: ${color.darkest};
}
&:focus {
box-shadow: ${color.lightest} 0 0 0 1px inset,
${rgba(color.lightest, 0.4)} 0 1px 9px 2px;
${rgba(color.darkest, 0.4)} 0 1px 9px 2px;
}
&:focus:hover {
box-shadow: ${color.lightest} 0 0 0 1px inset,
${rgba(color.lightest, 0.2)} 0 8px 18px 0px;
${rgba(color.darkest, 0.2)} 0 8px 18px 0px;
}
`};

Expand Down