Skip to content

Commit bb2b930

Browse files
add Chat .Header component (#1015)
* add chat header component * update chat preview * fix chat types * fix lint and ts * fix lint and ts * fix lint and ts * fix lint and ts
1 parent 5c67c4f commit bb2b930

File tree

7 files changed

+37
-27
lines changed

7 files changed

+37
-27
lines changed

apps/design-system/src/main.tsx

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import { StrictMode } from 'react'
2-
import { render } from 'react-dom'
2+
import { createRoot } from 'react-dom/client'
33

44
import App from './App'
55

6-
render(
6+
const container = document.getElementById('root')
7+
const root = createRoot(container!)
8+
9+
root.render(
710
<StrictMode>
811
<App />
9-
</StrictMode>,
10-
document.getElementById('root')
12+
</StrictMode>
1113
)

apps/gitness/src/main.tsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
import { render } from 'react-dom'
1+
import { createRoot } from 'react-dom/client'
22

33
import App from './App'
44

5-
render(<App />, document.getElementById('root'))
5+
const container = document.getElementById('root')
6+
const root = createRoot(container!)
7+
8+
root.render(<App />)

packages/ui/src/components/chat/chat-preview-wrapper.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export const ChatPreviewWrapper: FC = () => {
2121
return (
2222
<div className="h-[calc(100vh-100px)] border-r border-borders-4">
2323
<Chat.Root>
24+
<Chat.Header onClose={() => {}} />
2425
<Chat.Body>
2526
<Chat.Message>
2627
Hey Olivia! I&#39;ve finished with the requirements doc! I made some notes in the gdoc as well for Phoenix

packages/ui/src/components/chat/chat.tsx

+15-13
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,31 @@ import { Button, Icon, Input } from '@/components'
44
import ChatAvatarIcon from '@/icons/chat-avatar.svg'
55
import { cn } from '@utils/cn'
66

7-
const Root: FC = ({ children }: PropsWithChildren<HTMLAttributes<HTMLElement>>) => {
7+
const Root: FC<PropsWithChildren<HTMLAttributes<HTMLElement>>> = ({ children }) => {
8+
return <div className="flex size-full max-w-[460px] flex-col bg-background-1">{children}</div>
9+
}
10+
11+
const Header: FC<{ onClose: () => void }> = ({ onClose }) => {
812
return (
9-
<div className="flex size-full max-w-[460px] flex-col bg-background-1">
10-
<div className="sticky top-0 flex items-center justify-between bg-background-1 px-6 py-4">
11-
<p className="text-16 font-medium text-foreground-1">AI Assistant</p>
12-
<Button size="icon" variant="custom" className="-mr-2 text-icons-4 hover:text-icons-2">
13-
<Icon name="close" size={16} />
14-
<span className="sr-only">Close</span>
15-
</Button>
16-
</div>
17-
{children}
13+
<div className="sticky top-0 flex items-center justify-between bg-background-1 px-6 py-4">
14+
<p className="text-16 font-medium text-foreground-1">AI Assistant</p>
15+
<Button size="icon" variant="custom" className="-mr-2 text-icons-4 hover:text-icons-2" onClick={onClose}>
16+
<Icon name="close" size={16} />
17+
<span className="sr-only">Close</span>
18+
</Button>
1819
</div>
1920
)
2021
}
2122

22-
const Body: FC = ({ children }: PropsWithChildren<HTMLAttributes<HTMLElement>>) => {
23+
const Body: FC<PropsWithChildren<HTMLAttributes<HTMLElement>>> = ({ children }) => {
2324
return (
2425
<div className="scrollbar-hidden flex flex-1 flex-col gap-y-7 overflow-y-auto overflow-x-hidden px-6 py-2">
2526
{children}
2627
</div>
2728
)
2829
}
2930

30-
const Footer: FC = ({ children }: PropsWithChildren<HTMLAttributes<HTMLElement>>) => {
31+
const Footer: FC<PropsWithChildren<HTMLAttributes<HTMLElement>>> = ({ children }) => {
3132
return <div className="sticky bottom-0 bg-background-1 px-6 py-3">{children}</div>
3233
}
3334

@@ -64,7 +65,7 @@ const Message: FC<MessageProps> = ({ self, avatar, actions, children }) => {
6465
)
6566
}
6667

67-
const CodeBlock: FC<{ className?: string }> = ({ children, className }) => {
68+
const CodeBlock: FC<PropsWithChildren<{ className?: string }>> = ({ children, className }) => {
6869
return (
6970
<code
7071
className={cn(
@@ -194,6 +195,7 @@ const InputField: FC<InputFieldProps> = ({
194195
export const Chat = {
195196
Root,
196197
Body,
198+
Header,
197199
Footer,
198200
Message,
199201
Typing,

packages/ui/src/components/tabnav.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
import { PropsWithChildren } from 'react'
12
import { NavLink, NavLinkProps } from 'react-router-dom'
23

3-
const TabNavRoot: React.FC = ({ children }) => {
4+
const TabNavRoot: React.FC<PropsWithChildren> = ({ children }) => {
45
return (
56
<nav className="inline-flex h-[44px] w-full items-center justify-start gap-6 border-b border-border-background px-6 text-muted-foreground">
67
{children}

packages/ui/src/views/repo/pull-request/components/in-view-diff-renderer.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const InViewDiffRendererInternal: FC<InViewDiffRendererProps> = ({
3131
initialInView: false
3232
})
3333
const setContainerRef = useCallback(
34-
node => {
34+
(node: HTMLDivElement) => {
3535
containerRef.current = node
3636
ref(node)
3737
},
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import React from 'react'
2-
import { render } from 'react-dom'
1+
import { StrictMode } from 'react'
2+
import { createRoot } from 'react-dom/client'
33

44
import App from './App'
55

6-
render(
7-
<React.StrictMode>
6+
const root = createRoot(document.getElementById('root')!)
7+
8+
root.render(
9+
<StrictMode>
810
<App />
9-
</React.StrictMode>,
10-
document.getElementById('root')
11+
</StrictMode>
1112
)

0 commit comments

Comments
 (0)