accept children for button label
This commit is contained in:
@@ -8,6 +8,11 @@ export type ButtonSharedProps = {
|
||||
/** The text on the button. Rich formatting (markdown) is not supported here. */
|
||||
label?: ReactNode
|
||||
|
||||
/** The text on the button. Rich formatting (markdown) is not supported here.
|
||||
* If both `label` and `children` are passed, `children` will be ignored.
|
||||
*/
|
||||
children?: ReactNode
|
||||
|
||||
/** When true, the button will be slightly faded, and cannot be clicked. */
|
||||
disabled?: boolean
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { randomUUID } from "node:crypto"
|
||||
import React from "react"
|
||||
import type { Except } from "type-fest"
|
||||
import type { ButtonSharedProps } from "./button-shared-props"
|
||||
import type { ComponentEvent } from "./component-event"
|
||||
import { Node } from "./node"
|
||||
@@ -27,18 +26,18 @@ export type ButtonProps = ButtonSharedProps & {
|
||||
*/
|
||||
export type ButtonClickEvent = ComponentEvent
|
||||
|
||||
export function Button({ label, ...props }: ButtonProps) {
|
||||
export function Button({ label, children, ...props }: ButtonProps) {
|
||||
return (
|
||||
<ReacordElement
|
||||
name="button"
|
||||
createNode={() => new ButtonNode(props)}
|
||||
nodeProps={props}
|
||||
>
|
||||
{label}
|
||||
{label ?? children}
|
||||
</ReacordElement>
|
||||
)
|
||||
}
|
||||
|
||||
export class ButtonNode extends Node<Except<ButtonProps, "label">> {
|
||||
export class ButtonNode extends Node<ButtonProps> {
|
||||
readonly customId = randomUUID()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user