refactor: rendering button

This commit is contained in:
MapleLeaf
2021-12-25 01:24:52 -06:00
parent e799e71f1a
commit 99430e0edc
9 changed files with 107 additions and 31 deletions

View File

@@ -0,0 +1,28 @@
import type {
EmojiResolvable,
MessageButtonStyle,
MessageComponentInteraction,
} from "discord.js"
import React from "react"
import { Node } from "../node.js"
export type ButtonProps = {
label?: string
style?: Exclude<Lowercase<MessageButtonStyle>, "link">
disabled?: boolean
emoji?: EmojiResolvable
onClick?: (interaction: MessageComponentInteraction) => void
}
export const ButtonTag = "reacord-button"
export function Button(props: ButtonProps) {
return React.createElement(ButtonTag, props)
}
export class ButtonNode extends Node {
readonly name = "button"
constructor(public props: ButtonProps) {
super()
}
}

View File

@@ -1,14 +0,0 @@
import type { ReactNode } from "react"
import React from "react"
export type TextProps = {
children?: ReactNode
}
export const TextTag = "reacord-text"
export function Text(props: TextProps) {
return React.createElement(TextTag, props)
}
export class TextElementNode {}