Add isIconOnly to Button.jsx
This commit is contained in:
@@ -16,6 +16,8 @@ export const Button = ({
|
|||||||
...rest
|
...rest
|
||||||
}) => {
|
}) => {
|
||||||
const isDisabled = disabled || loading;
|
const isDisabled = disabled || loading;
|
||||||
|
const isIconOnly = (icon || iconRight) && !children;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Component
|
<Component
|
||||||
className={cn(
|
className={cn(
|
||||||
@@ -24,6 +26,7 @@ export const Button = ({
|
|||||||
`btn--${size}`,
|
`btn--${size}`,
|
||||||
full && "btn--full",
|
full && "btn--full",
|
||||||
loading && "is-loading",
|
loading && "is-loading",
|
||||||
|
isIconOnly && "btn--icon-only",
|
||||||
className
|
className
|
||||||
)}
|
)}
|
||||||
disabled={isDisabled}
|
disabled={isDisabled}
|
||||||
@@ -31,7 +34,7 @@ export const Button = ({
|
|||||||
>
|
>
|
||||||
{loading && <span className="btn-spinner" aria-hidden />}
|
{loading && <span className="btn-spinner" aria-hidden />}
|
||||||
{icon && <span className="btn-icon btn-icon--left">{icon}</span>}
|
{icon && <span className="btn-icon btn-icon--left">{icon}</span>}
|
||||||
<span className="btn-label">{children}</span>
|
{children && <span className="btn-label">{children}</span>}
|
||||||
{iconRight && <span className="btn-icon btn-icon--right">{iconRight}</span>}
|
{iconRight && <span className="btn-icon btn-icon--right">{iconRight}</span>}
|
||||||
</Component>
|
</Component>
|
||||||
);
|
);
|
||||||
|
@@ -69,6 +69,20 @@
|
|||||||
--c-text: #ffffff
|
--c-text: #ffffff
|
||||||
background: var(--c-bg)
|
background: var(--c-bg)
|
||||||
border-color: var(--c-border)
|
border-color: var(--c-border)
|
||||||
|
|
||||||
|
&.btn--icon-only
|
||||||
|
padding: 0.75rem
|
||||||
|
aspect-ratio: 1
|
||||||
|
justify-content: center
|
||||||
|
|
||||||
|
&.btn--sm
|
||||||
|
padding: 0.6rem
|
||||||
|
|
||||||
|
&.btn--lg
|
||||||
|
padding: 0.9rem
|
||||||
|
|
||||||
|
.btn-icon
|
||||||
|
margin: 0
|
||||||
|
|
||||||
.btn-icon
|
.btn-icon
|
||||||
display: inline-flex
|
display: inline-flex
|
||||||
|
Reference in New Issue
Block a user