Skip to content

Commit

Permalink
feat: reset > type
Browse files Browse the repository at this point in the history
  • Loading branch information
jxom committed Feb 8, 2024
1 parent 08d5ea2 commit ee13de2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion example/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ app.frame('/', (context) => {
<Button value="apples">Apples</Button>,
<Button value="oranges">Oranges</Button>,
<Button value="bananas">Bananas</Button>,
status === 'response' && <Button type="reset">Reset</Button>,
status === 'response' && <Button reset>Reset</Button>,
],
}
})
Expand Down
8 changes: 4 additions & 4 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -273,18 +273,18 @@ export class Farc extends Hono {
export type ButtonProps = {
children: string
index?: number | undefined
type?: 'reset'
reset?: true | undefined
value?: string | undefined
}

// TODO: `fc:frame:button:$idx:action` and `fc:frame:button:$idx:target`
Button.__type = 'button'
export function Button({ children, index = 0, type, value }: ButtonProps) {
export function Button({ children, index = 0, reset, value }: ButtonProps) {
return (
<meta
property={`fc:frame:button:${index}`}
content={children}
data-type={type}
data-reset={reset}
data-value={value}
/>
)
Expand Down Expand Up @@ -316,7 +316,7 @@ function getIntentState(
)
const intent = buttonIntents[buttonIndex - 1]
state.buttonValue = intent.props['data-value']
if (intent.props['data-type'] === 'reset') state.reset = true
if (intent.props['data-reset']) state.reset = true
}
return state
}
Expand Down

0 comments on commit ee13de2

Please sign in to comment.