add JSX components v2
This commit is contained in:
parent
b5dd0ed413
commit
4b1227149f
25 changed files with 1080 additions and 3 deletions
21
components-jsx/TextDisplay.tsx
Normal file
21
components-jsx/TextDisplay.tsx
Normal file
|
@ -0,0 +1,21 @@
|
|||
import { ComponentTypes, TextDisplayComponent } from "oceanic.js";
|
||||
|
||||
import { childrenToString } from "./utils";
|
||||
|
||||
export interface TextDisplayProps {
|
||||
children?: any;
|
||||
id?: number;
|
||||
}
|
||||
|
||||
export function TextDisplay({ children, id }: TextDisplayProps): TextDisplayComponent {
|
||||
children = childrenToString("TextDisplay", children);
|
||||
if (!children) {
|
||||
throw new Error("TextDisplay requires at least one child");
|
||||
}
|
||||
|
||||
return {
|
||||
type: ComponentTypes.TEXT_DISPLAY,
|
||||
content: children,
|
||||
id,
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue