diff --git a/package.json b/package.json index 3b7e1f0a6..a74865242 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@openstax/ui-components", - "version": "1.15.4", + "version": "1.16.0-pre2", "license": "MIT", "source": "./src/index.ts", "types": "./dist/index.d.ts", diff --git a/src/components/Button.tsx b/src/components/Button.tsx index dd2c04c8f..569bcc0ab 100644 --- a/src/components/Button.tsx +++ b/src/components/Button.tsx @@ -2,8 +2,9 @@ import styled, {css} from "styled-components"; import theme from '../../src/theme'; import { applyButtonVariantStyles, ButtonVariant } from "../theme/buttons"; -const StyledButton = styled.button<{ variant: ButtonVariant }>` - ${props => applyButtonVariantStyles(props.variant)} +export { applyButtonVariantStyles }; +export const buttonCss = css<{variant?: ButtonVariant}>` + ${props => applyButtonVariantStyles(props.variant || 'primary')} font-size: 1.6rem; line-height: 2rem; @@ -23,13 +24,6 @@ const StyledButton = styled.button<{ variant: ButtonVariant }>` user-select: none; white-space: nowrap; - ${props => props.variant === 'primary' ? ` - &:focus { - outline: solid ${theme.colors.palette.white}; - box-shadow: inset 0 0 0 3px ${theme.colors.palette.black}; - } - `: ''} - &:not([disabled]) { cursor: pointer; } @@ -59,27 +53,31 @@ interface WaitingButtonProps extends ButtonBase { waitingText: string; } -export const Button = (props: ButtonProps | WaitingButtonProps) => { +export const Button = styled((props: ButtonProps | WaitingButtonProps) => { const { disabled, isWaiting, waitingText, children, - variant = 'primary', + variant, ...otherProps } = props; - return {(isWaiting && waitingText) || children} - ; -} + ; +})` + ${buttonCss} +`; -export const LinkButton = ({ variant = 'primary', ...props}: LinkButtonBase) => - {props.children} +export const LinkButton = styled(({ variant, ...props}: LinkButtonBase) => + {props.children} +)` + ${buttonCss} +`; export const linkStyle = css` color: ${theme.colors.link.color}; diff --git a/src/components/__snapshots__/Button.spec.tsx.snap b/src/components/__snapshots__/Button.spec.tsx.snap index 6c6fa7da2..5a5af14b7 100644 --- a/src/components/__snapshots__/Button.spec.tsx.snap +++ b/src/components/__snapshots__/Button.spec.tsx.snap @@ -2,7 +2,7 @@ exports[`Button isWaiting state matches snapshot 1`] = ` @@ -19,7 +19,7 @@ exports[`Button matches light color snapshot 1`] = ` exports[`Button matches snapshot 1`] = ` @@ -27,7 +27,7 @@ exports[`Button matches snapshot 1`] = ` exports[`Button renders as a tag 1`] = ` Click Me @@ -35,7 +35,7 @@ exports[`Button renders as a tag 1`] = ` exports[`Button renders as a tag variant 1`] = ` Click Me @@ -43,7 +43,7 @@ exports[`Button renders as a tag variant 1`] = ` exports[`Button renders button that looks like a link 1`] = ` @@ -51,7 +51,7 @@ exports[`Button renders button that looks like a link 1`] = ` exports[`Button renders plain button 1`] = ` diff --git a/src/components/__snapshots__/DropdownMenu.spec.tsx.snap b/src/components/__snapshots__/DropdownMenu.spec.tsx.snap index 04ed674a8..3882db5ed 100644 --- a/src/components/__snapshots__/DropdownMenu.spec.tsx.snap +++ b/src/components/__snapshots__/DropdownMenu.spec.tsx.snap @@ -5,7 +5,7 @@ exports[`DropdownMenu matches snapshots 1`] = ` @@ -140,7 +140,7 @@ exports[`Modal matches snapshot when heading and children are set 1`] = ` hidden="" />
@@ -159,20 +159,20 @@ exports[`Modal matches snapshot when heading and children are set 1`] = ` />