DocHub/frontend/src/styles.css
Tianyang 39761b4ce7 fix: lock sidebar width and add rendered markdown preview
Sidebar overflowed horizontally on long file/folder names, which broke
vertical scrolling too — locked width with min/max-width plus
overflow-x: hidden, and truncate folder names with ellipsis.

Documents now open in a rendered preview (marked + DOMPurify) by
default, with an 编辑/预览 toggle to switch to the CodeMirror source view.
2026-08-01 18:30:50 +08:00

767 lines
12 KiB
CSS

:root {
--paper: #faf9f6;
--paper-alt: #f1efe6;
--ink: #1b1b18;
--ash: #86847c;
--ash-faint: #b3b0a5;
--rule: #e4e1d8;
--pine: #2f5d50;
--pine-deep: #234840;
--pine-soft: #e7efec;
--amber: #e8a33d;
--amber-soft: #fbead0;
--radius: 6px;
--shadow: 0 12px 36px rgba(27, 27, 24, 0.1);
}
* {
box-sizing: border-box;
}
@media (prefers-reduced-motion: reduce) {
*,
*::before,
*::after {
animation-duration: 0.01ms !important;
transition-duration: 0.01ms !important;
}
}
html,
body,
#root {
height: 100%;
}
body {
margin: 0;
font-family: 'Inter', -apple-system, 'PingFang SC', sans-serif;
background: var(--paper);
color: var(--ink);
font-size: 13px;
}
.serif {
font-family: 'Fraunces', serif;
}
.mono {
font-family: 'IBM Plex Mono', Consolas, monospace;
}
.catalog-tag {
font-family: 'IBM Plex Mono', monospace;
font-size: 10.5px;
color: var(--pine);
background: var(--pine-soft);
border: 1px solid rgba(47, 93, 80, 0.18);
border-radius: 4px;
padding: 1px 6px;
white-space: nowrap;
letter-spacing: 0.02em;
flex-shrink: 0;
}
.app {
height: 100vh;
display: flex;
flex-direction: column;
}
/* ---------- Top bar ---------- */
.topbar {
height: 58px;
background: var(--paper);
border-bottom: 1px solid var(--rule);
display: flex;
align-items: center;
padding: 0 22px;
gap: 22px;
flex-shrink: 0;
}
.wordmark {
font-family: 'Fraunces', serif;
font-style: italic;
font-weight: 600;
font-size: 19px;
color: var(--ink);
white-space: nowrap;
display: flex;
align-items: baseline;
gap: 8px;
margin: 0;
}
.wordmark .subtitle {
font-family: 'IBM Plex Mono', monospace;
font-style: normal;
font-size: 10px;
color: var(--ash);
letter-spacing: 0.06em;
text-transform: uppercase;
}
.search-box {
flex: 1;
max-width: 540px;
position: relative;
}
.search-box input {
width: 100%;
background: var(--paper-alt);
border: 1px solid var(--rule);
border-radius: var(--radius);
color: var(--ink);
padding: 9px 14px 9px 38px;
font-size: 13px;
font-family: 'Inter', sans-serif;
outline: none;
transition: border-color 0.15s, background 0.15s;
}
.search-box input::placeholder {
color: var(--ash-faint);
font-family: 'IBM Plex Mono', monospace;
font-size: 12px;
}
.search-box input:focus {
border-color: var(--pine);
background: var(--paper);
box-shadow: 0 0 0 3px var(--pine-soft);
}
.search-box svg {
position: absolute;
left: 13px;
top: 50%;
transform: translateY(-50%);
color: var(--ash);
pointer-events: none;
}
.upload-btn {
margin-left: auto;
background: var(--pine);
color: #fff;
border: none;
border-radius: var(--radius);
padding: 9px 16px;
font-size: 12.5px;
font-weight: 500;
font-family: 'Inter', sans-serif;
cursor: pointer;
white-space: nowrap;
display: flex;
align-items: center;
gap: 7px;
transition: background 0.15s;
}
.upload-btn:hover {
background: var(--pine-deep);
}
.reindex-control {
display: flex;
align-items: center;
gap: 8px;
}
.reindex-message {
font-family: 'IBM Plex Mono', monospace;
font-size: 11px;
color: var(--ash);
white-space: nowrap;
}
.reindex-message.error {
color: #b3432f;
}
/* ---------- Body layout ---------- */
.body {
flex: 1;
display: flex;
overflow: hidden;
position: relative;
}
/* ---------- Sidebar ---------- */
.sidebar {
width: 272px;
min-width: 272px;
max-width: 272px;
background: var(--paper-alt);
border-right: 1px solid var(--rule);
overflow-y: auto;
overflow-x: hidden;
padding: 16px 10px;
flex-shrink: 0;
}
.sidebar-title {
font-family: 'Fraunces', serif;
font-size: 13px;
font-weight: 600;
color: var(--ink);
padding: 4px 10px 12px;
display: flex;
align-items: baseline;
justify-content: space-between;
}
.sidebar-title .count {
font-family: 'IBM Plex Mono', monospace;
color: var(--ash);
font-size: 11px;
font-weight: 400;
}
.tree-item {
display: flex;
align-items: center;
gap: 7px;
padding: 7px 10px;
font-size: 13px;
cursor: pointer;
color: var(--ink);
white-space: nowrap;
border-radius: 5px;
user-select: none;
min-width: 0;
}
.tree-item .foldername {
flex: 1;
overflow: hidden;
text-overflow: ellipsis;
}
.tree-item:hover {
background: rgba(27, 27, 24, 0.045);
}
.tree-item.file-row.active {
background: #fff;
box-shadow: 0 0 0 1px var(--rule);
font-weight: 500;
}
.tree-item.folder {
color: var(--ash);
font-weight: 500;
font-size: 11.5px;
letter-spacing: 0.03em;
text-transform: uppercase;
}
.tree-children {
overflow: hidden;
padding-left: 14px;
}
.chevron {
display: inline-flex;
transition: transform 0.15s ease;
color: var(--ash-faint);
flex-shrink: 0;
}
.chevron.open {
transform: rotate(90deg);
}
.file-row {
padding-left: 20px;
}
.file-row .filename {
flex: 1;
overflow: hidden;
text-overflow: ellipsis;
}
.file-icon {
color: var(--ash);
flex-shrink: 0;
}
/* ---------- Main ---------- */
.main {
flex: 1;
display: flex;
flex-direction: column;
min-width: 0;
}
.empty-state {
flex: 1;
display: flex;
align-items: center;
justify-content: center;
color: var(--ash-faint);
font-family: 'Fraunces', serif;
font-size: 15px;
}
.doc-header {
height: 54px;
background: var(--paper);
border-bottom: 1px solid var(--rule);
display: flex;
align-items: center;
padding: 0 24px;
gap: 12px;
flex-shrink: 0;
}
.doc-path {
color: var(--ash);
font-size: 12.5px;
display: flex;
align-items: center;
gap: 6px;
}
.doc-path .sep {
color: var(--ash-faint);
}
.doc-path .current {
color: var(--ink);
font-weight: 500;
}
.doc-actions {
margin-left: auto;
display: flex;
gap: 8px;
align-items: center;
}
.save-status {
font-family: 'IBM Plex Mono', monospace;
font-size: 11px;
color: var(--ash-faint);
margin-right: 6px;
display: flex;
align-items: center;
gap: 5px;
}
.save-status .dot {
width: 6px;
height: 6px;
border-radius: 50%;
background: var(--ash-faint);
}
.save-status.dirty {
color: #a9762a;
}
.save-status.dirty .dot {
background: var(--amber);
}
.save-status.saved {
color: var(--pine);
}
.save-status.saved .dot {
background: var(--pine);
}
.save-error {
font-size: 11.5px;
color: #a9401f;
display: flex;
align-items: center;
gap: 4px;
}
.save-error button {
background: none;
border: none;
color: inherit;
cursor: pointer;
font-size: 13px;
line-height: 1;
padding: 0;
}
.btn-save {
background: var(--pine);
color: #fff;
border: none;
border-radius: 5px;
padding: 7px 15px;
font-size: 12px;
font-weight: 500;
font-family: 'Inter', sans-serif;
cursor: pointer;
transition: background 0.15s;
}
.btn-save:hover {
background: var(--pine-deep);
}
.btn-save:disabled {
background: var(--ash-faint);
cursor: default;
}
.btn-secondary {
background: transparent;
color: var(--ash);
border: 1px solid var(--rule);
border-radius: 5px;
padding: 7px 15px;
font-size: 12px;
font-family: 'Inter', sans-serif;
cursor: pointer;
}
.btn-secondary:hover {
background: var(--paper-alt);
}
.editor-area {
flex: 1;
display: flex;
overflow: hidden;
background: var(--paper);
}
.editor-area > div {
flex: 1;
min-width: 0;
}
.editor-area .cm-editor {
height: 100%;
}
.image-preview-area {
flex: 1;
display: flex;
align-items: center;
justify-content: center;
overflow: auto;
background: var(--paper);
padding: 24px;
}
.image-preview-area img {
max-width: 100%;
max-height: 100%;
object-fit: contain;
box-shadow: var(--shadow);
border-radius: var(--radius);
}
.preview-area {
flex: 1;
overflow-y: auto;
background: var(--paper);
padding: 32px 40px;
}
.markdown-preview {
max-width: 720px;
margin: 0 auto;
color: var(--ink);
line-height: 1.7;
font-size: 14px;
}
.markdown-preview h1,
.markdown-preview h2,
.markdown-preview h3,
.markdown-preview h4 {
font-family: 'Fraunces', serif;
font-weight: 600;
color: var(--ink);
margin: 1.4em 0 0.6em;
}
.markdown-preview h1 {
font-size: 26px;
}
.markdown-preview h2 {
font-size: 21px;
}
.markdown-preview h3 {
font-size: 17px;
}
.markdown-preview p {
margin: 0.8em 0;
}
.markdown-preview a {
color: var(--pine);
}
.markdown-preview code {
font-family: 'IBM Plex Mono', monospace;
font-size: 12.5px;
background: var(--paper-alt);
padding: 2px 5px;
border-radius: 4px;
}
.markdown-preview pre {
background: var(--paper-alt);
border: 1px solid var(--rule);
border-radius: var(--radius);
padding: 14px 16px;
overflow-x: auto;
}
.markdown-preview pre code {
background: none;
padding: 0;
}
.markdown-preview ul,
.markdown-preview ol {
padding-left: 1.6em;
margin: 0.8em 0;
}
.markdown-preview blockquote {
border-left: 3px solid var(--rule);
color: var(--ash);
margin: 0.8em 0;
padding: 2px 0 2px 16px;
}
.markdown-preview img {
max-width: 100%;
border-radius: var(--radius);
}
.markdown-preview table {
border-collapse: collapse;
width: 100%;
margin: 0.8em 0;
}
.markdown-preview th,
.markdown-preview td {
border: 1px solid var(--rule);
padding: 6px 10px;
text-align: left;
}
/* ---------- Search overlay ---------- */
.search-overlay {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: var(--paper);
z-index: 10;
overflow-y: auto;
}
.search-results-header {
padding: 24px 30px 12px;
color: var(--ash);
font-size: 12.5px;
border-bottom: 1px solid var(--rule);
display: flex;
align-items: baseline;
gap: 8px;
}
.search-results-header .big-count {
font-family: 'Fraunces', serif;
font-size: 18px;
font-weight: 600;
color: var(--ink);
}
.result-item {
padding: 16px 30px;
border-bottom: 1px solid var(--rule);
cursor: pointer;
transition: background 0.1s;
display: flex;
gap: 12px;
}
.result-item:hover {
background: var(--paper-alt);
}
.result-body {
flex: 1;
min-width: 0;
}
.result-path {
font-size: 12px;
color: var(--ash);
margin-bottom: 6px;
display: flex;
align-items: center;
gap: 8px;
}
.result-title {
font-family: 'Fraunces', serif;
font-weight: 600;
color: var(--ink);
}
.result-snippet {
font-size: 12.5px;
color: var(--ash);
line-height: 1.65;
}
.result-snippet em {
background: var(--amber-soft);
color: #8a5a12;
padding: 0 2px;
border-radius: 2px;
font-weight: 600;
font-style: normal;
}
.no-results {
padding: 60px 30px;
text-align: center;
color: var(--ash-faint);
font-size: 13px;
}
.no-results .serif {
display: block;
font-size: 16px;
color: var(--ash);
margin-bottom: 6px;
}
/* ---------- Status bar ---------- */
.statusbar {
height: 28px;
background: var(--paper-alt);
border-top: 1px solid var(--rule);
color: var(--ash);
font-family: 'IBM Plex Mono', monospace;
font-size: 10.5px;
display: flex;
align-items: center;
padding: 0 18px;
gap: 18px;
flex-shrink: 0;
}
/* ---------- Upload modal ---------- */
.modal-backdrop {
position: fixed;
inset: 0;
background: rgba(27, 27, 24, 0.32);
display: flex;
align-items: center;
justify-content: center;
z-index: 100;
}
.modal {
background: var(--paper);
border-radius: 10px;
width: 460px;
box-shadow: var(--shadow);
overflow: hidden;
}
.modal-header {
padding: 18px 22px;
border-bottom: 1px solid var(--rule);
display: flex;
align-items: center;
justify-content: space-between;
}
.modal-header h3 {
margin: 0;
font-family: 'Fraunces', serif;
font-size: 16px;
font-weight: 600;
}
.modal-close {
background: none;
border: none;
color: var(--ash);
cursor: pointer;
padding: 4px;
display: flex;
}
.modal-body {
padding: 22px;
}
.dropzone {
border: 1.5px dashed var(--rule);
border-radius: var(--radius);
padding: 36px 20px;
text-align: center;
color: var(--ash);
font-size: 12.5px;
transition: all 0.15s;
cursor: pointer;
}
.dropzone.dragover {
border-color: var(--pine);
background: var(--pine-soft);
color: var(--pine-deep);
}
.dropzone svg {
display: block;
margin: 0 auto 12px;
color: var(--ash-faint);
}
.dropzone.dragover svg {
color: var(--pine);
}
.dropzone .hint {
font-family: 'IBM Plex Mono', monospace;
font-size: 10.5px;
color: var(--ash-faint);
margin-top: 4px;
}
.upload-error {
margin-top: 12px;
padding: 10px 12px;
background: #fdece6;
color: #a9401f;
border-radius: 5px;
font-size: 12px;
}
.modal-footer {
padding: 14px 22px;
border-top: 1px solid var(--rule);
display: flex;
justify-content: flex-end;
gap: 8px;
}