getting rid of daisy buttons (#969)

* getting rid of daisy buttons so bet button does not turn black on mobile
This commit is contained in:
ingawei 2022-09-30 00:41:22 -05:00 committed by GitHub
parent 13b3613460
commit b83e5db563
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 107 additions and 107 deletions

View File

@ -184,16 +184,14 @@ export function AnswerBetPanel(props: {
<Spacer h={6} /> <Spacer h={6} />
{user ? ( {user ? (
<WarningConfirmationButton <WarningConfirmationButton
size="xl"
marketType="freeResponse" marketType="freeResponse"
amount={betAmount} amount={betAmount}
warning={warning} warning={warning}
onSubmit={submitBet} onSubmit={submitBet}
isSubmitting={isSubmitting} isSubmitting={isSubmitting}
disabled={!!betDisabled} disabled={!!betDisabled}
openModalButtonClass={clsx( color={'indigo'}
'btn self-stretch',
betDisabled ? 'btn-disabled' : 'btn-primary'
)}
/> />
) : ( ) : (
<BetSignUpPrompt /> <BetSignUpPrompt />

View File

@ -85,17 +85,6 @@ export function AnswerResolvePanel(props: {
setIsSubmitting(false) setIsSubmitting(false)
} }
const resolutionButtonClass =
resolveOption === 'CANCEL'
? 'bg-yellow-400 hover:bg-yellow-500'
: resolveOption === 'CHOOSE' && answers.length
? 'btn-primary'
: resolveOption === 'CHOOSE_MULTIPLE' &&
answers.length > 1 &&
answers.every((answer) => chosenAnswers[answer] > 0)
? 'bg-blue-400 hover:bg-blue-500'
: 'btn-disabled'
return ( return (
<Col className="gap-4 rounded"> <Col className="gap-4 rounded">
<Row className="justify-between"> <Row className="justify-between">
@ -129,11 +118,28 @@ export function AnswerResolvePanel(props: {
Clear Clear
</button> </button>
)} )}
<ResolveConfirmationButton <ResolveConfirmationButton
color={
resolveOption === 'CANCEL'
? 'yellow'
: resolveOption === 'CHOOSE' && answers.length
? 'green'
: resolveOption === 'CHOOSE_MULTIPLE' &&
answers.length > 1 &&
answers.every((answer) => chosenAnswers[answer] > 0)
? 'blue'
: 'indigo'
}
disabled={
!resolveOption ||
(resolveOption === 'CHOOSE' && !answers.length) ||
(resolveOption === 'CHOOSE_MULTIPLE' &&
(!(answers.length > 1) ||
!answers.every((answer) => chosenAnswers[answer] > 0)))
}
onResolve={onResolve} onResolve={onResolve}
isSubmitting={isSubmitting} isSubmitting={isSubmitting}
openModalButtonClass={resolutionButtonClass}
submitButtonClass={resolutionButtonClass}
/> />
</Row> </Row>
</Col> </Col>

View File

@ -395,22 +395,16 @@ export function BuyPanel(props: {
<WarningConfirmationButton <WarningConfirmationButton
marketType="binary" marketType="binary"
amount={betAmount} amount={betAmount}
outcome={outcome}
warning={warning} warning={warning}
onSubmit={submitBet} onSubmit={submitBet}
isSubmitting={isSubmitting} isSubmitting={isSubmitting}
openModalButtonClass={clsx( disabled={!!betDisabled || outcome === undefined}
'btn mb-2 flex-1', size="xl"
betDisabled || outcome === undefined color={outcome === 'NO' ? 'red' : 'green'}
? 'btn-disabled bg-greyscale-2'
: outcome === 'NO'
? 'border-none bg-red-400 hover:bg-red-500'
: 'border-none bg-teal-500 hover:bg-teal-600'
)}
/> />
)} )}
<button <button
className="text-greyscale-6 mx-auto select-none text-sm underline xl:hidden" className="text-greyscale-6 mx-auto mt-3 select-none text-sm underline xl:hidden"
onClick={() => setSeeLimit(true)} onClick={() => setSeeLimit(true)}
> >
Advanced Advanced

View File

@ -2,7 +2,6 @@ import Link from 'next/link'
import { keyBy, groupBy, mapValues, sortBy, partition, sumBy } from 'lodash' import { keyBy, groupBy, mapValues, sortBy, partition, sumBy } from 'lodash'
import dayjs from 'dayjs' import dayjs from 'dayjs'
import { useMemo, useState } from 'react' import { useMemo, useState } from 'react'
import clsx from 'clsx'
import { ChevronDownIcon, ChevronUpIcon } from '@heroicons/react/solid' import { ChevronDownIcon, ChevronUpIcon } from '@heroicons/react/solid'
import { Bet } from 'web/lib/firebase/bets' import { Bet } from 'web/lib/firebase/bets'
@ -599,8 +598,8 @@ function SellButton(props: {
return ( return (
<ConfirmationButton <ConfirmationButton
openModalBtn={{ openModalBtn={{
className: clsx('btn-sm', isSubmitting && 'btn-disabled loading'),
label: 'Sell', label: 'Sell',
disabled: isSubmitting,
}} }}
submitBtn={{ className: 'btn-primary', label: 'Sell' }} submitBtn={{ className: 'btn-primary', label: 'Sell' }}
onSubmit={async () => { onSubmit={async () => {

View File

@ -46,21 +46,27 @@ export function Button(props: {
<button <button
type={type} type={type}
className={clsx( className={clsx(
'font-md items-center justify-center rounded-md border border-transparent shadow-sm hover:transition-colors disabled:cursor-not-allowed disabled:opacity-50', className,
'font-md items-center justify-center rounded-md border border-transparent shadow-sm transition-colors disabled:cursor-not-allowed',
sizeClasses, sizeClasses,
color === 'green' && 'btn-primary text-white', color === 'green' &&
color === 'red' && 'bg-red-400 text-white hover:bg-red-500', 'disabled:bg-greyscale-2 bg-teal-500 text-white hover:bg-teal-600',
color === 'yellow' && 'bg-yellow-400 text-white hover:bg-yellow-500', color === 'red' &&
color === 'blue' && 'bg-blue-400 text-white hover:bg-blue-500', 'disabled:bg-greyscale-2 bg-red-400 text-white hover:bg-red-500',
color === 'indigo' && 'bg-indigo-500 text-white hover:bg-indigo-600', color === 'yellow' &&
color === 'gray' && 'bg-gray-50 text-gray-600 hover:bg-gray-200', 'disabled:bg-greyscale-2 bg-yellow-400 text-white hover:bg-yellow-500',
color === 'blue' &&
'disabled:bg-greyscale-2 bg-blue-400 text-white hover:bg-blue-500',
color === 'indigo' &&
'disabled:bg-greyscale-2 bg-indigo-500 text-white hover:bg-indigo-600',
color === 'gray' &&
'bg-greyscale-1 text-greyscale-6 hover:bg-greyscale-2 disabled:opacity-50',
color === 'gradient' && color === 'gradient' &&
'border-none bg-gradient-to-r from-indigo-500 to-blue-500 text-white hover:from-indigo-700 hover:to-blue-700', 'disabled:bg-greyscale-2 border-none bg-gradient-to-r from-indigo-500 to-blue-500 text-white hover:from-indigo-700 hover:to-blue-700',
color === 'gray-white' && color === 'gray-white' &&
'text-greyscale-6 hover:bg-greyscale-2 border-none shadow-none', 'text-greyscale-6 hover:bg-greyscale-2 border-none shadow-none disabled:opacity-50',
color === 'highlight-blue' && color === 'highlight-blue' &&
'text-highlight-blue border-none shadow-none', 'text-highlight-blue disabled:bg-greyscale-2 border-none shadow-none'
className
)} )}
disabled={disabled} disabled={disabled}
onClick={onClick} onClick={onClick}

View File

@ -1,5 +1,6 @@
import clsx from 'clsx' import clsx from 'clsx'
import { ReactNode, useState } from 'react' import { ReactNode, useState } from 'react'
import { Button, ColorType, SizeType } from './button'
import { Col } from './layout/col' import { Col } from './layout/col'
import { Modal } from './layout/modal' import { Modal } from './layout/modal'
import { Row } from './layout/row' import { Row } from './layout/row'
@ -9,6 +10,9 @@ export function ConfirmationButton(props: {
label: string label: string
icon?: JSX.Element icon?: JSX.Element
className?: string className?: string
color?: ColorType
size?: SizeType
disabled?: boolean
} }
cancelBtn?: { cancelBtn?: {
label?: string label?: string
@ -68,13 +72,16 @@ export function ConfirmationButton(props: {
</Row> </Row>
</Col> </Col>
</Modal> </Modal>
<div <Button
className={clsx('btn', openModalBtn.className)} className={clsx(openModalBtn.className)}
onClick={() => updateOpen(true)} onClick={() => updateOpen(true)}
disabled={openModalBtn.disabled}
color={openModalBtn.color}
size={openModalBtn.size}
> >
{openModalBtn.icon} {openModalBtn.icon}
{openModalBtn.label} {openModalBtn.label}
</div> </Button>
</> </>
) )
} }
@ -84,18 +91,25 @@ export function ResolveConfirmationButton(props: {
isSubmitting: boolean isSubmitting: boolean
openModalButtonClass?: string openModalButtonClass?: string
submitButtonClass?: string submitButtonClass?: string
color?: ColorType
disabled?: boolean
}) { }) {
const { onResolve, isSubmitting, openModalButtonClass, submitButtonClass } = const {
props onResolve,
isSubmitting,
openModalButtonClass,
submitButtonClass,
color,
disabled,
} = props
return ( return (
<ConfirmationButton <ConfirmationButton
openModalBtn={{ openModalBtn={{
className: clsx( className: clsx('border-none self-start', openModalButtonClass),
'border-none self-start',
openModalButtonClass,
isSubmitting && 'btn-disabled loading'
),
label: 'Resolve', label: 'Resolve',
color: color,
disabled: isSubmitting || disabled,
size: 'xl',
}} }}
cancelBtn={{ cancelBtn={{
label: 'Back', label: 'Back',

View File

@ -82,11 +82,8 @@ export function CreateGroupButton(props: {
openModalBtn={{ openModalBtn={{
label: label ? label : 'Create Group', label: label ? label : 'Create Group',
icon: icon, icon: icon,
className: clsx( className: className,
isSubmitting ? 'loading btn-disabled' : 'btn-primary', disabled: isSubmitting,
'btn-sm, normal-case',
className
),
}} }}
submitBtn={{ submitBtn={{
label: 'Create', label: 'Create',

View File

@ -128,8 +128,10 @@ export function NumericResolutionPanel(props: {
<ResolveConfirmationButton <ResolveConfirmationButton
onResolve={resolve} onResolve={resolve}
isSubmitting={isSubmitting} isSubmitting={isSubmitting}
openModalButtonClass={clsx('w-full mt-2', submitButtonClass)} openModalButtonClass={clsx('w-full mt-2')}
submitButtonClass={submitButtonClass} submitButtonClass={submitButtonClass}
color={outcomeMode === 'CANCEL' ? 'yellow' : 'indigo'}
disabled={outcomeMode === undefined}
/> />
</Col> </Col>
) )

View File

@ -57,17 +57,6 @@ export function ResolutionPanel(props: {
setIsSubmitting(false) setIsSubmitting(false)
} }
const submitButtonClass =
outcome === 'YES'
? 'btn-primary'
: outcome === 'NO'
? 'bg-red-400 hover:bg-red-500'
: outcome === 'CANCEL'
? 'bg-yellow-400 hover:bg-yellow-500'
: outcome === 'MKT'
? 'bg-blue-400 hover:bg-blue-500'
: 'btn-disabled'
return ( return (
<Col className={clsx('relative rounded-md bg-white px-8 py-6', className)}> <Col className={clsx('relative rounded-md bg-white px-8 py-6', className)}>
{isAdmin && !isCreator && ( {isAdmin && !isCreator && (
@ -76,18 +65,14 @@ export function ResolutionPanel(props: {
</span> </span>
)} )}
<div className="mb-6 whitespace-nowrap text-2xl">Resolve market</div> <div className="mb-6 whitespace-nowrap text-2xl">Resolve market</div>
<div className="mb-3 text-sm text-gray-500">Outcome</div> <div className="mb-3 text-sm text-gray-500">Outcome</div>
<YesNoCancelSelector <YesNoCancelSelector
className="mx-auto my-2" className="mx-auto my-2"
selected={outcome} selected={outcome}
onSelect={setOutcome} onSelect={setOutcome}
btnClassName={isSubmitting ? 'btn-disabled' : ''} btnClassName={isSubmitting ? 'btn-disabled' : ''}
/> />
<Spacer h={4} /> <Spacer h={4} />
<div> <div>
{outcome === 'YES' ? ( {outcome === 'YES' ? (
<> <>
@ -123,16 +108,23 @@ export function ResolutionPanel(props: {
<>Resolving this market will immediately pay out {BETTORS}.</> <>Resolving this market will immediately pay out {BETTORS}.</>
)} )}
</div> </div>
<Spacer h={4} /> <Spacer h={4} />
{!!error && <div className="text-red-500">{error}</div>} {!!error && <div className="text-red-500">{error}</div>}
<ResolveConfirmationButton <ResolveConfirmationButton
color={
outcome === 'YES'
? 'green'
: outcome === 'NO'
? 'red'
: outcome === 'CANCEL'
? 'yellow'
: outcome === 'MKT'
? 'blue'
: 'indigo'
}
disabled={!outcome}
onResolve={resolve} onResolve={resolve}
isSubmitting={isSubmitting} isSubmitting={isSubmitting}
openModalButtonClass={clsx('w-full mt-2', submitButtonClass)}
submitButtonClass={submitButtonClass}
/> />
</Col> </Col>
) )

View File

@ -5,17 +5,18 @@ import { Row } from './layout/row'
import { ConfirmationButton } from './confirmation-button' import { ConfirmationButton } from './confirmation-button'
import { ExclamationIcon } from '@heroicons/react/solid' import { ExclamationIcon } from '@heroicons/react/solid'
import { formatMoney } from 'common/util/format' import { formatMoney } from 'common/util/format'
import { Button, ColorType, SizeType } from './button'
export function WarningConfirmationButton(props: { export function WarningConfirmationButton(props: {
amount: number | undefined amount: number | undefined
outcome?: 'YES' | 'NO' | undefined
marketType: 'freeResponse' | 'binary' marketType: 'freeResponse' | 'binary'
warning?: string warning?: string
onSubmit: () => void onSubmit: () => void
disabled?: boolean disabled: boolean
isSubmitting: boolean isSubmitting: boolean
openModalButtonClass?: string openModalButtonClass?: string
submitButtonClassName?: string color: ColorType
size: SizeType
}) { }) {
const { const {
amount, amount,
@ -24,53 +25,43 @@ export function WarningConfirmationButton(props: {
disabled, disabled,
isSubmitting, isSubmitting,
openModalButtonClass, openModalButtonClass,
submitButtonClassName, size,
outcome, color,
marketType,
} = props } = props
if (!warning) { if (!warning) {
return ( return (
<button <Button
className={clsx( size={size}
openModalButtonClass, disabled={isSubmitting || disabled}
isSubmitting ? 'loading btn-disabled' : '', className={clsx(openModalButtonClass)}
disabled && 'btn-disabled',
marketType === 'binary'
? !outcome
? 'btn-disabled bg-greyscale-2'
: ''
: ''
)}
onClick={onSubmit} onClick={onSubmit}
color={color}
> >
{isSubmitting {isSubmitting
? 'Submitting...' ? 'Submitting...'
: amount : amount
? `Wager ${formatMoney(amount)}` ? `Wager ${formatMoney(amount)}`
: 'Wager'} : 'Wager'}
</button> </Button>
) )
} }
return ( return (
<ConfirmationButton <ConfirmationButton
openModalBtn={{ openModalBtn={{
className: clsx(
openModalButtonClass,
isSubmitting && 'btn-disabled loading'
),
label: amount ? `Wager ${formatMoney(amount)}` : 'Wager', label: amount ? `Wager ${formatMoney(amount)}` : 'Wager',
size: size,
color: 'yellow',
disabled: isSubmitting,
}} }}
cancelBtn={{ cancelBtn={{
label: 'Cancel', label: 'Cancel',
className: 'btn-warning', className: 'btn btn-warning',
}} }}
submitBtn={{ submitBtn={{
label: 'Submit', label: 'Submit',
className: clsx( className: clsx('btn border-none btn-sm btn-ghost self-center'),
'border-none btn-sm btn-ghost self-center',
submitButtonClassName
),
}} }}
onSubmit={onSubmit} onSubmit={onSubmit}
> >

View File

@ -213,7 +213,7 @@ export function NumberCancelSelector(props: {
return ( return (
<Col className={clsx('gap-2', className)}> <Col className={clsx('gap-2', className)}>
<Button <Button
color={selected === 'NUMBER' ? 'green' : 'gray'} color={selected === 'NUMBER' ? 'indigo' : 'gray'}
onClick={() => onSelect('NUMBER')} onClick={() => onSelect('NUMBER')}
className={clsx('whitespace-nowrap', btnClassName)} className={clsx('whitespace-nowrap', btnClassName)}
> >
@ -244,7 +244,7 @@ function Button(props: {
type="button" type="button"
className={clsx( className={clsx(
'inline-flex flex-1 items-center justify-center rounded-md border border-transparent px-8 py-3 font-medium shadow-sm', 'inline-flex flex-1 items-center justify-center rounded-md border border-transparent px-8 py-3 font-medium shadow-sm',
color === 'green' && 'btn-primary text-white', color === 'green' && 'bg-teal-500 bg-teal-600 text-white',
color === 'red' && 'bg-red-400 text-white hover:bg-red-500', color === 'red' && 'bg-red-400 text-white hover:bg-red-500',
color === 'yellow' && 'bg-yellow-400 text-white hover:bg-yellow-500', color === 'yellow' && 'bg-yellow-400 text-white hover:bg-yellow-500',
color === 'blue' && 'bg-blue-400 text-white hover:bg-blue-500', color === 'blue' && 'bg-blue-400 text-white hover:bg-blue-500',

View File

@ -218,9 +218,10 @@ export default function ProfilePage(props: {
/> />
<ConfirmationButton <ConfirmationButton
openModalBtn={{ openModalBtn={{
className: 'btn btn-primary btn-square p-2', className: 'p-2',
label: '', label: '',
icon: <RefreshIcon />, icon: <RefreshIcon className="h-5 w-5" />,
color: 'indigo',
}} }}
submitBtn={{ submitBtn={{
label: 'Update key', label: 'Update key',