Skip to content

Commit

Permalink
wip: generate button backend
Browse files Browse the repository at this point in the history
  • Loading branch information
sakuyacatcat committed Mar 23, 2024
1 parent e0668c6 commit 966491c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
27 changes: 27 additions & 0 deletions app/api/frames/createStamp/route.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { Button, createFrames } from 'frames.js/next';

const frames = createFrames({
basePath: '/api/frames/createStamp',
});

const handleRequest = frames(async (ctx) => {
console.log(ctx);

return {
image: (
<div tw="w-full h-full bg-slate-700 text-white justify-center items-center flex flex-col">
<div tw="flex flex-row">hogehoge</div>
</div>
),
imageOptions: {
aspectRatio: '1:1',
},
buttons: [
<Button action="link" target="https://google.com">
{ctx.message?.inputText}
</Button>,
],
};
});

export const POST = handleRequest;
6 changes: 5 additions & 1 deletion app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ export default async function Home({ searchParams }: NextServerPageProps) {
</div>
</FrameImage>
<FrameInput text="Please enter a prompt" />
{!state.generated ? <FrameButton>generate</FrameButton> : null}
{!state.generated ? (
<FrameButton action="post" target="/api/frames/createStamp">
generate
</FrameButton>
) : null}
{state.generated ? <FrameButton>initialize</FrameButton> : null}
{state.generated ? <FrameButton>Mint</FrameButton> : null}
{state.generated ? <FrameButton>Share</FrameButton> : null}
Expand Down

0 comments on commit 966491c

Please sign in to comment.