Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Zewed committed Jan 27, 2024
1 parent 30c5f27 commit 1128d36
Show file tree
Hide file tree
Showing 11 changed files with 103 additions and 98 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,51 @@
.message_row_container {
display: flex;
flex-direction: column;
padding-right: Spacings.$spacing05;

.message_row_content {
border-radius: 12px;
width: fit-content;
padding-block: Spacings.$spacing03;
padding-inline: Spacings.$spacing05;
margin-inline: Spacings.$spacing01;
}

.message_header {
padding: Spacings.$spacing02;
}

&.user {
align-self: flex-end;

.message_header {
align-self: flex-end;
display: flex;
gap: Spacings.$spacing02;
align-items: center;
color: Colors.$dark-grey;
}

.message_row_content {
align-self: flex-end;
background-color: Colors.$highlight;
box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.25);
}
}

&.brain {
.message_header {
align-self: flex-start;
display: flex;
justify-content: space-between;
width: 100%;

.left_wrapper {
display: flex;
gap: Spacings.$spacing05;
align-items: center;
}

.copy_button {
visibility: hidden;
}
}

.message_row_content {
Expand All @@ -36,4 +57,12 @@
margin-left: 1px;
}
}

&:hover {
.message_header {
.copy_button {
visibility: visible;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import React from "react";

import Icon from "@/lib/components/ui/Icon/Icon";

import styles from "./MessageRow.module.scss";
import { CopyButton } from "./components/CopyButton";
import { MessageContent } from "./components/MessageContent/MessageContent";
import { QuestionBrain } from "./components/QuestionBrain";
import { QuestionPrompt } from "./components/QuestionPrompt";
import { QuestionBrain } from "./components/QuestionBrain/QuestionBrain";
import { QuestionPrompt } from "./components/QuestionPrompt/QuestionPrompt";
import { useMessageRow } from "./hooks/useMessageRow";

type MessageRowProps = {
Expand Down Expand Up @@ -37,11 +39,23 @@ export const MessageRow = React.forwardRef(
${isUserSpeaker ? styles.user ?? "" : styles.brain ?? ""}
`}
>
<div className={styles.message_header}>
<QuestionBrain brainName={brainName} />
<QuestionPrompt promptName={promptName} />
<CopyButton handleCopy={handleCopy} isCopied={isCopied} />
</div>
{!isUserSpeaker ? (
<div className={styles.message_header}>
<div className={styles.left_wrapper}>
<QuestionBrain brainName={brainName} />
<QuestionPrompt promptName={promptName} />
</div>
<div className={styles.copy_button}>
<CopyButton handleCopy={handleCopy} isCopied={isCopied} />
</div>
</div>
) : (
<div className={styles.message_header}>
<Icon name="user" color="dark-grey" size="normal" />
<span className={styles.me}>Me</span>
</div>
)}
{}
<div ref={ref} className={styles.message_row_content}>
{children ?? (
<MessageContent text={messageContent} isUser={isUserSpeaker} />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FaCheckCircle, FaCopy } from "react-icons/fa";
import Icon from "@/lib/components/ui/Icon/Icon";

type CopyButtonProps = {
handleCopy: () => void;
Expand All @@ -14,6 +14,11 @@ export const CopyButton = ({
onClick={handleCopy}
title={isCopied ? "Copied!" : "Copy to clipboard"}
>
{isCopied ? <FaCheckCircle /> : <FaCopy />}
<Icon
name={isCopied ? "checkCircle" : "copy"}
color={isCopied ? "primary" : "black"}
size="normal"
handleHover={true}
/>
</button>
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@use "@/styles/Colors.module.scss";
@use "@/styles/Spacings.module.scss";

.brain_name_wrapper {
display: flex;
align-items: center;
gap: Spacings.$spacing02;
color: Colors.$primary;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { Fragment } from "react";

import Icon from "@/lib/components/ui/Icon/Icon";

import styles from "./QuestionBrain.module.scss";

type QuestionBrainProps = {
brainName?: string | null;
};
Expand All @@ -11,8 +15,9 @@ export const QuestionBrain = ({
}

return (
<span data-testid="brain-tags" className="text-highlight mb-1 text-xs">
@{brainName}
</span>
<div data-testid="brain-tags" className={styles.brain_name_wrapper}>
<Icon name="brain" color="primary" size="normal" />
<span>{brainName}</span>
</div>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@use "@/styles/Colors.module.scss";
@use "@/styles/Spacings.module.scss";

.prompt_name_wrapper {
display: flex;
align-items: center;
color: Colors.$primary;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { Fragment } from "react";

import Icon from "@/lib/components/ui/Icon/Icon";

import styles from "./QuestionPompt.module.scss";

type QuestionProptProps = {
promptName?: string | null;
};
Expand All @@ -11,8 +15,9 @@ export const QuestionPrompt = ({
}

return (
<span data-testid="prompt-tags" className="text-highlight mb-1 text-xs">
#{promptName}
</span>
<div data-testid="prompt-tags" className={styles.prompt_name_wrapper}>
<Icon name="hastag" color="primary" size="normal" />
<span>{promptName}</span>
</div>
);
};

This file was deleted.

4 changes: 4 additions & 0 deletions frontend/lib/components/ui/Icon/Icon.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
}
}

.dark-grey {
color: Colors.$dark-grey;
}

.primary {
color: Colors.$primary;
}
Expand Down
5 changes: 5 additions & 0 deletions frontend/lib/helpers/iconList.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { AiOutlineLoading3Quarters } from "react-icons/ai";
import { FaCheckCircle, FaRegUserCircle } from "react-icons/fa";
import { IconType } from "react-icons/lib";
import {
LuBrain,
Expand All @@ -8,13 +9,17 @@ import {
LuPlusCircle,
LuSearch,
} from "react-icons/lu";
import { RiHashtag } from "react-icons/ri";

export const iconList: { [name: string]: IconType } = {
add: LuPlusCircle,
brain: LuBrain,
checkCircle: FaCheckCircle,
chevronDown: LuChevronDown,
chevronRight: LuChevronRight,
copy: LuCopy,
hastag: RiHashtag,
loader: AiOutlineLoading3Quarters,
search: LuSearch,
user: FaRegUserCircle,
};
2 changes: 1 addition & 1 deletion frontend/lib/types/Colors.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export type Color = "black" | "primary" | "accent" | "white";
export type Color = "black" | "dark-grey" | "primary" | "accent" | "white";

0 comments on commit 1128d36

Please sign in to comment.