-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update starter frame with counter + state example
- Loading branch information
1 parent
3875369
commit 7dcf3f5
Showing
5 changed files
with
59 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"framesjs-starter": patch | ||
--- | ||
|
||
feat: update starter frame to use the new api |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { createFrames } from "frames.js/next"; | ||
|
||
export const frames = createFrames({ | ||
basePath: "/frames", | ||
initialState: { totalButtonPresses: 0 }, | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* eslint-disable react/jsx-key */ | ||
import { Button } from "frames.js/next"; | ||
import { frames } from "./frames"; | ||
|
||
const frameHandler = frames(async (ctx) => { | ||
const counter = ctx.message ? ctx.searchParams.op === "+" ? ctx.state.totalButtonPresses + 1 : ctx.state.totalButtonPresses - 1 : ctx.state.totalButtonPresses | ||
|
||
return { | ||
image: <div tw="flex flex-col"> | ||
{ctx.message?.inputText && <div tw="flex"> | ||
{`Input: ${ctx.message.inputText}`} | ||
</div>} | ||
<div tw="flex">Counter {counter}</div></div>, | ||
textInput: "Say something", | ||
buttons: [ | ||
<Button action="post" target={{pathname: "/", query: {op: "+"}}}> | ||
Increment | ||
</Button>, | ||
<Button action="post" target={{pathname: "/", query: {op: "-"}}}> | ||
Decrement | ||
</Button >, | ||
<Button action="link" target={`https://www.google.com`}> | ||
External | ||
</Button> | ||
], | ||
state: { totalButtonPresses: counter} | ||
} | ||
}) | ||
|
||
export const GET = frameHandler; | ||
export const POST = frameHandler; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters