This commit is contained in:
Nalvazhuthi 2025-05-22 18:04:06 +05:30
commit e836c96c23
9 changed files with 86 additions and 72 deletions

View File

@ -1,22 +1,48 @@
import React, { useState } from "react"; import React, { useState } from "react";
import { getAvatarColor } from "../../../modules/collaboration/functions/getAvatarColor"; import { getAvatarColor } from "../../../modules/collaboration/functions/getAvatarColor";
const CommentThreads: React.FC = () => { interface CommentThreadsProps {
commentClicked: () => void;
}
const CommentThreads: React.FC<CommentThreadsProps> = ({ commentClicked }) => {
const [expand, setExpand] = useState(false); const [expand, setExpand] = useState(false);
const commentsedUsers = [ const commentsedUsers = [{ creatorId: "1" }];
const CommentDetails = {
state: "active",
commentId: "c-1",
creatorId: "12",
createdAt: "2 hours ago",
comment: "Thread check",
lastUpdatedAt: "string",
replies: [
{ {
userId: "1", replyId: 'string',
userName: "user", creatorId: 'string',
createdAt: 'string',
lastUpdatedAt: 'string',
reply: 'string',
}, },
{ {
userId: "2", replyId: 'string',
userName: "Admin", creatorId: 'string',
}, createdAt: 'string',
]; lastUpdatedAt: 'string',
reply: 'string',
}
],
};
function getUsername(userId: string) {
const UserName = "username";
return UserName;
}
function getDetails(type?: "clicked") { function getDetails(type?: "clicked") {
if (type === "clicked") { if (type === "clicked") {
setExpand(true); setExpand(true);
commentClicked();
} else { } else {
setExpand((prev) => !prev); setExpand((prev) => !prev);
} }
@ -28,28 +54,33 @@ const CommentThreads: React.FC = () => {
onPointerEnter={() => getDetails()} onPointerEnter={() => getDetails()}
onPointerLeave={() => getDetails()} onPointerLeave={() => getDetails()}
onClick={() => getDetails("clicked")} onClick={() => getDetails("clicked")}
className={`comments-threads-container ${ className={`comments-threads-container ${expand ? "open" : "closed"
expand ? "open" : "closed"
} unread`} } unread`}
> >
<div className="users-commented"> <div className="users-commented">
{commentsedUsers.map((val, i) => ( {commentsedUsers.map((val, i) => (
<div <div
className="users" className="users"
key={val.userId} key={val.creatorId}
style={{ background: getAvatarColor(i, val.userName) }} style={{
background: getAvatarColor(i, getUsername(val.creatorId)),
}}
> >
{val.userName[0]} {getUsername(val.creatorId)[0]}
</div> </div>
))} ))}
</div> </div>
<div className={`last-comment-details ${expand ? "expand" : ""}`}> <div className={`last-comment-details ${expand ? "expand" : ""}`}>
<div className="header"> <div className="header">
<div className="user-name">user</div> <div className="user-name">
<div className="time">4 mins, ago</div> {getUsername(CommentDetails.creatorId)}
</div> </div>
<div className="message">hello</div> <div className="time">{CommentDetails.createdAt}</div>
<div className="replies">0 replies</div> </div>
<div className="message">{CommentDetails.comment}</div>
{CommentDetails.replies.length > 0 && (
<div className="replies">{CommentDetails.replies.length} reply(s)</div>
)}
</div> </div>
</button> </button>
</div> </div>

View File

@ -3,14 +3,7 @@ import { getAvatarColor } from "../../../modules/collaboration/functions/getAvat
import { KebabIcon } from "../../icons/ExportCommonIcons"; import { KebabIcon } from "../../icons/ExportCommonIcons";
interface MessageProps { interface MessageProps {
val: { val: Reply;
userName: string;
userId: string;
message: string;
creationTime: string;
idEdited: boolean;
modifiedTime: string;
};
i: number; i: number;
} }
@ -18,22 +11,25 @@ const Messages: React.FC<MessageProps> = ({ val, i }) => {
const [isEditing, setIsEditing] = useState(false); const [isEditing, setIsEditing] = useState(false);
const [openOptions, setOpenOptions] = useState(false); const [openOptions, setOpenOptions] = useState(false);
const currentUser = "1"; const currentUser = "1";
const UserName = "username";
return ( return (
<> <>
{isEditing ? ( {isEditing ? (
<> <>
<div <div
className="profile" className="profile"
style={{ background: getAvatarColor(i, val.userName) }} style={{ background: getAvatarColor(i, UserName) }}
> >
{val.userName[0]} {UserName[0]}
</div> </div>
<div className="content"> <div className="content">
<div className="user-details"> <div className="user-details">
<div className="user-name">{val.userName}</div> <div className="user-name">{UserName}</div>
<div className="time">{val.creationTime}</div> <div className="time">{val.createdAt}</div>
</div> </div>
{val.userId === currentUser && ( {val.creatorId === currentUser && (
<div className="more-options"> <div className="more-options">
<button <button
className="more-options-button" className="more-options-button"

View File

@ -6,20 +6,18 @@ import { ExpandIcon } from "../../icons/SimulationIcons";
const ThreadChat: React.FC = () => { const ThreadChat: React.FC = () => {
const messages = [ const messages = [
{ {
userName: "user 1", replyId: "user 1",
userId: "1", creatorId: "1",
message: "hello, thread check", createdAt: "hello, thread check",
creationTime: "2 hrs ago", lastUpdatedAt: "2 hrs ago",
idEdited: true, reply: "true",
modifiedTime: "5 mins ago",
}, },
{ {
userName: "user 2", userName: "user 2",
userId: "2", userId: "2",
message: "hello, thread check", message: "hello, thread check",
creationTime: "2 hrs ago", creationTime: "2 hrs ago",
idEdited: true, idEdited: "true",
modifiedTime: "5 mins ago",
}, },
]; ];
@ -44,7 +42,7 @@ const ThreadChat: React.FC = () => {
</div> </div>
<div className="messages-wrapper"> <div className="messages-wrapper">
{messages.map((val, i) => ( {messages.map((val, i) => (
<Messages val={val} i={i} key={val.userId} /> <Messages val={val as Reply} i={i} key={val.userId} />
))} ))}
</div> </div>
<div className="send-message-wrapper"> <div className="send-message-wrapper">

View File

@ -10,7 +10,7 @@ function updateDistanceText(
////////// Updating the Distance Texts of the lines that are affected during drag ////////// ////////// Updating the Distance Texts of the lines that are affected during drag //////////
const DistanceGroup = scene.children.find((child) => child.name === "Distance_Text") as THREE.Group; const DistanceGroup = scene.getObjectByName('Distance_Text') as THREE.Group;
affectedLines.forEach((lineIndex) => { affectedLines.forEach((lineIndex) => {
const mesh = floorPlanGroupLine.current.children[lineIndex] as THREE.Mesh; const mesh = floorPlanGroupLine.current.children[lineIndex] as THREE.Mesh;

View File

@ -10,7 +10,6 @@ function CommentInstance({ comment }: { comment: CommentSchema }) {
const [selectedComment, setSelectedComment] = useState<CommentSchema | null>(null); const [selectedComment, setSelectedComment] = useState<CommentSchema | null>(null);
const [transformMode, setTransformMode] = useState<"translate" | "rotate" | null>(null); const [transformMode, setTransformMode] = useState<"translate" | "rotate" | null>(null);
useEffect(() => { useEffect(() => {
const handleKeyDown = (e: KeyboardEvent) => { const handleKeyDown = (e: KeyboardEvent) => {
const keyCombination = detectModifierKeys(e); const keyCombination = detectModifierKeys(e);
@ -27,6 +26,11 @@ function CommentInstance({ comment }: { comment: CommentSchema }) {
return () => window.removeEventListener("keydown", handleKeyDown); return () => window.removeEventListener("keydown", handleKeyDown);
}, [selectedComment]); }, [selectedComment]);
const commentClicked = () => {
console.log('hii');
setSelectedComment(comment);
}
if (comment.state === 'inactive' || isPlaying) return null; if (comment.state === 'inactive' || isPlaying) return null;
return ( return (
@ -42,21 +46,7 @@ function CommentInstance({ comment }: { comment: CommentSchema }) {
rotation={comment.rotation} rotation={comment.rotation}
className='comments-main-wrapper' className='comments-main-wrapper'
> >
<CommentThreads /> <CommentThreads commentClicked={commentClicked} />
{/* <div
className='outer'
onClick={(e) => {
e.stopPropagation();
setSelectedComment(comment);
console.log("down");
}}
onPointerOver={(e) => {
e.stopPropagation();
}}>
<div>
hii
</div>
</div> */}
</Html> </Html>
{CommentRef.current && transformMode && ( {CommentRef.current && transformMode && (
<TransformControls <TransformControls

View File

@ -6,7 +6,7 @@ function CommentInstances() {
const { comments } = useCommentStore(); const { comments } = useCommentStore();
useEffect(() => { useEffect(() => {
console.log('comments: ', comments); // console.log('comments: ', comments);
}, [comments]) }, [comments])
return ( return (

View File

@ -218,7 +218,7 @@ const MeasurementTool = () => {
sprite sprite
> >
<div> <div>
{startConePosition.distanceTo(endConePosition).toFixed(2)} m {(startConePosition.distanceTo(endConePosition) + (coneSize.height)).toFixed(2)} m
</div> </div>
</Html> </Html>
)} )}

View File

@ -1,22 +1,22 @@
@use "../abstracts/variables" as *; @use "../abstracts/variables" as *;
@use "../abstracts/mixins" as *; @use "../abstracts/mixins" as *;
.comments-main-wrapper{ .comments-main-wrapper {
position: relative; position: relative;
} }
.comments-threads-wrapper { .comments-threads-wrapper {
position: absolute; position: absolute;
top: 0; top: 0;
left: 0; left: 0;
padding: 4px; padding: 4px;
background: var(--background-color); background: var(--background-color);
border-radius: #{$border-radius-large} #{$border-radius-large} #{$border-radius-large} 0; border-radius: #{$border-radius-extra-large} #{$border-radius-extra-large} #{$border-radius-extra-large}
0;
backdrop-filter: blur(12px); backdrop-filter: blur(12px);
z-index: 1000; z-index: 1000;
transform: translateY(-100%); transform: translateY(-100%);
outline: 1px solid var(--border-color); outline: 1px solid var(--border-color);
transition: all 0.2s ease-out;
.comments-threads-container { .comments-threads-container {
display: flex; display: flex;
align-items: start; align-items: start;
@ -39,8 +39,7 @@
align-items: start; align-items: start;
flex-direction: column; flex-direction: column;
overflow: hidden; overflow: hidden;
transition: all 0.2s; transition: all 0.2s ease-in;
.header { .header {
@include flex-center; @include flex-center;
gap: 10px; gap: 10px;