chatscope / chat-ui-kit-react

Build your own chat UI with React components in few minutes. Chat UI Kit from chatscope is an open source UI toolkit for developing web chat applications.
https://chatscope.io
MIT License
1.32k stars 109 forks source link

transitionning between the chatcontainer and the sidebar in mobile display #142

Closed Med-Fedi-Adel closed 8 months ago

Med-Fedi-Adel commented 9 months ago

Hello , it's not really an issue but I'm working with this library and I'm having hard time to write a bit of code to transition from the chatContainer to the Sidebar by clicking on the Back arrow located in the start of Conversation Header. I just need a bit of help in the css and state management to make the sidebar appear with full width on the screen and the ChatContainer is hidden.

Example :

When I click on this back arrow for example : Capture d'écran 2024-01-21 230148

My goal is something similar to this : Capture d'écran 2024-01-21 230018

notzane commented 9 months ago

Try something like this, call setShowSidebar(true) in your back button and false when you tap a thread.

const [showSidebar, setShowSidebar] = useState(true); // start with sidebar showing

return (
  <MainContainer>
    {showSidebar ? ( // if true render the sidebar content
      <Sidebar>
        { sidebar content }
      </Sidebar>
    ) : ( // else render the chat content
      <ChatContainer>
        { chat content }
      </ChatContainer>
    )
 </MainContainer>
)
vishalbhan commented 9 months ago

Here's the implementation from the chatscope storybook: https://chatscope.io/storybook/react/?path=/docs/components-maincontainer--default-story#toggle-conversation-list-using-the-back-button

supersnager commented 8 months ago

@vishalbhan gave an answer so I'm closing the issue. @Med-Fedi-Adel if you still have problem with this, please reopen.