-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c7a356c
commit 946d98c
Showing
11 changed files
with
208 additions
and
110 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,30 @@ | ||
import "@repo/ui/globals.css"; | ||
import type { Metadata } from "next"; | ||
import { Newsreader } from "next/font/google"; | ||
import Header from "../components/Header"; | ||
import Footer from "../components/Footer"; | ||
|
||
const newsreader = Newsreader({ subsets: ["latin"] }); | ||
|
||
export const metadata: Metadata = { | ||
title: "CouncilHaus", | ||
description: "Democratically allocate a budget across projects", | ||
}; | ||
|
||
export default function RootLayout({ | ||
children, | ||
}: { | ||
children: React.ReactNode; | ||
}): JSX.Element { | ||
return ( | ||
<html lang="en"> | ||
<body className={newsreader.className}> | ||
<div className='flex flex-col min-h-screen'> | ||
<Header /> | ||
<main className='flex-grow px-4 container max-w-3xl mx-auto'>{children}</main> | ||
<Footer /> | ||
</div> | ||
</body> | ||
</html> | ||
); | ||
} |
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,16 @@ | ||
import { Button } from "@repo/ui/components/ui/button"; | ||
import VotingCard from "../components/VotingCard"; | ||
|
||
async function getProjects() { | ||
return ["Project 1", "Project 2", "Project 3", "Project 4"]; | ||
} | ||
|
||
export default async function Page() { | ||
const projects = await getProjects(); | ||
return ( | ||
<main> | ||
<h1 className="text-4xl font-bold mb-4 text-accent">Frontier Guild</h1> | ||
<VotingCard className="max-w-lg mx-auto" projects={projects} maxVotedProjects={3} /> | ||
</main> | ||
); | ||
} |
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,12 @@ | ||
import React from "react"; | ||
import { Button } from "@repo/ui/components/ui/button"; | ||
import Link from "next/link"; | ||
|
||
export default function Footer() { | ||
return <div className="bg-gray-800 py-4"> | ||
<div className="container max-w-4xl mx-auto flex justify-between items-center"> | ||
<p className="text-md text-gray-400">Built with ❤️ by <Button variant="link" className="text-gray-400 px-0 text-lg" asChild><Link href="https://blossom.software" target="_blank">Blossom Labs</Link></Button></p> | ||
<p className="text-md text-gray-400">⚡️ Powered by <Button variant="link" className="text-gray-400 px-0 text-lg" asChild><Link href="https://superfluid.finance" target="_blank">Superfluid</Link></Button></p> | ||
</div> | ||
</div>; | ||
} |
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,11 @@ | ||
import React from "react"; | ||
import { Button } from "@repo/ui/components/ui/button"; | ||
|
||
export default function Header() { | ||
return <div className="bg-gray-900 py-4 mb-6"> | ||
<div className="container max-w-4xl mx-auto flex justify-between items-center"> | ||
<h1 className="text-2xl font-bold text-accent">Council Haus</h1> | ||
<Button>Connect Wallet</Button> | ||
</div> | ||
</div>; | ||
} |
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,79 @@ | ||
'use client'; | ||
|
||
import { Card, CardHeader, CardTitle, CardContent, CardFooter } from '@repo/ui/components/ui/card'; | ||
import { Button } from '@repo/ui/components/ui/button'; | ||
import { Input } from '@repo/ui/components/ui/input'; | ||
import React, { useState } from 'react'; | ||
|
||
const VotingCard = ({ className, projects, maxVotedProjects = 3 }: { className: string, projects: string[], maxVotedProjects?: number }) => { | ||
const [votes, setVotes] = useState<{ [key: string]: number }>( | ||
Object.fromEntries(projects.map(project => [project, 0])) | ||
); | ||
const votedProjects = Object.keys(votes).filter(project => votes[project] ?? 0 > 0); | ||
|
||
const totalVotes = Object.values(votes).reduce((a, b) => a + b, 0); | ||
|
||
const handleVote = (project: string, value: number) => { | ||
const newValue = Math.max(0, value || 0); | ||
setVotes(prev => ({ | ||
...prev, | ||
[project]: newValue | ||
})); | ||
}; | ||
|
||
return ( | ||
<Card className={className}> | ||
<CardHeader> | ||
<CardTitle> | ||
Which project is doing better? | ||
</CardTitle> | ||
</CardHeader> | ||
<CardContent> | ||
{projects.length === 0 ? ( | ||
<div>No projects to vote on</div> | ||
) : ( | ||
<> | ||
<h4 className="text-xl mb-6 text-accent">Cast Your Vote ({votedProjects.length} / {maxVotedProjects})</h4> | ||
{Object.entries(votes).map(([project, voteCount]) => ( | ||
<div key={project} className="flex items-center justify-between mb-3"> | ||
<span className="flex-grow">{project}</span> | ||
<div className="flex items-center"> | ||
<Button | ||
disabled={voteCount <= 0} | ||
onClick={() => handleVote(project, voteCount - 1)} | ||
className="bg-gray-700 w-8 py-1 text-white rounded-r-none" | ||
> | ||
- | ||
</Button> | ||
<Input | ||
type="number" | ||
value={voteCount} | ||
onChange={(e) => handleVote(project, parseInt(e.target.value))} | ||
className="w-16 bg-gray-600 text-center text-white rounded-none px-3 py-1 input-number-hide-arrows border-none" | ||
/> | ||
<Button | ||
disabled={votedProjects.length >= maxVotedProjects && !votes[project as keyof typeof votes]} | ||
onClick={() => handleVote(project, voteCount + 1)} | ||
className="bg-gray-700 w-8 py-1 text-white rounded-l-none" | ||
> | ||
+ | ||
</Button> | ||
<span className="w-12 text-right"> | ||
{totalVotes > 0 ? Math.round((voteCount / totalVotes) * 100) : 0}% | ||
</span> | ||
</div> | ||
</div> | ||
))} | ||
</> | ||
)} | ||
</CardContent> | ||
<CardFooter> | ||
<Button disabled={votedProjects.length < 1} className="w-full py-2 rounded-lg mt-4 font-bold"> | ||
Vote | ||
</Button> | ||
</CardFooter> | ||
</Card> | ||
); | ||
}; | ||
|
||
export default VotingCard; |
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
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,25 @@ | ||
import * as React from "react" | ||
|
||
import { cn } from "@repo/ui/lib/utils" | ||
|
||
export interface InputProps | ||
extends React.InputHTMLAttributes<HTMLInputElement> {} | ||
|
||
const Input = React.forwardRef<HTMLInputElement, InputProps>( | ||
({ className, type, ...props }, ref) => { | ||
return ( | ||
<input | ||
type={type} | ||
className={cn( | ||
"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50", | ||
className | ||
)} | ||
ref={ref} | ||
{...props} | ||
/> | ||
) | ||
} | ||
) | ||
Input.displayName = "Input" | ||
|
||
export { Input } |
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
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