refactor: rendering button
This commit is contained in:
28
src.new/components/button.tsx
Normal file
28
src.new/components/button.tsx
Normal 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()
|
||||
}
|
||||
}
|
||||
@@ -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 {}
|
||||
Reference in New Issue
Block a user