@patreon/studio
Version:
Patreon Studio Design System
86 lines (80 loc) • 2.64 kB
JavaScript
// TODO (legacied filenames/match-regex)
// This failure is legacied in and should be updated. DO NOT COPY.
// eslint-disable-next-line filenames/match-regex
import styled, { css } from 'styled-components';
import { tokens } from '../../tokens';
import { mediaForBreakpoint } from '../../utilities/breakpoints';
import { getDimensions, getPadding } from '../Button/theme';
const colors = {
unselected: {
background: tokens.global.primary.muted,
content: tokens.global.primary.onMuted,
},
selected: {
background: tokens.global.primary.actionBase,
content: tokens.global.primary.onActionBase,
},
disabled_unselected: {
background: tokens.global.primary.muted,
content: tokens.global.content.muted,
},
disabled_selected: {
background: tokens.global.primary.actionBase,
content: tokens.global.primary.onActionBase,
},
};
export const StyledPill = styled.button `
display: flex;
justify-content: center;
align-items: center;
gap: 8px;
box-sizing: border-box;
border: none;
border-radius: ${tokens.global.radius.pill};
width: fit-content;
height: ${({ size }) => getDimensions({ size, isMobile: true })};
padding: ${({ size, icon, hasLabel, disclosureIcon }) => getPadding({ size, isMobile: true, hasLabel, icon, disclosureIcon })};
cursor: pointer;
${({ disabled }) => disabled &&
css `
cursor: not-allowed;
opacity: ${tokens.global.opacity.disabled};
`}
@media ${mediaForBreakpoint('sm')} {
height: ${({ size }) => getDimensions({ size, isMobile: false })};
padding: ${({ size, icon, hasLabel, disclosureIcon }) => getPadding({
size,
isMobile: false,
hasLabel,
icon,
disclosureIcon,
})};
}
${({ disabled, selected }) => {
const selectedState = selected ? 'selected' : 'unselected';
const state = disabled ? `disabled_${selectedState}` : selectedState;
const { background, content } = colors[state];
return css `
border-radius: ${tokens.global.radius.sm};
background-color: ${background.default};
color: ${content.default};
svg {
fill: currentColor;
}
${!disabled &&
css `
&:hover {
background-color: ${background.hover};
color: ${content.hover};
border-color: ${tokens.global.border.action.hover};
}
&:active {
background-color: ${background.pressed};
color: ${content.pressed};
border-color: ${tokens.global.border.action.pressed};
}
`}
`;
}}
`;
//# sourceMappingURL=styled-components.js.map