Fix student questions pages: CSS tokens, scroll, upload guard, S3 path
- Replace non-existent --surface/--surface-muted/--border-strong with actual design-system tokens (--color-surface, --background, --foreground, --muted) - Remove tmp/ segment from S3 upload key in question-upload route - Add auto-scroll to bottom on new message in QuestionThread - Block Send while file upload is in progress (uploading guard) - Replace <a> with Next.js <Link> in new question page back-link - Replace hardcoded #c00 error color with var(--destructive) in both files - Replace hardcoded #E8E8E0/#F5F5F0 hex backgrounds with CSS tokens
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { useState, useRef } from "react";
|
||||
import { useState, useRef, useEffect } from "react";
|
||||
|
||||
interface FileAttachment {
|
||||
name: string;
|
||||
@@ -53,6 +53,11 @@ export function QuestionThread({
|
||||
const [sending, setSending] = useState(false);
|
||||
const [error, setError] = useState("");
|
||||
const fileInputRef = useRef<HTMLInputElement>(null);
|
||||
const messagesEndRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
useEffect(() => {
|
||||
messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
|
||||
}, [messages]);
|
||||
|
||||
async function handleFileSelect(e: React.ChangeEvent<HTMLInputElement>) {
|
||||
const selected = Array.from(e.target.files ?? []);
|
||||
@@ -82,6 +87,7 @@ export function QuestionThread({
|
||||
}
|
||||
|
||||
async function handleSend() {
|
||||
if (uploading) return;
|
||||
if (!text.trim() && files.length === 0) return;
|
||||
setSending(true);
|
||||
setError("");
|
||||
@@ -120,7 +126,7 @@ export function QuestionThread({
|
||||
className="max-w-[88%] px-3 py-2 rounded-sm text-sm"
|
||||
style={{
|
||||
alignSelf: isMine ? "flex-end" : "flex-start",
|
||||
background: isMine ? "#E8E8E0" : "#F5F5F0",
|
||||
background: isMine ? "var(--muted)" : "var(--background)",
|
||||
border: isMine ? "none" : `2px solid #E8F0D8`,
|
||||
borderLeft: !isMine && isNew ? "3px solid #323232" : undefined,
|
||||
}}
|
||||
@@ -145,7 +151,7 @@ export function QuestionThread({
|
||||
rel="noreferrer"
|
||||
className="flex items-center gap-1.5 text-xs px-2 py-1 rounded-sm"
|
||||
style={{
|
||||
background: "#F5F5F0",
|
||||
background: "var(--background)",
|
||||
border: "1px solid #AAAAAA",
|
||||
color: "var(--foreground)",
|
||||
width: "fit-content",
|
||||
@@ -160,6 +166,7 @@ export function QuestionThread({
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
<div ref={messagesEndRef} />
|
||||
</div>
|
||||
|
||||
{/* Queued files preview */}
|
||||
@@ -169,7 +176,7 @@ export function QuestionThread({
|
||||
<div
|
||||
key={i}
|
||||
className="flex items-center gap-1 text-xs px-2 py-1 rounded-sm"
|
||||
style={{ background: "var(--surface)", border: "1px solid var(--border)" }}
|
||||
style={{ background: "var(--color-surface)", border: "1px solid var(--border)" }}
|
||||
>
|
||||
📎 {f.name}
|
||||
<button
|
||||
@@ -189,7 +196,7 @@ export function QuestionThread({
|
||||
className="rounded-sm p-2"
|
||||
style={{
|
||||
border: "2px solid #AAAAAA",
|
||||
background: "var(--surface)",
|
||||
background: "var(--color-surface)",
|
||||
opacity: questionStatus === "CLOSED" ? 0.5 : 1,
|
||||
pointerEvents: questionStatus === "CLOSED" ? "none" : "auto",
|
||||
}}
|
||||
@@ -205,7 +212,7 @@ export function QuestionThread({
|
||||
/>
|
||||
<div
|
||||
className="flex items-center justify-between pt-2 mt-1"
|
||||
style={{ borderTop: "1px solid #E8E8E0" }}
|
||||
style={{ borderTop: "1px solid var(--muted)" }}
|
||||
>
|
||||
<div className="flex items-center gap-2">
|
||||
<input
|
||||
@@ -221,7 +228,7 @@ export function QuestionThread({
|
||||
onClick={() => fileInputRef.current?.click()}
|
||||
disabled={uploading}
|
||||
className="text-xs px-2 py-1 rounded-sm"
|
||||
style={{ background: "var(--surface)", border: "1px solid #AAAAAA" }}
|
||||
style={{ background: "var(--color-surface)", border: "1px solid #AAAAAA" }}
|
||||
>
|
||||
{uploading ? "Загрузка..." : "📎 Прикрепить"}
|
||||
</button>
|
||||
@@ -245,7 +252,7 @@ export function QuestionThread({
|
||||
</button>
|
||||
</div>
|
||||
{error && (
|
||||
<p className="text-xs mt-1" style={{ color: "#c00" }}>
|
||||
<p className="text-xs mt-1" style={{ color: "var(--destructive)" }}>
|
||||
{error}
|
||||
</p>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user