Allow icons in Button component

[MAILPOET-2771]
This commit is contained in:
Ján Mikláš
2020-05-04 13:13:24 +02:00
committed by Veljko V
parent 98e570087e
commit 1a6b95b4b9
2 changed files with 30 additions and 2 deletions

View File

@@ -12,6 +12,7 @@
justify-content: center; justify-content: center;
line-height: 24px; line-height: 24px;
max-width: 100%; max-width: 100%;
min-height: 40px;
padding: 8px 20px; padding: 8px 20px;
position: relative; position: relative;
text-align: center; text-align: center;
@@ -25,8 +26,22 @@
} }
svg { svg {
fill: currentColor;
height: 16px; height: 16px;
width: 16px; width: 16px;
&:first-child {
margin-right: 6px;
}
&:last-child {
margin-left: 6px;
}
&:only-child {
margin-left: 0;
margin-right: 0;
}
} }
&.mailpoet-full-width + .mailpoet-button.mailpoet-full-width { margin-top: $grid-gap; } &.mailpoet-full-width + .mailpoet-button.mailpoet-full-width { margin-top: $grid-gap; }
@@ -36,10 +51,17 @@
.mailpoet-button-small { .mailpoet-button-small {
font-size: $font-size - 2px; font-size: $font-size - 2px;
line-height: 20px; line-height: 20px;
min-height: 32px;
padding: 6px 12px; padding: 6px 12px;
svg {
height: 12px;
width: 12px;
}
} }
.mailpoet-button-large { .mailpoet-button-large {
min-height: 48px;
padding: 12px 24px; padding: 12px 24px;
} }

View File

@@ -2,11 +2,13 @@ import React from 'react';
import classnames from 'classnames'; import classnames from 'classnames';
type Props = { type Props = {
children: React.ReactNode, children?: React.ReactNode,
size?: 'small' | 'large', size?: 'small' | 'large',
variant?: 'light' | 'dark' | 'link' | 'link-dark', variant?: 'light' | 'dark' | 'link' | 'link-dark',
isLoading?: boolean, isLoading?: boolean,
isFullWidth?: boolean, isFullWidth?: boolean,
iconStart?: JSX.Element,
iconEnd?: JSX.Element,
onClick?: () => void, onClick?: () => void,
href?: string, href?: string,
}; };
@@ -17,6 +19,8 @@ const Button = ({
variant, variant,
isLoading, isLoading,
isFullWidth, isFullWidth,
iconStart,
iconEnd,
onClick, onClick,
href, href,
}: Props) => ( }: Props) => (
@@ -35,7 +39,9 @@ const Button = ({
) )
} }
> >
<span>{children}</span> {iconStart}
{children && <span>{children}</span>}
{iconEnd}
</a> </a>
); );