Skip to content

Commit 50a89f8

Browse files
committed
fix
1 parent bd1d8e7 commit 50a89f8

File tree

14 files changed

+420
-31
lines changed

14 files changed

+420
-31
lines changed

components/components/SettingsDialog.tsx

Lines changed: 68 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from "react";
1+
import React, {useState} from "react";
22
import {
33
Dialog,
44
DialogClose,
@@ -13,6 +13,7 @@ import { Settings } from "../types";
1313
import { Switch } from "./ui/switch";
1414
import { Label } from "./ui/label";
1515
import { Input } from "./ui/input";
16+
import {RadioGroup, RadioGroupItem} from './ui/radio-group';
1617

1718
interface Props {
1819
settings: Settings;
@@ -21,6 +22,7 @@ interface Props {
2122

2223
function SettingsDialog({ settings, setSettings }: Props) {
2324

25+
const [llm, setLlm] = useState<string>('openai')
2426

2527
return (
2628
<Dialog>
@@ -51,28 +53,48 @@ function SettingsDialog({ settings, setSettings }: Props) {
5153
/>
5254
</div> */}
5355
<div className="flex flex-col space-y-4">
54-
<Label htmlFor="openai-api-key">
55-
<div>OpenAI API key</div>
56-
<div className="font-light mt-2 leading-relaxed">
57-
Only stored in your browser. Never stored on servers. Overrides
58-
your .env config.
59-
</div>
60-
</Label>
61-
62-
<Input
63-
id="openai-api-key"
64-
placeholder="OpenAI API key"
65-
value={settings?.openAiApiKey || ""}
66-
onChange={(e) =>
56+
<div className="border-b-2 border-black pb-4">
57+
<RadioGroup onValueChange={(data) => {
58+
setLlm(data);
6759
setSettings({
6860
...settings,
69-
openAiApiKey: e.target.value,
61+
llm: data,
7062
})
71-
}
72-
/>
63+
console.log(data)
64+
}} className="flex item-center" color="indigo" defaultValue={settings.llm}>
65+
<Label className="flex item-center" htmlFor="openai-llm">
66+
<span className="mr-2">openai</span>
67+
<RadioGroupItem value="openai" id="openai-llm"/>
68+
</Label>
69+
<Label className="flex item-center" htmlFor="gemini-llm">
70+
<span className="mr-2">gemini</span>
71+
<RadioGroupItem value="gemini" id="gemini-llm"/>
72+
</Label>
73+
</RadioGroup>
74+
</div>
75+
{
76+
settings.llm === 'openai' ? (
77+
<>
78+
<Label htmlFor="openai-api-key">
79+
<div>OpenAI API key</div>
80+
<div className="font-light mt-2 leading-relaxed">
81+
Only stored in your browser. Never stored on servers. Overrides
82+
your .env config.
83+
</div>
84+
</Label>
85+
86+
<Input
87+
id="openai-api-key"
88+
placeholder="OpenAI API key"
89+
value={settings?.openAiApiKey || ""}
90+
onChange={(e) =>
91+
setSettings({
92+
...settings,
93+
openAiApiKey: e.target.value,
94+
})
95+
}
96+
/>
7397

74-
{(
75-
<>
7698
<Label htmlFor="openai-api-key">
7799
<div>OpenAI Base URL (optional)</div>
78100
<div className="font-light mt-2 leading-relaxed">
@@ -91,8 +113,33 @@ function SettingsDialog({ settings, setSettings }: Props) {
91113
})
92114
}
93115
/>
94-
</>
95-
)}
116+
</>
117+
118+
) : (
119+
<>
120+
<Label htmlFor="openai-api-key">
121+
<div>Gemini API key</div>
122+
<div className="font-light mt-2 leading-relaxed">
123+
Only stored in your browser. Never stored on servers. Overrides
124+
your .env config.
125+
</div>
126+
</Label>
127+
128+
<Input
129+
id="Gemini-api-key"
130+
placeholder="Gemini API key"
131+
value={settings?.geminiApiKey || ""}
132+
onChange={(e) =>
133+
setSettings({
134+
...settings,
135+
geminiApiKey: e.target.value,
136+
})
137+
}
138+
/>
139+
</>
140+
)
141+
}
142+
96143
</div>
97144

98145
<div className="flex items-center space-x-2">

components/components/chatInput/index.tsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {UploadFileContext} from '../../contexts/UploadFileContext'
33
import { SettingContext } from '../../contexts/SettingContext';
44
import { useRouter } from 'next/navigation';
55
import { LiaPencilRulerSolid } from "react-icons/lia";
6+
import classNames from "classnames";
67

78
interface props {
89
openWhiteboard: () => void
@@ -16,6 +17,7 @@ export default function ChatInput({openWhiteboard}: props) {
1617
open,
1718
} = useContext(UploadFileContext);
1819
const { initCreateText, setInitCreateText, setInitCreate } = useContext(SettingContext);
20+
const [showAnim, setShowAnim] = useState<boolean>(false);
1921

2022
useEffect(() => {
2123
if (inputRef.current) {
@@ -52,13 +54,25 @@ export default function ChatInput({openWhiteboard}: props) {
5254
<div
5355
onClick={() => {
5456
inputRef.current.focus();
57+
setShowAnim(true);
58+
setTimeout(() => {
59+
setShowAnim(false);
60+
}, 800)
5561
}}
5662
className='before:block before:absolute before:-inset-1 before:-skew-y-3 before:bg-cyan-500 relative inline-block px-8'
5763
>
58-
<span className='relative text-white'>text</span>
64+
<span className='relative text-white'>ideas</span>
5965
</div>
6066
</div>
61-
<div className="sm:max-w-lg m-auto shadow-lg divide-zinc-600 min-h-12 bg-gray-900 shadow-black/40 rounded-[24px] overflow-hidden max-w-[90%] flex items-center flex-1 min-w-0 px-3 md:pl-4 bg-gray-900 relative z-10">
67+
{/* animate-wiggle */}
68+
<div
69+
className={classNames(
70+
"sm:max-w-lg m-auto shadow-lg divide-zinc-600 min-h-12 bg-gray-900 shadow-black/40 rounded-[24px] overflow-hidden max-w-[90%] flex items-center flex-1 min-w-0 px-3 md:pl-4 bg-gray-900 relative z-10",
71+
{
72+
"animate-wiggle": showAnim,
73+
}
74+
)}
75+
>
6276
<div
6377
className="relative w-full flex items-center transition-all duration-300 min-h-full h-fit" >
6478
<label htmlFor="textarea-input" className="sr-only">Prompt</label>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import * as React from "react"
2+
import * as RadioGroupPrimitive from "@radix-ui/react-radio-group";
3+
import { Circle } from "lucide-react"
4+
5+
import { cn } from "../../lib/utils"
6+
7+
const RadioGroup = React.forwardRef<
8+
React.ElementRef<typeof RadioGroupPrimitive.Root>,
9+
React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Root>
10+
>(({ className, ...props }, ref) => {
11+
return (<RadioGroupPrimitive.Root className={cn("grid gap-2", className)} {...props} ref={ref} />);
12+
})
13+
RadioGroup.displayName = RadioGroupPrimitive.Root.displayName
14+
15+
const RadioGroupItem = React.forwardRef<
16+
React.ElementRef<typeof RadioGroupPrimitive.Item>,
17+
React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Item>
18+
>(({ className, ...props }, ref) => {
19+
return (
20+
(<RadioGroupPrimitive.Item
21+
ref={ref}
22+
className={cn(
23+
"aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
24+
className
25+
)}
26+
{...props}>
27+
<RadioGroupPrimitive.Indicator className="flex items-center justify-center">
28+
<Circle className="h-2.5 w-2.5 fill-current text-current" />
29+
</RadioGroupPrimitive.Indicator>
30+
</RadioGroupPrimitive.Item>)
31+
);
32+
})
33+
RadioGroupItem.displayName = RadioGroupPrimitive.Item.displayName
34+
35+
export { RadioGroup, RadioGroupItem }

components/contexts/SettingContext.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ const initialValue = {
2424
mockAiResponse: false,
2525
promptCode: '',
2626
init: false,
27+
llm: 'openai',
28+
geminiApiKey: '',
2729
},
2830
initCreate: false,
2931
setSettings: () => {},

components/contexts/UploadFileContext.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ export default function UploadFileProvider({ children }: { children: ReactNode }
4343
const [dataUrls, setDataUrlsStatus] = useState<string[]>([]);
4444
const [uploadComplete, setUploadCompleteStatus] = useState(() => {
4545
return () => {}
46-
})
46+
});
47+
4748
const { getRootProps, getInputProps, isFocused, isDragAccept, isDragReject, open } =
4849
useDropzone({
4950
maxFiles: 1,
@@ -68,7 +69,6 @@ export default function UploadFileProvider({ children }: { children: ReactNode }
6869
Promise.all(acceptedFiles.map((file) => fileToDataURL(file)))
6970
.then((dataUrls: any) => {
7071
setDataUrlsStatus(dataUrls)
71-
console.log(dataUrls);
7272
uploadComplete();
7373
// setReferenceImages(dataUrls.map((dataUrl) => dataUrl as string));
7474
})

components/generateCode.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export function generateCode(
2929
onComplete: () => void
3030
) {
3131

32+
3233
wsRef.current = new AbortController();
3334

3435
async function handleMessage(event: { data: string }) {

components/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ export interface Settings {
2929
mockAiResponse: boolean;
3030
promptCode: string;
3131
init: boolean;
32+
llm: string;
33+
geminiApiKey: string;
3234
}
3335

3436
export enum AppState {

package-lock.json

Lines changed: 42 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"@radix-ui/react-label": "^2.0.2",
2525
"@radix-ui/react-popover": "^1.0.7",
2626
"@radix-ui/react-progress": "^1.0.3",
27+
"@radix-ui/react-radio-group": "^1.1.3",
2728
"@radix-ui/react-scroll-area": "^1.0.5",
2829
"@radix-ui/react-select": "^2.0.0",
2930
"@radix-ui/react-separator": "^1.0.3",
@@ -39,6 +40,7 @@
3940
"html2canvas": "^1.4.1",
4041
"intl-messageformat": "^10.5.8",
4142
"lodash": "^4.17.21",
43+
"lucide-react": "^0.304.0",
4244
"mobx": "^6.12.0",
4345
"mobx-react": "^9.1.0",
4446
"monaco-editor": "^0.45.0",

pages/index.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export default function Dashboard() {
4747
isFocused,
4848
isDragReject,
4949
setUploadComplete,
50+
setDataUrls,
5051
} = useContext(UploadFileContext);
5152
const [openWhiteboard, setOpenWhiteboard] = useState(false);
5253
const ref = useRef(null);
@@ -104,7 +105,11 @@ export default function Dashboard() {
104105
)}
105106
>
106107
<Whiteboard
107-
doCreate={() => {
108+
doCreate={(urls: string[]) => {
109+
setOpenWhiteboard(false);
110+
setDataUrls(urls);
111+
setInitCreate(true);
112+
router.push('/home', { scroll: false })
108113
}}
109114
closeWhiteboard={() => {
110115
setOpenWhiteboard(false);

0 commit comments

Comments
 (0)