flatten file structure and merge some things

This commit is contained in:
MapleLeaf
2021-12-19 21:29:21 -06:00
parent 9828b5c536
commit 634a47641a
14 changed files with 46 additions and 47 deletions

View File

@@ -1,15 +0,0 @@
import type { ColorResolvable } from "discord.js"
import type { ReactNode } from "react"
import React from "react"
import { EmbedInstance } from "../renderer/embed-instance.js"
export type EmbedProps = {
color?: ColorResolvable
children?: ReactNode
}
export function Embed(props: EmbedProps) {
return (
<reacord-element createInstance={() => new EmbedInstance(props.color)} />
)
}

View File

@@ -1,11 +0,0 @@
import type { ReactNode } from "react"
import React from "react"
import { TextElementInstance } from "../renderer/text-element-instance.js"
export type TextProps = {
children?: ReactNode
}
export function Text(props: TextProps) {
return <reacord-element createInstance={() => new TextElementInstance()} />
}

View File

@@ -3,10 +3,24 @@ import type {
MessageEmbedOptions,
MessageOptions,
} from "discord.js"
import type { ReactNode } from "react"
import React from "react"
import { ContainerInstance } from "./container-instance.js"
/** Represents an <Embed /> element */
export class EmbedInstance extends ContainerInstance {
export type EmbedProps = {
color?: ColorResolvable
children?: ReactNode
}
export function Embed(props: EmbedProps) {
return (
<reacord-element createInstance={() => new EmbedInstance(props.color)}>
{props.children}
</reacord-element>
)
}
class EmbedInstance extends ContainerInstance {
readonly name = "Embed"
constructor(readonly color?: ColorResolvable) {

11
packages/reacord/src/jsx.d.ts vendored Normal file
View File

@@ -0,0 +1,11 @@
declare namespace JSX {
import type { ReactNode } from "react"
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
interface IntrinsicElements {
"reacord-element": {
createInstance: () => unknown
children?: ReactNode
}
}
}

View File

@@ -1,3 +1,3 @@
export * from "./components/embed.js"
export * from "./components/text.js"
export * from "./renderer/root.js"
export * from "./embed.js"
export * from "./root.js"
export * from "./text.js"

View File

@@ -1,13 +0,0 @@
export type ReacordElementTag = "reacord-element"
export type ReacordElementProps = {
createInstance: () => unknown
}
declare global {
namespace JSX {
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
interface IntrinsicElements
extends Record<ReacordElementTag, ReacordElementProps> {}
}
}

View File

@@ -1,8 +1,21 @@
import type { MessageOptions } from "discord.js"
import type { ReactNode } from "react"
import React from "react"
import { ContainerInstance } from "./container-instance.js"
/** Represents a <Text /> element */
export class TextElementInstance extends ContainerInstance {
export type TextProps = {
children?: ReactNode
}
export function Text(props: TextProps) {
return (
<reacord-element createInstance={() => new TextElementInstance()}>
{props.children}
</reacord-element>
)
}
class TextElementInstance extends ContainerInstance {
readonly name = "Text"
constructor() {