Skip to content

Commit 01c40d3

Browse files
committed
chore: add experimental mods, fix render poll
1 parent 85d2239 commit 01c40d3

File tree

20 files changed

+3159
-3168
lines changed

20 files changed

+3159
-3168
lines changed
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
NEXT_PUBLIC_API_URL="http://localhost:3001/api"
22
NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID=""
33
NEXT_PUBLIC_URL="http://localhost:3000"
4-
NEXT_PUBLIC_HOST="localhost:3000"
4+
NEXT_PUBLIC_HOST="localhost:3000"
5+
NEXT_PUBLIC_EXPERIMENTAL_MODS="false"

examples/nextjs-shadcn/src/app/editor-example.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ import {
1313
} from "@mod-protocol/farcaster";
1414
import { CreationMod, RichEmbed } from "@mod-protocol/react";
1515
import { useEditor, EditorContent } from "@mod-protocol/react-editor";
16-
import { creationMods, defaultRichEmbedMod } from "@mod-protocol/mod-registry";
16+
import {
17+
creationMods,
18+
creationModsExperimental,
19+
defaultRichEmbedMod,
20+
} from "@mod-protocol/mod-registry";
1721
import {
1822
Embed,
1923
EthPersonalSignActionResolverInit,
@@ -201,7 +205,14 @@ export default function EditorExample() {
201205
}}
202206
>
203207
<PopoverTrigger></PopoverTrigger>
204-
<ModsSearch mods={creationMods} onSelect={setCurrentMod} />
208+
<ModsSearch
209+
mods={
210+
process.env.NEXT_PUBLIC_EXPERIMENTAL_MODS === "true"
211+
? creationModsExperimental
212+
: creationMods
213+
}
214+
onSelect={setCurrentMod}
215+
/>
205216
<PopoverContent className="w-[400px] ml-2" align="start">
206217
<div className="space-y-4">
207218
<h4 className="font-medium leading-none">{currentMod?.name}</h4>

