-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor and redesign of the 3d-web-text-chat package #38
Merged
+270
−172
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { createRef, forwardRef } from "react"; | ||
import { flushSync } from "react-dom"; | ||
import { createRoot, Root } from "react-dom/client"; | ||
|
||
import { ChatUIComponent } from "./components/ChatPanel/TextChatUIComponent"; | ||
|
||
const ForwardedChatUIComponent = forwardRef(ChatUIComponent); | ||
|
||
export type ChatUIInstance = { | ||
addMessage: (username: string, message: string) => void; | ||
}; | ||
|
||
export class TextChatUI { | ||
private root: Root; | ||
private appRef: React.RefObject<ChatUIInstance> = createRef<ChatUIInstance>(); | ||
|
||
public addTextMessage(username: string, message: string) { | ||
if (this.appRef.current) this.appRef.current.addMessage(username, message); | ||
} | ||
|
||
private container = document.getElementById("text-chat-ui")!; | ||
|
||
constructor( | ||
private clientname: string, | ||
private sendMessageToServerMethod: (message: string) => void, | ||
) { | ||
this.root = createRoot(this.container); | ||
this.sendMessageToServerMethod = sendMessageToServerMethod; | ||
} | ||
|
||
init() { | ||
flushSync(() => | ||
this.root.render( | ||
<ForwardedChatUIComponent | ||
ref={this.appRef} | ||
clientName={this.clientname} | ||
sendMessageToServer={this.sendMessageToServerMethod} | ||
/>, | ||
), | ||
); | ||
} | ||
} |
203 changes: 203 additions & 0 deletions
203
...ges/3d-web-text-chat/src/chat-ui/components/ChatPanel/TextChatUIComponent.module copy.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,203 @@ | ||
.textChat { | ||
z-index: -1; | ||
position: fixed; | ||
|
||
display: flex; | ||
flex-direction: column; | ||
justify-content: space-between; | ||
|
||
bottom: 45px; | ||
left: 60px; | ||
|
||
width: 400px; | ||
min-width: 400px; | ||
max-height: 500px; | ||
|
||
color: #ffffff; | ||
padding: 7px; | ||
|
||
-webkit-user-select: none; | ||
-ms-user-select: none; | ||
user-select: none; | ||
|
||
opacity: 0; | ||
transform: translateX(-100%); | ||
transition: | ||
opacity 0.25s ease-in-out, | ||
transform 0.2s ease-in-out; | ||
} | ||
|
||
.fadeIn { | ||
transform: translateX(0%); | ||
opacity: 1; | ||
} | ||
|
||
.fadeOut { | ||
transform: translateX(calc(-100% - 72px)); | ||
opacity: 0.6; | ||
} | ||
|
||
.controls { | ||
position: absolute; | ||
right: 0px; | ||
top: 2px; | ||
} | ||
|
||
.openTab { | ||
z-index: 1001; | ||
position: fixed; | ||
width: 42px; | ||
height: 42px; | ||
border-radius: 50%; | ||
bottom: 12px; | ||
left: 12px; | ||
background-color: rgba(0, 0, 0, 0.8); | ||
box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.8); | ||
border: 1px solid rgba(255, 255, 255, 0.21); | ||
-webkit-user-select: none; | ||
-ms-user-select: none; | ||
user-select: none; | ||
cursor: pointer; | ||
} | ||
|
||
.openTab img { | ||
filter: invert(60%); | ||
width: 35px; | ||
height: 35px; | ||
transition: all 0.3s ease-in-out; | ||
position: relative; | ||
top: 3px; | ||
left: 4px; | ||
transform: scale(0.7); | ||
} | ||
|
||
.stickyButton { | ||
z-index: 1002; | ||
position: fixed; | ||
width: 42px; | ||
height: 42px; | ||
border-radius: 50%; | ||
|
||
bottom: 62px; | ||
left: 12px; | ||
|
||
background-color: rgba(0, 0, 0, 0.8); | ||
box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.8); | ||
border: 1px solid rgba(255, 255, 255, 0.21); | ||
|
||
-webkit-user-select: none; | ||
-ms-user-select: none; | ||
user-select: none; | ||
|
||
transition: border 0.2s ease-in-out; | ||
cursor: pointer; | ||
} | ||
|
||
.stickyButton:hover { | ||
border: 1px solid rgba(255, 255, 255, 0.3); | ||
} | ||
|
||
.stickyButtonEnabled { | ||
z-index: 1002; | ||
position: fixed; | ||
width: 42px; | ||
height: 42px; | ||
border-radius: 50%; | ||
|
||
bottom: 62px; | ||
left: 12px; | ||
|
||
background-color: rgba(0, 0, 0, 0.8); | ||
box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.8); | ||
border: 1px solid rgba(255, 255, 255, 0.21); | ||
|
||
-webkit-user-select: none; | ||
-ms-user-select: none; | ||
user-select: none; | ||
|
||
border: 1px solid rgba(21, 210, 21, 0.9); | ||
transition: border 0.2s ease-in-out; | ||
cursor: pointer; | ||
} | ||
|
||
.stickyButtonEnabled:hover { | ||
border: 1px solid rgba(55, 255, 55, 1); | ||
} | ||
|
||
.stickyButton img { | ||
/* width: 25px; | ||
height: 25px; | ||
position: relative; | ||
top: 1px; | ||
left: 0px; | ||
filter: invert(50%); | ||
transform: scale(0.7); | ||
transition: all 0.3s ease-in-out; */ | ||
|
||
filter: invert(50%); | ||
width: 31px; | ||
height: 31px; | ||
position: relative; | ||
top: 7px; | ||
left: 6px; | ||
transform: scale(0.7); | ||
transition: all 0.3s ease-in-out; | ||
} | ||
|
||
.stickyButton:hover img { | ||
filter: invert(70%); | ||
transform: scale(0.8); | ||
} | ||
|
||
.stickyButtonEnabled img { | ||
filter: invert(50%); | ||
width: 31px; | ||
height: 31px; | ||
position: relative; | ||
top: 7px; | ||
left: 6px; | ||
transform: scale(0.7); | ||
transition: all 0.3s ease-in-out; | ||
} | ||
|
||
.stickyButtonEnabled:hover img { | ||
filter: invert(70%); | ||
transform: scale(0.8); | ||
} | ||
|
||
.controls .closeButton { | ||
font-family: "arial black"; | ||
font-weight: 900; | ||
color: #aaaaaa; | ||
position: absolute; | ||
top: 3px; | ||
right: 3px; | ||
width: 25px; | ||
height: 24px; | ||
background-color: rgba(0, 0, 0, 0.9); | ||
line-height: 24px; | ||
text-align: center; | ||
vertical-align: middle; | ||
border-radius: 50%; | ||
border: 1px solid rgba(255, 255, 255, 0.12); | ||
transition: border 0.2s ease-in-out; | ||
cursor: pointer; | ||
} | ||
|
||
.closeButton:hover { | ||
border: 1px solid rgba(255, 255, 255, 0.3); | ||
} | ||
|
||
.messagesWrapper { | ||
position: relative; | ||
height: 500px; | ||
min-height: 500px; | ||
max-height: 500px; | ||
-webkit-mask-image: url("http://localhost:8080/assets/chat-gradient.png"); | ||
-webkit-mask-size: contain; | ||
-webkit-mask-repeat: repeat-x; | ||
mask-image: url("http://localhost:8080/assets/chat-gradient.png"); | ||
mask-size: contain; | ||
mask-repeat: repeat-x; | ||
direction: rtl; | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it intended to have a copy of the
TextChatUIComponent.module.css
here?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was an alternative layout for the pin button. Just fixed with the second commit.