Skip to content

Commit

Permalink
Added a button to close the chat window
Browse files Browse the repository at this point in the history
resolves issue livekit#665
  • Loading branch information
GOVIND SHARMA committed Dec 23, 2023
1 parent d3bb268 commit f64ae53
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 1 deletion.
28 changes: 28 additions & 0 deletions packages/react/src/assets/icons/ChatCloseIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* WARNING: This file was auto-generated by svgr. Do not edit.
*/
import * as React from 'react';
import type { SVGProps } from 'react';
/**
* @internal
*/
const SvgChatCloseIcon = (props: SVGProps<SVGSVGElement>) => (
<svg
xmlns="http://www.w3.org/2000/svg"
x="0px"
y="0px"
width={16}
height={18}
viewBox="0 0 24 24"
fill=""
{...props}
>
<path
fill="currentColor"
fillRule="evenodd"
clipRule="evenodd"
d="M 4.9902344 3.9902344 A 1.0001 1.0001 0 0 0 4.2929688 5.7070312 L 10.585938 12 L 4.2929688 18.292969 A 1.0001 1.0001 0 1 0 5.7070312 19.707031 L 12 13.414062 L 18.292969 19.707031 A 1.0001 1.0001 0 1 0 19.707031 18.292969 L 13.414062 12 L 19.707031 5.7070312 A 1.0001 1.0001 0 0 0 18.980469 3.9902344 A 1.0001 1.0001 0 0 0 18.292969 4.2929688 L 12 10.585938 L 5.7070312 4.2929688 A 1.0001 1.0001 0 0 0 4.9902344 3.9902344 z"
></path>
</svg>
);
export default SvgChatCloseIcon;
1 change: 1 addition & 0 deletions packages/react/src/assets/icons/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ export { default as ScreenShareIcon } from './ScreenShareIcon';
export { default as ScreenShareStopIcon } from './ScreenShareStopIcon';
export { default as SpinnerIcon } from './SpinnerIcon';
export { default as UnfocusToggleIcon } from './UnfocusToggleIcon';
export { default as ChatCloseIcon } from './ChatCloseIcon';
9 changes: 9 additions & 0 deletions packages/react/src/prefabs/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { cloneSingleChild } from '../utils';
import type { MessageFormatter } from '../components/ChatEntry';
import { ChatEntry } from '../components/ChatEntry';
import { useChat } from '../hooks/useChat';
import { ChatToggle } from '../components';
import { ChatCloseIcon } from '../assets/icons';

/** @public */
export interface ChatProps extends React.HTMLAttributes<HTMLDivElement>, ChatOptions {
Expand Down Expand Up @@ -85,6 +87,13 @@ export function Chat({

return (
<div {...props} className="lk-chat">
<div className="lk-chat-header">
<span>Messages</span>
<ChatToggle>
<ChatCloseIcon />
</ChatToggle>
</div>

<ul className="lk-list lk-chat-messages" ref={ulRef}>
{props.children
? chatMessages.map((msg, idx) =>
Expand Down
15 changes: 14 additions & 1 deletion packages/styles/scss/prefabs/chat.scss
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
.chat {
display: grid;
grid-template-rows: 1fr var(--control-bar-height);
grid-template-rows:var(--chat-header-height) 1fr var(--control-bar-height);
width: clamp(200px, 55ch, 60ch);
background-color: var(--bg2);
border-left: 1px solid var(--border-color);
align-items: end;
}

.chat-header {
height: var(--chat-header-height);
padding:0.75rem;
align-items: center;
justify-content: center;
display: flex;
span:first-of-type {
// Styles for the chat header text "Messages"
width: 100%;
text-align: center;
}
}

.chat-messages {
display: flex;
width: 100%;
Expand Down
1 change: 1 addition & 0 deletions packages/styles/scss/themes/default.scss
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,5 @@ $accent: #1f8cf9;

--grid-gap: 0.5rem;
--control-bar-height: 69px;
--chat-header-height: 69px;
}

0 comments on commit f64ae53

Please sign in to comment.