examples/nextjs-shadcn/src/app/embeds.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ import {
66
SendEthTransactionActionResolverEvents,
77
SendEthTransactionActionResolverInit,
88
} from "@mod-protocol/core";
9-
import { richEmbedMods, defaultRichEmbedMod } from "@mod-protocol/mod-registry";
9+
import {
10+
richEmbedMods,
11+
defaultRichEmbedMod,
12+
richEmbedModsExperimental,
13+
} from "@mod-protocol/mod-registry";
1014
import { RichEmbed } from "@mod-protocol/react";
1115
import { renderers } from "@mod-protocol/react-ui-shadcn/dist/renderers";
1216
import {
@@ -77,7 +81,11 @@ export function Embeds(props: { embeds: Array<Embed> }) {
7781
key={i}
7882
renderers={renderers}
7983
defaultRichEmbedMod={defaultRichEmbedMod}
80-
mods={richEmbedMods}
84+
mods={
85+
process.env.NEXT_PUBLIC_EXPERIMENTAL_MODS === "true"
86+
? richEmbedModsExperimental
87+
: richEmbedMods
88+
}
8189
resolvers={{
8290
onSendEthTransactionAction,
8391
}}

examples/nextjs-shadcn/src/app/page.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,10 @@ export default function Page() {
7777
</div>
7878
<div className="flex md:flex-row gap-10 flex-col container">
7979
<div className="flex flex-col md:w-1/2">
80-
<h2 className="text-xl">Mod Editor</h2>
80+
<h2 className="text-xl">Creation Mods</h2>
8181
<h3 className="my-2">
8282
An open source library for Farcaster cast creation supporting
83-
Mods
83+
Mods. Try pressing the plus icon
8484
</h3>
8585
<div className="max-w-lg">
8686
<EditorExample />
@@ -100,7 +100,7 @@ export default function Page() {
100100
</div>
101101
</div>
102102
<div className="flex flex-col md:w-1/2">
103-
<h2 className="text-xl">Embed renderers</h2>
103+
<h2 className="text-xl">Rich-embed Mods</h2>
104104
<h3 className="mb-2 mt-2">NFT Mod with native minting</h3>
105105
<Cast cast={dummyCastData[4]} />
106106
<h3 className="mb-2 mt-4">Video Mod</h3>

mods/infura-ipfs-upload/src/manifest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import upload from "./upload";
66

77
const manifest: ModManifest = {
88
slug: "infura-ipfs-upload",
9-
name: "Add image",
9+
name: "Upload image to IPFS",
1010
custodyAddress: "furlong.eth",
1111
logo: "https://i.imgur.com/ptsz1Ig.png",
1212
custodyGithubUsername: "davidfurlong",

mods/livepeer-video/src/manifest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import upload from "./upload";
66

77
const manifest: ModManifest = {
88
slug: "livepeer-video",
9-
name: "Add video",
9+
name: "Upload video",
1010
custodyAddress: "furlong.eth",
1111
logo: "https://i.imgur.com/UeuTxpI.png",
1212
custodyGithubUsername: "davidfurlong",

mods/render-poll/src/loading.ts

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
11
import { ModElement } from "@mod-protocol/core";
22

3-
const loading: ModElement[] = [
4-
{
5-
type: "horizontal-layout",
6-
onload: {
7-
ref: "pollResults",
8-
type: "GET",
9-
url: "{{api}}/render-poll",
10-
searchParams: {
11-
embedUrl: "{{embed}}",
12-
fid: "{{user.farcaster.fid}}",
13-
endDate:
14-
"{{embed.metadata.json-ld.WebPage[0].mod:model.payload.endDate}}",
15-
},
16-
onsuccess: "#results",
17-
onerror: "#error",
18-
onloading: "#loading",
3+
const loading: ModElement = {
4+
type: "horizontal-layout",
5+
onload: {
6+
ref: "pollResults",
7+
type: "GET",
8+
url: "{{api}}/render-poll",
9+
searchParams: {
10+
embedUrl: "{{embed}}",
11+
fid: "{{user.farcaster.fid}}",
12+
endDate:
13+
"{{embed.metadata.json-ld.WebPage[0].mod:model.payload.endDate}}",
1914
},
15+
onsuccess: "#results",
16+
onerror: "#error",
2017
},
21-
];
18+
};
2219

2320
export default loading;

mods/render-poll/src/manifest.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import { ModManifest } from "@mod-protocol/core";
22
import view from "./view";
3-
import loading from "./loading";
43
import error from "./error";
54
import results from "./results";
6-
import vote from "./vote";
75

86
const manifest: ModManifest = {
97
slug: "render-poll",
@@ -16,10 +14,7 @@ const manifest: ModManifest = {
1614
permissions: ["farcaster.messagereply.create", "user.farcaster.fid"],
1715
elements: {
1816
"#error": error,
19-
"#view": view,
20-
"#vote": vote,
2117
"#results": results,
22-
"#loading": loading,
2318
},
2419
};
2520

mods/render-poll/src/view.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import { ModConditionalElement } from "@mod-protocol/core";
2+
import vote from "./vote";
3+
import loading from "./loading";
24

35
const rendering: ModConditionalElement[] = [
46
{
@@ -21,8 +23,8 @@ const rendering: ModConditionalElement[] = [
2123
greaterThan: "{{date.now.iso}}",
2224
},
2325
},
24-
then: "#loading",
25-
else: "#vote",
26+
then: loading,
27+
else: vote,
2628
},
2729
],
2830
},

mods/render-poll/src/vote.ts

Lines changed: 60 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,81 @@
11
import { ModElement } from "@mod-protocol/core";
22

3-
const vote: ModElement[] = [
4-
{
5-
type: "vertical-layout",
6-
elements: [
7-
{
8-
type: "button",
9-
onclick: {
10-
ref: "choice1",
11-
type: "ADDREPLY",
12-
text: "1.",
13-
onsuccess: "#results",
14-
},
15-
label: "Choice 1",
3+
const vote: ModElement = {
4+
type: "vertical-layout",
5+
elements: [
6+
{
7+
type: "text",
8+
label: "{{embed.metadata.json-ld.WebPage[0].mod:model.payload.question}}",
9+
},
10+
{
11+
type: "button",
12+
variant: "secondary",
13+
onclick: {
14+
ref: "choice1",
15+
type: "ADDREPLY",
16+
text: "1.",
17+
onsuccess: "#results",
1618
},
17-
{
18-
type: "button",
19-
onclick: {
20-
ref: "choice1",
21-
type: "ADDREPLY",
22-
text: "2.",
23-
onsuccess: "#results",
19+
label: "{{embed.metadata.json-ld.WebPage[0].mod:model.payload.choice1}}",
20+
},
21+
{
22+
type: "button",
23+
variant: "secondary",
24+
onclick: {
25+
ref: "choice2",
26+
type: "ADDREPLY",
27+
text: "2.",
28+
onsuccess: "#results",
29+
},
30+
label: "{{embed.metadata.json-ld.WebPage[0].mod:model.payload.choice2}}",
31+
},
32+
{
33+
if: {
34+
value:
35+
"{{embed.metadata.json-ld.WebPage[0].mod:model.payload.choice3}}",
36+
match: {
37+
NOT: {
38+
equals: "",
39+
},
2440
},
25-
label: "Choice 2",
2641
},
27-
{
42+
then: {
2843
type: "button",
44+
variant: "secondary",
2945
onclick: {
30-
ref: "choice1",
46+
ref: "choice3",
3147
type: "ADDREPLY",
3248
text: "3.",
3349
onsuccess: "#results",
3450
},
35-
label: "Choice 3 (optional)",
51+
label:
52+
"{{embed.metadata.json-ld.WebPage[0].mod:model.payload.choice3}}",
53+
},
54+
},
55+
{
56+
if: {
57+
value:
58+
"{{embed.metadata.json-ld.WebPage[0].mod:model.payload.choice4}}",
59+
match: {
60+
NOT: {
61+
equals: "",
62+
},
63+
},
3664
},
37-
{
65+
then: {
3866
type: "button",
67+
variant: "secondary",
3968
onclick: {
40-
ref: "choice1",
69+
ref: "choice4",
4170
type: "ADDREPLY",
4271
text: "4.",
4372
onsuccess: "#results",
4473
},
45-
label: "Choice 4 (optional)",
74+
label:
75+
"{{embed.metadata.json-ld.WebPage[0].mod:model.payload.choice4}}",
4676
},
47-
],
48-
},
49-
];
77+
},
78+
],
79+
};
5080

5181
export default vote;

0 commit comments

Comments
 (0)