@@ -31,23 +31,29 @@ npm install @lg-chat/chat-layout
3131This package exports:
3232
3333- ` ChatLayout ` : The grid container and context provider
34- - ` ChatMain ` : Content area component that positions itself in the grid
34+ - ` ChatMain ` : The primary content area of the chat interface, automatically positioned within the grid layout.
35+ - ` ChatSideNav ` : A compound component representing the side navigation, exposing subcomponents such as ` ChatSideNav.Header ` and ` ChatSideNav.Content ` for flexible composition.
3536- ` useChatLayoutContext ` : Hook for accessing layout state
3637
3738## Examples
3839
3940### Basic
4041
4142``` tsx
42- import { ChatLayout , ChatMain } from ' @lg-chat/chat-layout' ;
43+ import { ChatLayout , ChatMain , ChatSideNav } from ' @lg-chat/chat-layout' ;
4344
4445function MyChatApp() {
46+ const handleNewChat = () => {
47+ console .log (' Start new chat' );
48+ };
49+
4550 return (
4651 <ChatLayout >
47- { /* ChatSideNav will go here */ }
48- <ChatMain >
49- <div >Your chat content</div >
50- </ChatMain >
52+ <ChatSideNav >
53+ <ChatSideNav.Header onClickNewChat = { handleNewChat } />
54+ <ChatSideNav.Content >{ /* Your side nav content */ } </ChatSideNav.Content >
55+ </ChatSideNav >
56+ <ChatMain >{ /* Main chat content here */ } </ChatMain >
5157 </ChatLayout >
5258 );
5359}
@@ -56,19 +62,24 @@ function MyChatApp() {
5662### With Initial State and Toggle Pinned Callback
5763
5864``` tsx
59- import { ChatLayout , ChatMain } from ' @lg-chat/chat-layout' ;
65+ import { ChatLayout , ChatMain , ChatSideNav } from ' @lg-chat/chat-layout' ;
6066
6167function MyChatApp() {
68+ const handleNewChat = () => {
69+ console .log (' Start new chat' );
70+ };
71+
6272 const handleTogglePinned = (isPinned : boolean ) => {
6373 console .log (' Side nav is now:' , isPinned ? ' pinned' : ' collapsed' );
6474 };
6575
6676 return (
6777 <ChatLayout initialIsPinned = { false } onTogglePinned = { handleTogglePinned } >
68- { /* ChatSideNav will go here */ }
69- <ChatMain >
70- <div >Your chat content</div >
71- </ChatMain >
78+ <ChatSideNav >
79+ <ChatSideNav.Header onClickNewChat = { handleNewChat } />
80+ <ChatSideNav.Content >{ /* Your side nav content */ } </ChatSideNav.Content >
81+ </ChatSideNav >
82+ <ChatMain >{ /* Main chat content here */ } </ChatMain >
7283 </ChatLayout >
7384 );
7485}
@@ -97,6 +108,29 @@ All other props are passed through to the underlying `<div>` element.
97108
98109** Note:** ` ChatMain ` must be used as a direct child of ` ChatLayout ` to work correctly within the grid system.
99110
111+ ### ChatSideNav
112+
113+ | Prop | Type | Description | Default |
114+ | ------------------------ | ------------------------- | -------------------------------------------------------------- | ------- |
115+ | ` children ` | ` ReactNode ` | Should include ` ChatSideNav.Header ` and ` ChatSideNav.Content ` . | - |
116+ | ` className ` _ (optional)_ | ` string ` | Root class name | - |
117+ | ` ... ` | ` HTMLElementProps<'nav'> ` | Props spread on the root ` <nav> ` element | - |
118+
119+ ### ChatSideNav.Header
120+
121+ | Prop | Type | Description | Default |
122+ | ----------------------------- | -------------------------------------- | ------------------------------------------- | ------- |
123+ | ` onClickNewChat ` _ (optional)_ | ` MouseEventHandler<HTMLButtonElement> ` | Fired when the "New Chat" button is clicked | - |
124+ | ` className ` _ (optional)_ | ` string ` | Header class name | - |
125+ | ` ... ` | ` HTMLElementProps<'div'> ` | Props spread on the header container | - |
126+
127+ ### ChatSideNav.Content
128+
129+ | Prop | Type | Description | Default |
130+ | ------------------------ | ------------------------- | ------------------------------------- | ------- |
131+ | ` className ` _ (optional)_ | ` string ` | Content class name | - |
132+ | ` ... ` | ` HTMLElementProps<'div'> ` | Props spread on the content container | - |
133+
100134## Context API
101135
102136### useChatLayoutContext
0 commit comments