fix @Vendicated insanities
This commit is contained in:
parent
3fb6b6e2c2
commit
ff61e5ea04
3 changed files with 25 additions and 20 deletions
|
@ -1,11 +1,11 @@
|
||||||
import { ComponentTypes, ThumbnailComponent } from "oceanic.js";
|
import { ComponentTypes, ThumbnailComponent } from "oceanic.js";
|
||||||
|
|
||||||
export type ThumbnailProps = Omit<ThumbnailComponent, "type" | "media"> & { children: ThumbnailComponent["media"]; };
|
export function Thumbnail(props: { src: string }): ThumbnailComponent {
|
||||||
|
return {
|
||||||
export function Thumbnail({ children, ...props }: ThumbnailProps): ThumbnailComponent {
|
type: ComponentTypes.THUMBNAIL,
|
||||||
return {
|
media: {
|
||||||
type: ComponentTypes.THUMBNAIL,
|
url: props.src
|
||||||
media: children,
|
},
|
||||||
...props
|
...props
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,22 @@
|
||||||
|
import { br } from "./br";
|
||||||
|
|
||||||
export const Fragment = Symbol("ComponentsJsx.Fragment");
|
export const Fragment = Symbol("ComponentsJsx.Fragment");
|
||||||
|
|
||||||
type FunctionComponent = (props: any) => any;
|
type FunctionComponent = (props: any) => any;
|
||||||
|
|
||||||
export function createElement(type: typeof Fragment | FunctionComponent, props: any, ...children: any[]) {
|
export function createElement(
|
||||||
if (type === Fragment) {
|
type: typeof Fragment | FunctionComponent,
|
||||||
return children;
|
props: any,
|
||||||
}
|
...children: any[]
|
||||||
|
) {
|
||||||
|
if (type === Fragment) {
|
||||||
|
return children;
|
||||||
|
}
|
||||||
|
|
||||||
props ??= {};
|
props ??= {};
|
||||||
props.children = children;
|
props.children = children;
|
||||||
return type(props);
|
|
||||||
|
// @ts-ignore
|
||||||
|
if (type === "br") return "\n";
|
||||||
|
return type(props);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,11 +8,7 @@ import { User as DiscordUser } from "oceanic.js";
|
||||||
export function User(props: { user: DiscordUser }) {
|
export function User(props: { user: DiscordUser }) {
|
||||||
const { user } = props;
|
const { user } = props;
|
||||||
return (
|
return (
|
||||||
<Section
|
<Section accessory={<Thumbnail src={user.avatarURL("png", 128)} />}>
|
||||||
accessory={
|
|
||||||
<Thumbnail children={{ url: user.avatarURL("png", 128) }} />
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<TextDisplay>### User</TextDisplay>
|
<TextDisplay>### User</TextDisplay>
|
||||||
<TextDisplay>
|
<TextDisplay>
|
||||||
{user.globalName || user.username}
|
{user.globalName || user.username}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue