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

feat(component): add mobileWidth prop to Button #435

Merged
merged 2 commits into from
Aug 21, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 4 additions & 2 deletions packages/big-design/src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement>, Ma
iconOnly?: React.ReactNode;
iconRight?: React.ReactNode;
isLoading?: boolean;
mobileWidth?: 'auto' | '100%';
variant?: 'primary' | 'secondary' | 'subtle';
}

Expand Down Expand Up @@ -57,9 +58,10 @@ export const Button = forwardRef<HTMLButtonElement, ButtonProps>(({ className, s
));

const defaultProps = {
actionType: 'normal' as 'normal',
actionType: 'normal' as const,
isLoading: false,
variant: 'primary' as 'primary',
mobileWidth: '100%' as const,
variant: 'primary' as const,
};

Button.displayName = 'Button';
Expand Down
5 changes: 3 additions & 2 deletions packages/big-design/src/components/Button/styled.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const StyledButton = styled.button<ButtonProps & MarginProps>`
user-select: none;
vertical-align: middle;
white-space: nowrap;
width: 100%;
width: ${({ mobileWidth }) => (mobileWidth === 'auto' ? 'auto' : '100%')};

&:focus {
outline: none;
Expand All @@ -48,7 +48,8 @@ export const StyledButton = styled.button<ButtonProps & MarginProps>`
}

& + .bd-button {
margin-top: ${({ theme }) => theme.spacing.xSmall};
margin-top: ${({ mobileWidth, theme }) => mobileWidth === '100%' && theme.spacing.xSmall};
margin-left: ${({ mobileWidth, theme }) => mobileWidth === 'auto' && theme.spacing.xSmall};

${({ theme }) => theme.breakpoints.tablet} {
margin-top: ${({ theme }) => theme.spacing.none};
Expand Down
6 changes: 6 additions & 0 deletions packages/docs/PropTables/ButtonPropTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ const buttonProps: Prop[] = [
defaultValue: 'false',
description: 'Used to determine if component is in a loading state.',
},
{
name: 'mobileWidth',
types: ['auto', '100%'],
defaultValue: '100%',
description: 'Determines the width in mobile viewport.',
},
{
name: 'variant',
types: ['primary', 'secondary', 'subtle'],
Expand Down