style: рестайл интерфейса по принципам Ководства
- дизайн-токены: палитра, шкала отступов, типошкала, focus-ring - состояния hover/active/focus-visible/disabled для всех контролов - активный чат — акцентная полоска слева, тихий кастомный скроллбар - безопасная типографика AI-прозы (м²/м³/×/тире), СТРОГО минуя таблицы и код — шифры расценок не трогаются
This commit is contained in:
+73
-26
@@ -6,22 +6,38 @@
|
||||
<title>Сметный ИИ-ассистент</title>
|
||||
<style>
|
||||
:root {
|
||||
--bg: #f5f0eb; --bg-card: #ffffff; --bg-input: #ffffff;
|
||||
--text: #3a3a3a; --text-muted: #6b6b6b; --text-light: #8b7355;
|
||||
--border: #d4c5b2; --border-light: #ede5db;
|
||||
--accent: #c4463a; --accent-hover: #a83830; --accent-light: rgba(196,70,58,.08);
|
||||
--user-bg: #2c2c2c; --user-text: #ffffff;
|
||||
--ai-bg: #ffffff; --ai-border: #ede5db;
|
||||
--file-bg: #f5f0eb; --file-border: #d4c5b2;
|
||||
--bg: #f4efe9; --bg-card: #ffffff; --bg-input: #ffffff; --bg-sunken: #faf7f3;
|
||||
--text: #2b2926; --text-muted: #6b6258; --text-light: #948a7d;
|
||||
--border: #ddd0bf; --border-light: #ece4d9;
|
||||
--accent: #c0453a; --accent-hover: #a5392f; --accent-active: #8f3128; --accent-light: rgba(192,69,58,.08);
|
||||
--user-bg: #2b2926; --user-text: #fbf9f6;
|
||||
--ai-bg: #ffffff; --ai-border: #ece4d9;
|
||||
--file-bg: #f4efe9; --file-border: #ddd0bf;
|
||||
--error-bg: #fff1f2; --error-border: #fecdd3;
|
||||
--system-bg: #f5f0eb; --system-text: #8b7355;
|
||||
--shadow-sm: 0 1px 3px rgba(0,0,0,.05);
|
||||
--shadow-md: 0 4px 16px rgba(0,0,0,.07);
|
||||
--radius: 10px; --radius-lg: 16px;
|
||||
--system-bg: #efe9e1; --system-text: #847a6d;
|
||||
--ok: #1f6f43; --ok-hover: #18603a;
|
||||
--shadow-sm: 0 1px 2px rgba(43,41,38,.05);
|
||||
--shadow-md: 0 6px 24px rgba(43,41,38,.09);
|
||||
--focus-ring: 0 0 0 3px rgba(192,69,58,.28);
|
||||
--radius-sm: 7px; --radius: 10px; --radius-lg: 16px;
|
||||
/* spacing scale (4px rhythm) */
|
||||
--s1: .25rem; --s2: .5rem; --s3: .75rem; --s4: 1rem; --s5: 1.5rem; --s6: 2rem;
|
||||
}
|
||||
|
||||
* { box-sizing: border-box; margin: 0; padding: 0; }
|
||||
body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: var(--bg); height: 100vh; display: flex; flex-direction: column; color: var(--text); -webkit-font-smoothing: antialiased; }
|
||||
body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif; background: var(--bg); height: 100vh; display: flex; flex-direction: column; color: var(--text); line-height: 1.55; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
|
||||
|
||||
/* Видимый фокус для клавиатуры — Ководство: состояния обязательны */
|
||||
:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius-sm); }
|
||||
button { font-family: inherit; }
|
||||
::selection { background: rgba(192,69,58,.18); }
|
||||
|
||||
/* Тихий скроллбар */
|
||||
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
|
||||
*::-webkit-scrollbar { width: 10px; height: 10px; }
|
||||
*::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; border: 3px solid transparent; background-clip: padding-box; }
|
||||
*::-webkit-scrollbar-thumb:hover { background: var(--text-light); background-clip: padding-box; }
|
||||
*::-webkit-scrollbar-track { background: transparent; }
|
||||
|
||||
/* Login */
|
||||
#login-screen { display: flex; align-items: center; justify-content: center; height: 100vh; background: linear-gradient(135deg, #f5f0eb 0%, #ede5db 100%); }
|
||||
@@ -32,15 +48,17 @@ body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Robo
|
||||
#login-form input:focus { border-color: var(--accent); background: var(--bg-card); }
|
||||
#login-form button { width: 100%; padding: .75rem; background: var(--accent); color: #fff; border: none; border-radius: var(--radius); font-size: .95rem; font-weight: 600; cursor: pointer; transition: background .2s; margin-top: .3rem; }
|
||||
#login-form button:hover { background: var(--accent-hover); }
|
||||
#login-form button:active { background: var(--accent-active); transform: translateY(1px); }
|
||||
#login-error { color: #e03131; font-size: .8rem; margin-bottom: .5rem; display: none; text-align: center; }
|
||||
|
||||
/* Chat */
|
||||
#chat-screen { display: none; flex-direction: column; height: 100vh; }
|
||||
#header { background: var(--bg-card); padding: .7rem 1.2rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; box-shadow: var(--shadow-sm); }
|
||||
#header h1 { font-size: 1rem; font-weight: 600; color: var(--text); letter-spacing: -.01em; }
|
||||
#header { background: var(--bg-card); padding: .6rem 1.4rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; box-shadow: var(--shadow-sm); }
|
||||
#header h1 { font-size: 1rem; font-weight: 650; color: var(--text); letter-spacing: -.012em; }
|
||||
.header-actions { display: flex; gap: .4rem; }
|
||||
.header-actions button { padding: .35rem .75rem; background: transparent; border: 1.5px solid var(--border); border-radius: var(--radius); cursor: pointer; font-size: .78rem; color: var(--text-muted); font-weight: 500; transition: all .15s; }
|
||||
.header-actions button { padding: .38rem .8rem; background: transparent; border: 1.5px solid var(--border); border-radius: var(--radius); cursor: pointer; font-size: .78rem; color: var(--text-muted); font-weight: 500; transition: all .15s; }
|
||||
.header-actions button:hover { background: var(--bg); border-color: var(--accent); color: var(--accent); }
|
||||
.header-actions button:active { transform: translateY(1px); }
|
||||
|
||||
#messages { flex: 1; overflow-y: auto; padding: 1.2rem 1.6rem; display: flex; flex-direction: column; gap: .7rem; width: 100%; }
|
||||
.msg { max-width: 85%; padding: .8rem 1.1rem; border-radius: var(--radius-lg); line-height: 1.6; white-space: pre-wrap; word-break: break-word; font-size: .9rem; box-shadow: var(--shadow-sm); position: relative; }
|
||||
@@ -80,8 +98,9 @@ body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Robo
|
||||
.msg-ai td.num, .msg-ai th.num { white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; }
|
||||
.msg-ai tbody tr:nth-child(even) { background: rgba(0,0,0,.022); }
|
||||
.msg-table-bar { display: flex; justify-content: flex-end; margin: .5rem 0 -.2rem; }
|
||||
.msg-table-bar button { background: #1f6f43; color: #fff; border: none; border-radius: 6px; cursor: pointer; font-size: .72rem; padding: .28rem .7rem; font-weight: 600; transition: background .15s; }
|
||||
.msg-table-bar button:hover { background: #18603a; }
|
||||
.msg-table-bar button { background: var(--ok); color: #fff; border: none; border-radius: var(--radius-sm); cursor: pointer; font-size: .72rem; padding: .3rem .75rem; font-weight: 600; transition: background .15s, transform .05s; }
|
||||
.msg-table-bar button:hover { background: var(--ok-hover); }
|
||||
.msg-table-bar button:active { transform: translateY(1px); }
|
||||
.msg-ai code { background: #f5f0eb; padding: .1rem .3rem; border-radius: 3px; font-size: .85em; font-family: 'SF Mono', Menlo, monospace; }
|
||||
.msg-ai pre { background: #2c2c2c; color: #f5f0eb; padding: .6rem; border-radius: 6px; overflow-x: auto; margin: .4rem 0; }
|
||||
.msg-ai pre code { background: none; padding: 0; color: inherit; }
|
||||
@@ -96,25 +115,31 @@ body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Robo
|
||||
.file-badge { background: #ede5db; color: #2c2c2c; padding: .25rem .6rem; border-radius: 6px; font-size: .75rem; display: flex; align-items: center; gap: .3rem; font-weight: 500; }
|
||||
.file-badge .remove { cursor: pointer; color: #e03131; font-weight: bold; }
|
||||
#input-row { display: flex; gap: .5rem; align-items: flex-end; }
|
||||
#msg-input { flex: 1; padding: .65rem .9rem; border: 1.5px solid var(--border); border-radius: var(--radius); font-size: .95rem; resize: none; min-height: 44px; max-height: 150px; font-family: inherit; outline: none; transition: border-color .2s; background: var(--bg); }
|
||||
#msg-input:focus { border-color: var(--accent); background: var(--bg-card); }
|
||||
#send-btn { padding: .65rem 1.3rem; background: var(--accent); color: #fff; border: none; border-radius: var(--radius); cursor: pointer; font-size: .95rem; font-weight: 600; white-space: nowrap; transition: background .15s; }
|
||||
#msg-input { flex: 1; padding: .65rem .9rem; border: 1.5px solid var(--border); border-radius: var(--radius); font-size: .95rem; resize: none; min-height: 44px; max-height: 150px; font-family: inherit; line-height: 1.5; outline: none; transition: border-color .15s, box-shadow .15s; background: var(--bg-sunken); color: var(--text); }
|
||||
#msg-input::placeholder { color: var(--text-light); }
|
||||
#msg-input:focus { border-color: var(--accent); background: var(--bg-card); box-shadow: var(--focus-ring); }
|
||||
#send-btn { padding: .65rem 1.3rem; background: var(--accent); color: #fff; border: none; border-radius: var(--radius); cursor: pointer; font-size: .95rem; font-weight: 600; white-space: nowrap; transition: background .15s, transform .05s; }
|
||||
#send-btn:hover { background: var(--accent-hover); }
|
||||
#send-btn:disabled { background: #d4c5b2; cursor: not-allowed; }
|
||||
#file-btn { padding: .65rem .7rem; background: var(--bg); border: 1.5px solid var(--border); border-radius: var(--radius); cursor: pointer; font-size: 1.1rem; transition: all .15s; }
|
||||
#send-btn:active { background: var(--accent-active); transform: translateY(1px); }
|
||||
#send-btn:disabled { background: var(--border); color: var(--bg-card); cursor: not-allowed; transform: none; }
|
||||
#file-btn { padding: .65rem .7rem; background: var(--bg-sunken); border: 1.5px solid var(--border); border-radius: var(--radius); cursor: pointer; font-size: 1.1rem; line-height: 1; transition: all .15s; }
|
||||
#file-btn:hover { border-color: var(--accent); background: var(--accent-light); }
|
||||
#file-btn:active { transform: translateY(1px); }
|
||||
|
||||
/* Layout with left chat sidebar (Claude-desktop style) */
|
||||
.app-layout { flex: 1; display: flex; min-height: 0; }
|
||||
.sidebar { width: 264px; flex-shrink: 0; background: var(--bg-card); border-right: 1px solid var(--border); display: flex; flex-direction: column; }
|
||||
.sidebar-head { padding: .7rem; border-bottom: 1px solid var(--border-light); }
|
||||
.new-chat-btn { width: 100%; padding: .6rem; background: var(--accent); color: #fff; border: none; border-radius: var(--radius); font-size: .85rem; font-weight: 600; cursor: pointer; transition: background .15s; }
|
||||
.new-chat-btn { width: 100%; padding: .6rem; background: var(--accent); color: #fff; border: none; border-radius: var(--radius); font-size: .85rem; font-weight: 600; cursor: pointer; transition: background .15s, transform .05s; }
|
||||
.new-chat-btn:hover { background: var(--accent-hover); }
|
||||
.new-chat-btn:active { background: var(--accent-active); transform: translateY(1px); }
|
||||
.chat-list { flex: 1; overflow-y: auto; padding: .4rem; }
|
||||
.chat-list-empty { padding: 1rem .7rem; color: var(--text-muted); font-size: .78rem; text-align: center; }
|
||||
.chat-item { padding: .5rem .65rem; border-radius: 8px; cursor: pointer; margin-bottom: .15rem; border: 1px solid transparent; transition: background .12s; }
|
||||
.chat-item { position: relative; padding: .5rem .65rem .5rem .8rem; border-radius: var(--radius-sm); cursor: pointer; margin-bottom: .1rem; transition: background .12s; }
|
||||
.chat-item:hover { background: var(--bg); }
|
||||
.chat-item.active { background: var(--accent-light); border-color: var(--border); }
|
||||
.chat-item.active { background: var(--accent-light); }
|
||||
.chat-item.active::before { content: ""; position: absolute; left: 0; top: 6px; bottom: 6px; width: 3px; border-radius: 3px; background: var(--accent); }
|
||||
.chat-item.active .ci-title { color: var(--accent); font-weight: 600; }
|
||||
.ci-title { font-size: .82rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
.ci-date { font-size: .66rem; color: var(--text-muted); margin-top: .12rem; }
|
||||
.main-col { flex: 1; display: flex; flex-direction: column; min-width: 0; }
|
||||
@@ -272,6 +297,27 @@ function tableToExcel(table, filename) {
|
||||
setTimeout(() => URL.revokeObjectURL(url), 1000);
|
||||
}
|
||||
|
||||
// Лёгкая типографика прозы AI (Ководство): м²/м³, знак умножения, тире.
|
||||
// СТРОГО минует таблицы и код — там шифры расценок (01-01-001), их дефисы
|
||||
// и числа трогать нельзя. Идемпотентна (² не матчит 2 повторно).
|
||||
const SKIP_TYPO = 'table, code, pre, .msg-table-bar, .msg-time, .copy-btn';
|
||||
function typografAI(root) {
|
||||
const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT, {
|
||||
acceptNode: n => (n.parentElement && n.parentElement.closest(SKIP_TYPO))
|
||||
? NodeFilter.FILTER_REJECT
|
||||
: (n.nodeValue.trim() ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT),
|
||||
});
|
||||
const nodes = [];
|
||||
for (let n = walker.nextNode(); n; n = walker.nextNode()) nodes.push(n);
|
||||
for (const n of nodes) {
|
||||
n.nodeValue = n.nodeValue
|
||||
.replace(/(\d)\s?м2(?![\wа-я²³])/gi, '$1 м²')
|
||||
.replace(/(\d)\s?м3(?![\wа-я²³])/gi, '$1 м³')
|
||||
.replace(/(\d)\s?[xх]\s?(\d)/g, '$1×$2') // 50x100 → 50×100
|
||||
.replace(/ - /g, ' — '); // дефис-разделитель → тире
|
||||
}
|
||||
}
|
||||
|
||||
const API = '';
|
||||
let token = localStorage.getItem('token');
|
||||
let pendingFiles = [];
|
||||
@@ -398,6 +444,7 @@ function addMsg(type, text, ts) {
|
||||
div.innerHTML = renderMarkdown(text);
|
||||
div.prepend(time);
|
||||
enhanceTables(div);
|
||||
typografAI(div);
|
||||
} else {
|
||||
div.textContent = text;
|
||||
div.prepend(time);
|
||||
@@ -669,7 +716,7 @@ async function sendMessage() {
|
||||
}
|
||||
}
|
||||
if (!aiDiv && !aiText) addMsg('ai', '(пустой ответ)');
|
||||
if (aiDiv) enhanceTables(aiDiv); // streaming re-renders innerHTML each chunk → enhance once at the end
|
||||
if (aiDiv) { enhanceTables(aiDiv); typografAI(aiDiv); } // streaming re-renders innerHTML each chunk → finalize once at the end
|
||||
|
||||
} catch (err) {
|
||||
removeTyping();
|
||||
|
||||
Reference in New Issue
Block a user