Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
AkiaCode authored Jun 1, 2021
1 parent 02b972b commit 927fd64
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
8 changes: 8 additions & 0 deletions example.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { MessageComponentType, ButtonStyle } from 'https://deno.land/x/harmony@v2.0.0-rc2/mod.ts';
import React from "https://esm.sh/react";
import { Component, Components } from './mod.tsx'

let d = [<Component type={MessageComponentType.Button} style={ButtonStyle.PRIMARY} label="test" customID="asd" options={[{ label: "test", value: "test" }]}/>,
<Component type={MessageComponentType.Button} style={ButtonStyle.PRIMARY} label="test1" customID="asd"/>]

console.log(Components(MessageComponentType.Button, d));
38 changes: 38 additions & 0 deletions mod.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { MessageComponentType, ButtonStyle } from 'https://deno.land/x/harmony@v2.0.0-rc2/mod.ts';
import React, { FunctionComponent } from "https://esm.sh/react";

interface Component {
type: MessageComponentType,
style: ButtonStyle,
label: String,
customID: String,
url?: String,
options?: { label: String, value: String }[]
}

interface Components {
type: MessageComponentType,
components: Component[]
}

export const Component: FunctionComponent<Component> = (props) => {
const { type, style, label, customID, url, options } = props;
return <> {{
type,
style,
label,
customID,
url,
options
}} </>
}

export const Components = (type: MessageComponentType, component: any[]): Components => {
let components: any = [];
component.forEach(r=> components.push(r.props))

return {
type,
components
}
}

0 comments on commit 927fd64

Please sign in to comment.