All files / styles Button.js

90.48% Statements 19/21
62.5% Branches 10/16
83.33% Functions 10/12
100% Lines 17/17

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144        3x                                                                             3x                   3x                 3x                   5x                   3x         5x                             3x                   35x 35x               35x         35x 35x     35x 35x 35x     3x                
import { css } from 'emotion';
import styled from '@appbaseio/vue-emotion';
import { darken, lighten, rgba } from 'polished';
 
const filters = ({ colors: { borderColor } }) => css`
	margin: 0 -3px;
	max-width: 100%;
 
	a {
		margin: 2px 3px;
		padding: 5px 8px;
		font-size: 0.85rem;
		position: relative;
 
		span:first-child {
			max-width: 260px;
			white-space: nowrap;
			overflow: hidden;
			text-overflow: ellipsis;
			margin-right: 26px;
		}
 
		span:last-child {
			display: flex;
			height: 100%;
			top: 0;
			right: 8px;
			position: absolute;
			align-items: center;
			border-left: 1px solid ${borderColor || '#fff'};
			padding-left: 8px;
			margin-left: 8px;
		}
 
		&:hover,
		&:focus {
			span:first-child {
				text-decoration: line-through;
			}
		}
	}
`;
 
const pagination = css`
	margin: 10px -3px;
	max-width: 100%;
	text-align: center;
 
	a {
		margin: 0 3px;
	}
`;
 
const toggleButtons = css`
	margin: 0 -3px;
	max-width: 100%;
 
	a {
		margin: 3px 3px;
	}
`;
 
const numberBoxContainer = css`
	margin: 0 -5px;
	a {
		margin: 5px;
	}
	span {
		margin: 0 5px;
	}
`;
 
const primary = ({ theme }) => css`
	background-color: ${theme.colors.primaryColor};
	color: ${theme.colors.primaryTextColor};
 
	&:hover,
	&:focus {
		background-color: ${darken(0.1, theme.colors.primaryColor)};
	}
`;
 
const large = () => css`
	min-height: 40px;
	padding: 10px 20px;
`;
 
const disabled = ({ theme }) => css`
	background-color: ${theme.colors.backgroundColor
		? lighten(0.1, theme.colors.backgroundColor)
		: '#fafafa'};
	color: #ccc;
	cursor: not-allowed;
 
	&:hover,
	&:focus {
		background-color: ${theme.colors.backgroundColor
		? lighten(0.2, theme.colors.backgroundColor)
		: '#fafafa'};
	}
`;
 
const Button = styled('a')`
	display: inline-flex;
	justify-content: center;
	align-items: center;
	border-radius: 3px;
	border: 1px solid transparent;
	min-height: 30px;
	word-wrap: break-word;
	padding: 5px 12px;
	line-height: 1.2rem;
	background-color: ${({ theme }) => theme.colors.backgroundColor || '#eee'};
	color: ${({ theme }) => theme.colors.textColor};
	cursor: pointer;
	user-select: none;
	transition: all 0.3s ease;
 
	&:hover,
	&:focus {
		background-color: ${({ theme }) =>
		theme.colors.backgroundColor ? darken(0.1, theme.colors.backgroundColor) : '#ccc'};
	}
 
	&:focus {
		outline: 0;
		border-color: ${({ theme }) => rgba(theme.colors.primaryColor, 0.6)};
		box-shadow: ${({ theme }) => `0 0 0 2px ${rgba(theme.colors.primaryColor, 0.3)}`};
	}
 
	${props => (props.primary ? primary : null)};
	${props => (props.disabled ? disabled : null)};
	${props => props.large && large};
`;
 
const loadMoreContainer = css({
	margin: '5px 0',
	display: 'flex',
	justifyContent: 'center',
});
 
export { pagination, filters, toggleButtons, numberBoxContainer, loadMoreContainer };
export default Button;