From 91c250f63fa4d87caaeb59a836284a2f57a46f1c Mon Sep 17 00:00:00 2001 From: itsMapleLeaf <19603573+itsMapleLeaf@users.noreply.github.com> Date: Tue, 26 Jul 2022 12:15:48 -0500 Subject: [PATCH] accept children for button label --- packages/reacord/library.new/core/button-shared-props.ts | 5 +++++ packages/reacord/library.new/core/button.tsx | 7 +++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/reacord/library.new/core/button-shared-props.ts b/packages/reacord/library.new/core/button-shared-props.ts index 4218af1..4ba558f 100644 --- a/packages/reacord/library.new/core/button-shared-props.ts +++ b/packages/reacord/library.new/core/button-shared-props.ts @@ -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 diff --git a/packages/reacord/library.new/core/button.tsx b/packages/reacord/library.new/core/button.tsx index 27b5434..bc3957b 100644 --- a/packages/reacord/library.new/core/button.tsx +++ b/packages/reacord/library.new/core/button.tsx @@ -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 ( new ButtonNode(props)} nodeProps={props} > - {label} + {label ?? children} ) } -export class ButtonNode extends Node> { +export class ButtonNode extends Node { readonly customId = randomUUID() }