Skip to content
Open
Changes from all commits
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
28 changes: 13 additions & 15 deletions frontend/web/components/base/forms/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ import React from 'react'
import cn from 'classnames'
import { ButtonHTMLAttributes, HTMLAttributeAnchorTarget } from 'react'
import Icon, { IconName } from 'components/Icon'
import Constants from 'common/constants'

const iconColours = {
primary: '#6837fc',
white: '#ffffff',
} as const

export type IconColour = keyof typeof iconColours

export const themeClassNames = {
danger: 'btn btn-danger',
Expand All @@ -26,8 +32,8 @@ export const sizeClassNames = {

export type ButtonType = ButtonHTMLAttributes<HTMLButtonElement> & {
iconRight?: IconName
iconRightColour?: keyof typeof Constants.colours
iconLeftColour?: keyof typeof Constants.colours
iconRightColour?: IconColour
iconLeftColour?: IconColour
iconLeft?: IconName
href?: string
target?: HTMLAttributeAnchorTarget
Expand Down Expand Up @@ -71,9 +77,7 @@ export const Button = React.forwardRef<
<div className='d-flex h-100 align-items-center justify-content-center gap-2'>
{!!iconLeft && (
<Icon
fill={
iconLeftColour ? Constants.colours[iconLeftColour] : undefined
}
fill={iconLeftColour ? iconColours[iconLeftColour] : undefined}
name={iconLeft}
width={iconSize}
/>
Expand All @@ -82,9 +86,7 @@ export const Button = React.forwardRef<
</div>
{!!iconRight && (
<Icon
fill={
iconRightColour ? Constants.colours[iconRightColour] : undefined
}
fill={iconRightColour ? iconColours[iconRightColour] : undefined}
className='ml-2'
name={iconRight}
width={iconSize}
Expand All @@ -106,9 +108,7 @@ export const Button = React.forwardRef<
>
{!!iconLeft && (
<Icon
fill={
iconLeftColour ? Constants.colours[iconLeftColour] : undefined
}
fill={iconLeftColour ? iconColours[iconLeftColour] : undefined}
className='mr-2'
name={iconLeft}
width={iconSize}
Expand All @@ -117,9 +117,7 @@ export const Button = React.forwardRef<
{children}
{!!iconRight && (
<Icon
fill={
iconRightColour ? Constants.colours[iconRightColour] : undefined
}
fill={iconRightColour ? iconColours[iconRightColour] : undefined}
className='ml-2'
name={iconRight}
width={iconSize}
Expand Down
Loading