add action row component

This commit is contained in:
MapleLeaf
2021-12-27 02:37:15 -06:00
parent 5717d12e1f
commit c56abcaa34
4 changed files with 68 additions and 1 deletions

View File

@@ -0,0 +1,26 @@
import type { ReactNode } from "react"
import React from "react"
import { ReacordElement } from "../../internal/element.js"
import type { MessageOptions } from "../../internal/message"
import { Node } from "../../internal/node.js"
export type ActionRowProps = {
children?: ReactNode
}
export function ActionRow(props: ActionRowProps) {
return (
<ReacordElement props={props} createNode={() => new ActionRowNode(props)}>
{props.children}
</ReacordElement>
)
}
class ActionRowNode extends Node<{}> {
override modifyMessageOptions(options: MessageOptions): void {
options.actionRows.push([])
for (const child of this.children) {
child.modifyMessageOptions(options)
}
}
}