profileShare

rasmusjy / roundtable

Read-only snapshot

No repository description.

main default branch 181 files Expires Sep 13, 2026, 9:06 AM
decision-starter.tsx 2,493 bytes
1 'use client';
2
3 import { ArrowRight } from 'lucide-react';
4 import { useRouter } from 'next/navigation';
5 import { useState } from 'react';
6 import { Button } from '@/components/ui/button';
7 import { QUESTION_EXAMPLES } from '@/lib/question-examples';
8
9 export function DecisionStarter() {
10 const router = useRouter();
11 const [question, setQuestion] = useState('');
12
13 const submit = () => {
14 const value = question.trim();
15 if (value.length < 3) return;
16 router.push(`/debate?q=${encodeURIComponent(value)}`);
17 };
18
19 return (
20 <div>
21 <form
22 onSubmit={(event) => {
23 event.preventDefault();
24 submit();
25 }}
26 className="rounded-[1.35rem] border bg-card p-2 shadow-xl shadow-primary/10 ring-1 ring-foreground/[0.03]"
27 >
28 <label htmlFor="home-question" className="sr-only">
29 What do you want help deciding?
30 </label>
31 <textarea
32 id="home-question"
33 value={question}
34 onChange={(event) => setQuestion(event.target.value)}
35 rows={3}
36 maxLength={1600}
37 placeholder="What do you want help deciding?"
38 className="block w-full resize-none bg-transparent px-3 py-3 text-base leading-relaxed outline-none placeholder:text-muted-foreground/70"
39 />
40 <div className="flex items-center justify-between gap-3 border-t px-2 pt-2">
41 <span className="hidden text-xs text-muted-foreground sm:block">
42 Add your options, priorities, and limits.
43 </span>
44 <Button
45 type="submit"
46 size="lg"
47 disabled={question.trim().length < 3}
48 className="ml-auto rounded-xl"
49 >
50 Ask the table
51 <ArrowRight className="h-4 w-4" />
52 </Button>
53 </div>
54 </form>
55
56 <div className="mt-4 flex flex-wrap gap-2">
57 <span className="py-1.5 text-xs font-medium text-muted-foreground">Try one:</span>
58 {QUESTION_EXAMPLES.slice(0, 3).map((example) => (
59 <button
60 key={example.short}
61 type="button"
62 onClick={() => setQuestion(example.question)}
63 className="rounded-full border bg-background/70 px-3 py-1.5 text-xs text-muted-foreground transition-colors hover:border-primary/40 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
64 >
65 {example.short}
66 </button>
67 ))}
68 </div>
69 </div>
70 );
71 }
72