mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-09 19:41:32 +00:00
button icon flip prop
This commit is contained in:
1 parent
e057356af0
commit
27a27c1cb8
1 file changed
+11
-2
@@ -17,6 +17,7 @@ interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
||||
square?: boolean;
|
||||
tooltip?: string;
|
||||
full?: boolean;
|
||||
iconFlip?: boolean;
|
||||
}
|
||||
|
||||
export default function Button({
|
||||
@@ -30,11 +31,14 @@ export default function Button({
|
||||
square,
|
||||
tooltip,
|
||||
full = false,
|
||||
iconFlip = false,
|
||||
...rest
|
||||
}: ButtonProps) {
|
||||
let iconMarginClass = !square && label ? (iconFlip ? "ms-2" : "me-2") : "";
|
||||
let IconComponent = icon ? (
|
||||
<FontAwesomeIcon icon={icon} className={!square && label ? "me-2" : ""} />
|
||||
<FontAwesomeIcon icon={icon} className={iconMarginClass} />
|
||||
) : null;
|
||||
|
||||
let LabelComponent = !square ? label : null;
|
||||
|
||||
const externalClass = rest.className || "";
|
||||
@@ -47,7 +51,12 @@ export default function Button({
|
||||
|
||||
delete rest.className;
|
||||
|
||||
const ButtonContent = (
|
||||
const ButtonContent = iconFlip ? (
|
||||
<>
|
||||
{LabelComponent}
|
||||
{IconComponent}
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
{IconComponent}
|
||||
{LabelComponent}
|
||||
|
||||
Reference in new issue
Block a user