mirror of
https://github.com/tale/headplane.git
synced 2026-08-27 15:37:04 +00:00
fix: call button onPress even without state handler
This commit is contained in:
@@ -4,8 +4,8 @@ import { Button as AriaButton } from 'react-aria-components'
|
|||||||
import { cn } from '~/utils/cn'
|
import { cn } from '~/utils/cn'
|
||||||
|
|
||||||
type ButtonProperties = Parameters<typeof AriaButton>[0] & {
|
type ButtonProperties = Parameters<typeof AriaButton>[0] & {
|
||||||
readonly control?: [boolean, Dispatch<SetStateAction<boolean>>];
|
readonly control?: [boolean, Dispatch<SetStateAction<boolean>>]
|
||||||
readonly variant?: 'heavy' | 'light';
|
readonly variant?: 'heavy' | 'light'
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function Button(properties: ButtonProperties) {
|
export default function Button(properties: ButtonProperties) {
|
||||||
@@ -24,13 +24,14 @@ export default function Button(properties: ButtonProperties) {
|
|||||||
? 'text-white'
|
? 'text-white'
|
||||||
: 'text-ui-700 dark:text-ui-300',
|
: 'text-ui-700 dark:text-ui-300',
|
||||||
properties.isDisabled && 'opacity-50 cursor-not-allowed',
|
properties.isDisabled && 'opacity-50 cursor-not-allowed',
|
||||||
properties.className
|
properties.className,
|
||||||
)}
|
)}
|
||||||
// If control is passed, set the state value
|
// If control is passed, set the state value
|
||||||
onPress={properties.control ? () => {
|
onPress={properties.control
|
||||||
properties.control?.[1](true)
|
? () => {
|
||||||
} : undefined}
|
properties.control?.[1](true)
|
||||||
|
}
|
||||||
|
: properties.onPress}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user