Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 5 additions & 21 deletions app/components/button.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,21 @@
justify-content: center;
padding: 10px;

box-shadow: var(--card-shadow);
cursor: pointer;
transition: all 0.3s ease;
overflow: hidden;
user-select: none;
}

.shadow {
box-shadow: var(--card-shadow);
}

.border {
border: var(--border-in-light);
}

.icon-button:hover {
filter: brightness(0.9);
border-color: var(--primary);
}

Expand All @@ -36,25 +38,7 @@
}
}

@mixin dark-button {
div:not(:global(.no-dark))>.icon-button-icon {
filter: invert(0.5);
}

.icon-button:hover {
filter: brightness(1.2);
}
}

:global(.dark) {
@include dark-button;
}

@media (prefers-color-scheme: dark) {
@include dark-button;
}

.icon-button-text {
margin-left: 5px;
font-size: 12px;
}
}
6 changes: 5 additions & 1 deletion app/components/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,21 @@ export function IconButton(props: {
icon: JSX.Element;
text?: string;
bordered?: boolean;
shadow?: boolean;
className?: string;
title?: string;
}) {
return (
<div
className={
styles["icon-button"] +
` ${props.bordered && styles.border} ${props.className ?? ""}`
` ${props.bordered && styles.border} ${props.shadow && styles.shadow} ${
props.className ?? ""
} clickable`
}
onClick={props.onClick}
title={props.title}
role="button"
>
<div className={styles["icon-button-icon"]}>{props.icon}</div>
{props.text && (
Expand Down
73 changes: 73 additions & 0 deletions app/components/chat-list.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import { useState, useRef, useEffect, useLayoutEffect } from "react";
import DeleteIcon from "../icons/delete.svg";
import styles from "./home.module.scss";

import {
Message,
SubmitKey,
useChatStore,
ChatSession,
BOT_HELLO,
} from "../store";

import Locale from "../locales";
import { isMobileScreen } from "../utils";

export function ChatItem(props: {
onClick?: () => void;
onDelete?: () => void;
title: string;
count: number;
time: string;
selected: boolean;
}) {
return (
<div
className={`${styles["chat-item"]} ${
props.selected && styles["chat-item-selected"]
}`}
onClick={props.onClick}
>
<div className={styles["chat-item-title"]}>{props.title}</div>
<div className={styles["chat-item-info"]}>
<div className={styles["chat-item-count"]}>
{Locale.ChatItem.ChatItemCount(props.count)}
</div>
<div className={styles["chat-item-date"]}>{props.time}</div>
</div>
<div className={styles["chat-item-delete"]} onClick={props.onDelete}>
<DeleteIcon />
</div>
</div>
);
}

export function ChatList() {
const [sessions, selectedIndex, selectSession, removeSession] = useChatStore(
(state) => [
state.sessions,
state.currentSessionIndex,
state.selectSession,
state.removeSession,
],
);

return (
<div className={styles["chat-list"]}>
{sessions.map((item, i) => (
<ChatItem
title={item.topic}
time={item.lastUpdate}
count={item.messages.length}
key={i}
selected={i === selectedIndex}
onClick={() => selectSession(i)}
onDelete={() =>
(!isMobileScreen() || confirm(Locale.Home.DeleteChat)) &&
removeSession(i)
}
/>
))}
</div>
);
}
71 changes: 71 additions & 0 deletions app/components/chat.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
.prompt-toast {
position: absolute;
bottom: -50px;
z-index: 999;
display: flex;
justify-content: center;
width: calc(100% - 40px);

.prompt-toast-inner {
display: flex;
justify-content: center;
align-items: center;
font-size: 12px;
background-color: var(--white);
color: var(--black);

border: var(--border-in-light);
box-shadow: var(--card-shadow);
padding: 10px 20px;
border-radius: 100px;

.prompt-toast-content {
margin-left: 10px;
}
}
}

.context-prompt {
.context-prompt-row {
display: flex;
justify-content: center;
width: 100%;
margin-bottom: 10px;

.context-role {
margin-right: 10px;
}

.context-content {
flex: 1;
max-width: 100%;
text-align: left;
}

.context-delete-button {
margin-left: 10px;
}
}

.context-prompt-button {
flex: 1;
}
}

.memory-prompt {
margin-top: 20px;

.memory-prompt-title {
font-size: 12px;
font-weight: bold;
margin-bottom: 10px;
}

.memory-prompt-content {
background-color: var(--gray);
border-radius: 6px;
padding: 10px;
font-size: 12px;
user-select: text;
}
}
Loading