From 1baf8d3b06cf9aec00c94334457bd421a0f9da2b Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Fri, 27 Jan 2023 20:29:32 -0800 Subject: [PATCH] Add support for left and right button accessories --- components/Button/index.tsx | 41 ++++++++++++++++++++++++++---- components/CharacterUnit/index.tsx | 2 +- components/GridRep/index.tsx | 2 +- components/JobImage/index.tsx | 2 +- components/PartyDetails/index.tsx | 6 ++--- components/SummonUnit/index.tsx | 2 +- components/WeaponUnit/index.tsx | 2 +- 7 files changed, 44 insertions(+), 13 deletions(-) diff --git a/components/Button/index.tsx b/components/Button/index.tsx index e87e7ff7..f75b9a48 100644 --- a/components/Button/index.tsx +++ b/components/Button/index.tsx @@ -8,7 +8,10 @@ interface Props React.ButtonHTMLAttributes, HTMLButtonElement > { - accessoryIcon?: React.ReactNode + leftAccessoryIcon?: React.ReactNode + leftAccessoryClassName?: string + rightAccessoryIcon?: React.ReactNode + rightAccessoryClassName?: string active?: boolean blended?: boolean contained?: boolean @@ -24,7 +27,18 @@ const defaultProps = { } const Button = React.forwardRef(function button( - { accessoryIcon, active, blended, contained, buttonSize, text, ...props }, + { + leftAccessoryIcon, + leftAccessoryClassName, + rightAccessoryIcon, + rightAccessoryClassName, + active, + blended, + contained, + buttonSize, + text, + ...props + }, forwardedRef ) { const classes = classNames( @@ -38,8 +52,24 @@ const Button = React.forwardRef(function button( props.className ) - const hasAccessory = () => { - if (accessoryIcon) return {accessoryIcon} + const leftAccessoryClasses = classNames(leftAccessoryClassName, { + Accessory: true, + Left: true, + }) + + const rightAccessoryClasses = classNames(rightAccessoryClassName, { + Accessory: true, + Right: true, + }) + + const hasLeftAccessory = () => { + if (leftAccessoryIcon) + return {leftAccessoryIcon} + } + + const hasRightAccessory = () => { + if (rightAccessoryIcon) + return {rightAccessoryIcon} } const hasText = () => { @@ -48,8 +78,9 @@ const Button = React.forwardRef(function button( return ( ) }) diff --git a/components/CharacterUnit/index.tsx b/components/CharacterUnit/index.tsx index d813b877..6e1b0674 100644 --- a/components/CharacterUnit/index.tsx +++ b/components/CharacterUnit/index.tsx @@ -218,7 +218,7 @@ const CharacterUnit = ({