MingruiZhang commited on
Commit
edd2230
1 Parent(s): ee55c8c
app/(chat)/page.tsx CHANGED
@@ -1,19 +1,23 @@
1
  import { nanoid } from '@/lib/utils';
2
  import { Chat } from '@/components/chat';
 
3
 
4
  export default function IndexPage() {
5
  const id = nanoid();
6
 
7
  return (
8
- <Chat
9
- id={id}
10
- initialMessages={[
11
- {
12
- id: '123',
13
- content: 'Hi, what do you want to know about this image?',
14
- role: 'system',
15
- },
16
- ]}
17
- />
 
 
 
18
  );
19
  }
 
1
  import { nanoid } from '@/lib/utils';
2
  import { Chat } from '@/components/chat';
3
+ import { ThemeToggle } from '../../components/theme-toggle';
4
 
5
  export default function IndexPage() {
6
  const id = nanoid();
7
 
8
  return (
9
+ <>
10
+ <Chat
11
+ id={id}
12
+ initialMessages={[
13
+ {
14
+ id: '123',
15
+ content: 'Hi, what do you want to know about this image?',
16
+ role: 'system',
17
+ },
18
+ ]}
19
+ />
20
+ <ThemeToggle />
21
+ </>
22
  );
23
  }
components/chat-list.tsx CHANGED
@@ -1,3 +1,5 @@
 
 
1
  import { type Message } from 'ai';
2
  import { useEffect, useState } from 'react';
3
 
 
1
+ 'use client';
2
+
3
  import { type Message } from 'ai';
4
  import { useEffect, useState } from 'react';
5
 
components/chat.tsx CHANGED
@@ -16,6 +16,7 @@ import { usePathname, useRouter } from 'next/navigation';
16
  import { useAtom } from 'jotai';
17
  import { targetImageAtom } from '@/state';
18
  import Image from 'next/image';
 
19
 
20
  export interface ChatProps extends React.ComponentProps<'div'> {
21
  initialMessages?: Message[];
@@ -44,7 +45,7 @@ export function Chat({ id, initialMessages, className }: ChatProps) {
44
  if (!targetImage)
45
  return (
46
  <div className={cn('pb-[150px] pt-4 md:pt-10 h-full', className)}>
47
- <EmptyScreen />/
48
  </div>
49
  );
50
  return (
 
16
  import { useAtom } from 'jotai';
17
  import { targetImageAtom } from '@/state';
18
  import Image from 'next/image';
19
+ import { ThemeToggle } from './theme-toggle';
20
 
21
  export interface ChatProps extends React.ComponentProps<'div'> {
22
  initialMessages?: Message[];
 
45
  if (!targetImage)
46
  return (
47
  <div className={cn('pb-[150px] pt-4 md:pt-10 h-full', className)}>
48
+ <EmptyScreen />
49
  </div>
50
  );
51
  return (
components/theme-toggle.tsx CHANGED
@@ -1,31 +1,32 @@
1
- 'use client'
2
 
3
- import * as React from 'react'
4
- import { useTheme } from 'next-themes'
5
 
6
- import { Button } from '@/components/ui/button'
7
- import { IconMoon, IconSun } from '@/components/ui/icons'
8
 
9
  export function ThemeToggle() {
10
- const { setTheme, theme } = useTheme()
11
- const [_, startTransition] = React.useTransition()
12
 
13
- return (
14
- <Button
15
- variant="ghost"
16
- size="icon"
17
- onClick={() => {
18
- startTransition(() => {
19
- setTheme(theme === 'light' ? 'dark' : 'light')
20
- })
21
- }}
22
- >
23
- {!theme ? null : theme === 'dark' ? (
24
- <IconMoon className="transition-all" />
25
- ) : (
26
- <IconSun className="transition-all" />
27
- )}
28
- <span className="sr-only">Toggle theme</span>
29
- </Button>
30
- )
 
31
  }
 
1
+ 'use client';
2
 
3
+ import * as React from 'react';
4
+ import { useTheme } from 'next-themes';
5
 
6
+ import { Button } from '@/components/ui/button';
7
+ import { IconMoon, IconSun } from '@/components/ui/icons';
8
 
9
  export function ThemeToggle() {
10
+ const { setTheme, theme } = useTheme();
11
+ const [_, startTransition] = React.useTransition();
12
 
13
+ return (
14
+ <Button
15
+ variant="ghost"
16
+ size="icon"
17
+ className="fixed bottom-4 right-4 z-50 dark:bg-zinc-950 dark:text-white transition-all p-2 rounded-full shadow-md"
18
+ onClick={() => {
19
+ startTransition(() => {
20
+ setTheme(theme === 'light' ? 'dark' : 'light');
21
+ });
22
+ }}
23
+ >
24
+ {!theme ? null : theme === 'dark' ? (
25
+ <IconMoon className="transition-all" />
26
+ ) : (
27
+ <IconSun className="transition-all" />
28
+ )}
29
+ <span className="sr-only">Toggle theme</span>
30
+ </Button>
31
+ );
32
  }