From 25fe747f2458f745958f11e95cae5e33d5019339 Mon Sep 17 00:00:00 2001 From: Muhdsodiq Bolarinwa <105107754+Amity808@users.noreply.github.com> Date: Sun, 6 Oct 2024 21:16:40 +0100 Subject: [PATCH] implement AMA Frame --- templates/ama/Inspector.tsx | 87 ------------------------------ templates/ama/cover.jpeg | Bin 4868 -> 0 bytes templates/ama/handlers/index.ts | 7 --- templates/ama/handlers/initial.ts | 27 ---------- templates/ama/handlers/page.ts | 27 ---------- templates/ama/index.ts | 34 ------------ templates/ama/views/Cover.tsx | 34 ------------ templates/ama/views/Page.tsx | 24 --------- 8 files changed, 240 deletions(-) delete mode 100644 templates/ama/Inspector.tsx delete mode 100644 templates/ama/cover.jpeg delete mode 100644 templates/ama/handlers/index.ts delete mode 100644 templates/ama/handlers/initial.ts delete mode 100644 templates/ama/handlers/page.ts delete mode 100644 templates/ama/index.ts delete mode 100644 templates/ama/views/Cover.tsx delete mode 100644 templates/ama/views/Page.tsx diff --git a/templates/ama/Inspector.tsx b/templates/ama/Inspector.tsx deleted file mode 100644 index b51f4560..00000000 --- a/templates/ama/Inspector.tsx +++ /dev/null @@ -1,87 +0,0 @@ -'use client' -import { Button, Input } from '@/sdk/components' -import { useFrameConfig, useFarcasterName, useFarcasterId } from '@/sdk/hooks' -import { Configuration } from '@/sdk/inspector' -import { useRef, useState, useEffect } from 'react' -import type { Config } from '.' - - -export default function Inspector() { - const [config, updateConfig] = useFrameConfig() - const [ques, setQues] = useState('') - const [ans, setAns] = useState("") - - const { text, questions, answers } = config - const username = useFarcasterName(); - const fid = useFarcasterId(); - - const displayLabelInputRef = useRef(null) - - // biome-ignore lint/correctness/useExhaustiveDependencies: - useEffect(() => { - if (!config?.owner) { - updateConfig({ - owner: { - username, - fid - } - }) - } - }, []) - - return ( - - -

{JSON.stringify(config)}

-

Ask Me anything, i'm here to anser your question

- -

Text

- -

{text}

-

Previous Question

-

{questions}

- -
- updateConfig({ questions: e.target.value })} - /> - - -
- -
- updateConfig({ answers: e.target.value })} - /> - -
- - -
-
- ) -} diff --git a/templates/ama/cover.jpeg b/templates/ama/cover.jpeg deleted file mode 100644 index 2bf6acb0d437d1fde608f3815828fb44e9ca6d78..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4868 zcmex=ltFvy>gkB?7SP*_b=RL$R1 z*VLb6@c$5lAO~|7TNg8<5(ASUBeNjm|04{dKxZ { - const roboto = await loadGoogleFontAllVariants('Roboto') - - return { - buttons: [{ label: 'VIEW' }], - fonts: roboto, - component: CoverView(config), - handler: 'page', - } -} diff --git a/templates/ama/handlers/page.ts b/templates/ama/handlers/page.ts deleted file mode 100644 index 68c08ba9..00000000 --- a/templates/ama/handlers/page.ts +++ /dev/null @@ -1,27 +0,0 @@ -'use server' -import type { BuildFrameData } from '@/lib/farcaster' -import type { Config } from '..' -import PageView from '../views/Page' - -export default async function page({ - body, - config, - storage, - params, -}: { - body: FramePayloadValidated - config: Config - storage: Storage - params: any -}): Promise { - return { - buttons: [ - { - label: '←', - }, - ], - aspectRatio: '1:1', - component: PageView(config), - handler: 'initial', - } -} diff --git a/templates/ama/index.ts b/templates/ama/index.ts deleted file mode 100644 index 131034bf..00000000 --- a/templates/ama/index.ts +++ /dev/null @@ -1,34 +0,0 @@ -import type { BaseConfig, BaseStorage, BaseTemplate } from '@/lib/types' -import Inspector from './Inspector' -import cover from './cover.jpeg' -import handlers from './handlers' - - -export interface Config extends BaseConfig { - text: string - owner: { - username: string - fid: number - } | null - questions: string[] - answers: string[] -} - -export interface Storage extends BaseStorage {} - -export default { - name: 'AMA', - description: 'Ask Me Anything', - shortDescription: "I'm here to answer your question", - octicon: 'gear', // https://docs.farcaster.xyz/reference/actions/spec#valid-icons - creatorFid: '0', - creatorName: 'FrameTrain', - cover, - enabled: true, - Inspector, - handlers, - initialConfig: { - text: 'Default Text', - }, - events: [], -} satisfies BaseTemplate diff --git a/templates/ama/views/Cover.tsx b/templates/ama/views/Cover.tsx deleted file mode 100644 index 94d12450..00000000 --- a/templates/ama/views/Cover.tsx +++ /dev/null @@ -1,34 +0,0 @@ -import type { Config } from '..' -import { Input } from '@/sdk/components' - -export default function CoverView(config: Config) { - return ( -
- {}} - /> - Ask Me Anyting -

Question

-

{config.questions}

- -

Answer

-

{config.answers}

-
- ) -} diff --git a/templates/ama/views/Page.tsx b/templates/ama/views/Page.tsx deleted file mode 100644 index 4a53d689..00000000 --- a/templates/ama/views/Page.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import type { Config } from '..' - - -export default function CoverView(config: Config) { - return ( -
- {config.text} - {config.questions} -
- ) -}