Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
hardingjam committed Sep 30, 2024
1 parent e70031d commit ab638e0
Show file tree
Hide file tree
Showing 29 changed files with 4,559 additions and 4,686 deletions.
121 changes: 56 additions & 65 deletions app/[projectName]/[strategyName]/[deployment]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,82 +1,73 @@
import { fetchMetadata } from "frames.js/next";
import { Metadata } from "next";
import WebappFrame from "@/app/_components/WebappFrame";
import fs from "fs";
import path from "path";
import { fetchMetadata } from 'frames.js/next';
import { Metadata } from 'next';
import WebappFrame from '@/app/_components/WebappFrame';
import fs from 'fs';
import path from 'path';

interface generateMetadataProps {
params: {
projectName: string;
strategyName: string;
deployment: string;
};
params: {
projectName: string;
strategyName: string;
deployment: string;
};
}

export async function generateMetadata({
params,
}: generateMetadataProps): Promise<Metadata> {
// get all dirs in the project name and find the one that ends with the project name
const allDirs = fs.readdirSync(
path.join(process.cwd(), "public", "_strategies", params.projectName)
);
export async function generateMetadata({ params }: generateMetadataProps): Promise<Metadata> {
// get all dirs in the project name and find the one that ends with the project name
const allDirs = fs.readdirSync(
path.join(process.cwd(), 'public', '_strategies', params.projectName)
);

const strategyDir = allDirs.find((dir) => dir.endsWith(params.strategyName));
const strategyDir = allDirs.find((dir) => dir.endsWith(params.strategyName));

if (!strategyDir) {
throw new Error(
`No directory found for strategy: ${params.strategyName} in project: ${params.projectName}`
);
}
return {
other: {
...(await fetchMetadata(
new URL(
`/frames/${params.projectName}/${params.strategyName}/${params.deployment}`,
process.env.VERCEL_URL
? `https://${process.env.VERCEL_URL}`
: "http://localhost:3000"
)
)),
},
};
if (!strategyDir) {
throw new Error(
`No directory found for strategy: ${params.strategyName} in project: ${params.projectName}`
);
}
return {
other: {
...(await fetchMetadata(
new URL(
`/frames/${params.projectName}/${params.strategyName}/${params.deployment}`,
process.env.VERCEL_URL ? `https://${process.env.VERCEL_URL}` : 'http://localhost:3000'
)
))
}
};
}

interface homeProps {
params: {
projectName: string;
strategyName: string;
deployment: string;
};
params: {
projectName: string;
strategyName: string;
deployment: string;
};
}

export default async function Home({ params }: homeProps) {
// get all dirs in the project name and find the one that ends with the project name
const allDirs = fs.readdirSync(
path.join(process.cwd(), "public", "_strategies", params.projectName)
);
// get all dirs in the project name and find the one that ends with the project name
const allDirs = fs.readdirSync(
path.join(process.cwd(), 'public', '_strategies', params.projectName)
);

const strategyDir = allDirs.find((dir) => dir.endsWith(params.strategyName));
const strategyDir = allDirs.find((dir) => dir.endsWith(params.strategyName));

if (!strategyDir) {
throw new Error(
`No directory found for strategy: ${params.strategyName} in project: ${params.projectName}`
);
}
if (!strategyDir) {
throw new Error(
`No directory found for strategy: ${params.strategyName} in project: ${params.projectName}`
);
}

const filePath = path.join(
process.cwd(),
"public",
"_strategies",
params.projectName,
strategyDir,
`${params.strategyName}.rain`
);
const dotrainText = fs.readFileSync(filePath, "utf8");
const filePath = path.join(
process.cwd(),
'public',
'_strategies',
params.projectName,
strategyDir,
`${params.strategyName}.rain`
);
const dotrainText = fs.readFileSync(filePath, 'utf8');

return (
<WebappFrame
dotrainText={dotrainText}
deploymentOption={params.deployment}
/>
);
return <WebappFrame dotrainText={dotrainText} deploymentOption={params.deployment} />;
}
72 changes: 34 additions & 38 deletions app/[projectName]/[strategyName]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,50 +1,46 @@
import { fetchMetadata } from "frames.js/next";
import { Metadata } from "next";
import WebappFrame from "../../_components/WebappFrame";
import fs from "fs";
import path from "path";
import { fetchMetadata } from 'frames.js/next';
import { Metadata } from 'next';
import WebappFrame from '../../_components/WebappFrame';
import fs from 'fs';
import path from 'path';

interface generateMetadataProps {
params: {
projectName: string;
strategyName: string;
};
params: {
projectName: string;
strategyName: string;
};
}

export async function generateMetadata({
params,
}: generateMetadataProps): Promise<Metadata> {
return {
other: {
...(await fetchMetadata(
new URL(
`/frames/${params.projectName}/${params.strategyName}`,
process.env.VERCEL_URL
? `https://${process.env.VERCEL_URL}`
: "http://localhost:3000"
)
)),
},
};
export async function generateMetadata({ params }: generateMetadataProps): Promise<Metadata> {
return {
other: {
...(await fetchMetadata(
new URL(
`/frames/${params.projectName}/${params.strategyName}`,
process.env.VERCEL_URL ? `https://${process.env.VERCEL_URL}` : 'http://localhost:3000'
)
))
}
};
}

interface homeProps {
params: {
projectName: string;
strategyName: string;
};
params: {
projectName: string;
strategyName: string;
};
}

export default async function Home({ params }: homeProps) {
const filePath = path.join(
process.cwd(),
"public",
"_strategies",
params.projectName,
params.strategyName,
`${params.strategyName}.rain`
);
const dotrainText = fs.readFileSync(filePath, "utf8");
const filePath = path.join(
process.cwd(),
'public',
'_strategies',
params.projectName,
params.strategyName,
`${params.strategyName}.rain`
);
const dotrainText = fs.readFileSync(filePath, 'utf8');

return <WebappFrame dotrainText={dotrainText} deploymentOption={null} />;
return <WebappFrame dotrainText={dotrainText} deploymentOption={null} />;
}
36 changes: 24 additions & 12 deletions app/_components/FrameImage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,25 @@ export const FrameImage = ({ currentState }: { currentState: FrameState }) => {
return (
<div
className={`flex flex-col md:justify-center items-center md:text-[50px] text-center text-[30px] relative flex-grow px-8`}
tw={`flex flex-col items-center justify-center h-full w-full text-center`}>
tw={`flex flex-col items-center justify-center h-full w-full text-center`}
>
<div tw="absolute top-0 flex w-full" className="hidden">
<ProgressBar currentState={currentState} />
</div>
{currentState.deploymentOption ? (
<div
className="top-0 md:text-xl text-sm border rounded-full bg-gray-100 px-6 py-3 my-4 md:mb-0"
tw="absolute top-12 text-[30px] border rounded-full bg-gray-100 px-6 py-3">
tw="absolute top-12 text-[30px] border rounded-full bg-gray-100 px-6 py-3"
>
{currentState.deploymentOption.name}
</div>
) : (
''
)}
<div
tw="text-[60px] font-light flex px-28 "
className="font-light md:px-32 max-w-[1200px] w-full flex flex-col justify-center flex-grow">
className="font-light md:px-32 max-w-[1200px] w-full flex flex-col justify-center flex-grow"
>
{currentState.currentStep === 'start' ? (
<div className="flex flex-col gap-y-8" tw="flex flex-col">
<div className="text-1xl">{currentState.strategyName}</div>
Expand Down Expand Up @@ -60,19 +63,22 @@ export const FrameImage = ({ currentState }: { currentState: FrameState }) => {
{currentState.currentStep === 'review' && currentState.deploymentOption ? (
<table
className="min-w-full bg-white text-left text-[20px] lg:text-[25px]"
tw="text-left">
tw="text-left"
>
<tbody tw="flex flex-col text-[40px] w-full">
<tr>
<td
className="p-2 lg:p-3 text-2xl font-bold text-gray-800"
tw="px-4 py-2 text-[50px] font-bold text-gray-800">
tw="px-4 py-2 text-[50px] font-bold text-gray-800"
>
Review choices
</td>
</tr>
<tr className="border-t border-gray-300 table-row py-3" tw="border-t border-gray-300">
<td
className="lg:p-3 p-2 font-regular text-gray-700"
tw="px-4 py-4 font-regular text-gray-700 w-[300px]">
tw="px-4 py-4 font-regular text-gray-700 w-[300px]"
>
Deployment
</td>
<td className="p-4 text-gray-600" tw="px-4 py-2 text-gray-600">
Expand All @@ -89,10 +95,12 @@ export const FrameImage = ({ currentState }: { currentState: FrameState }) => {
<tr
key={binding}
className="border-t border-gray-300 table-row py-3"
tw="border-t border-gray-300">
tw="border-t border-gray-300"
>
<td
className="lg:p-3 p-2 font-regular text-gray-700"
tw="p-4 font-semibold text-gray-700 w-[300px] leading-tight">
tw="p-4 font-semibold text-gray-700 w-[300px] leading-tight"
>
{field.name}
</td>
<td className="px-4 text-gray-600 " tw="px-4 py-2 text-gray-600">
Expand All @@ -104,7 +112,8 @@ export const FrameImage = ({ currentState }: { currentState: FrameState }) => {
<tr className="flex flex-col lg:table-row py-3" tw="border-t border-gray-300">
<td
className="lg:p-3 p-2 text-2xl font-bold text-gray-800"
tw="px-4 py-2 text-[30px] font-bold text-gray-800">
tw="px-4 py-2 text-[30px] font-bold text-gray-800"
>
Deposits
</td>
</tr>
Expand All @@ -113,10 +122,12 @@ export const FrameImage = ({ currentState }: { currentState: FrameState }) => {
<tr
key={tokenInfo.address}
className="border-t border-gray-300 table-row"
tw="border-t border-gray-300">
tw="border-t border-gray-300"
>
<td
className="p-2 lg:p-3 font-regular text-gray-700"
tw="px-4 py-4 font-semibold text-gray-700 w-[300px] leading-tight">
tw="px-4 py-4 font-semibold text-gray-700 w-[300px] leading-tight"
>
{tokenInfo.symbol}
</td>
<td className="px-4 text-gray-600" tw="px-4 py-2 text-gray-600">
Expand All @@ -139,7 +150,8 @@ export const FrameImage = ({ currentState }: { currentState: FrameState }) => {
height="139"
viewBox="0 0 860 139"
fill="none"
xmlns="http://www.w3.org/2000/svg">
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M235.036 84.1922V73.2862L225.688 55.4922H229.583L236.758 70.0062L243.933 55.4922H247.787L238.48 73.2862V84.1922H235.036Z"
fill="#181818"
Expand Down
Loading

0 comments on commit ab638e0

Please sign in to comment.