coingimp's picture
Add code editor (CodeMirror) + live preview tabs
821bd2a verified
Raw
History Blame Contribute Delete
7.04 kB
:root {
--bg: #f7f8fb;
--panel: #ffffff;
--text: #17202a;
--muted: #667085;
--line: #d9dee7;
--primary: #2454d6;
--primary-dark: #183a9e;
--accent: #d64b35;
--shadow: 0 18px 50px rgba(31, 41, 55, 0.08);
}
* { box-sizing: border-box; }
body {
margin: 0;
min-height: 100vh;
background: var(--bg);
color: var(--text);
font-family: Inter, Arial, sans-serif;
}
.shell {
min-height: 100vh;
padding: 28px;
}
.workspace {
max-width: 1240px;
margin: 0 auto;
}
.topbar {
display: flex;
justify-content: space-between;
gap: 20px;
align-items: flex-start;
margin-bottom: 22px;
}
.eyebrow {
color: var(--muted);
font-size: 13px;
text-transform: uppercase;
letter-spacing: 0;
margin: 0 0 6px;
}
h1, h2 {
letter-spacing: 0;
margin: 0;
}
h1 {
font-size: clamp(30px, 4vw, 48px);
line-height: 1.05;
}
h2 {
font-size: 18px;
}
.status {
min-width: 120px;
padding: 10px 14px;
border: 1px solid var(--line);
border-radius: 999px;
color: var(--muted);
text-align: center;
background: #fff;
}
.builder {
display: grid;
grid-template-columns: minmax(0, 1.1fr) minmax(340px, 0.9fr);
gap: 18px;
align-items: start;
}
.panel, .results, .preview-panel {
background: var(--panel);
border: 1px solid var(--line);
border-radius: 8px;
box-shadow: var(--shadow);
padding: 22px;
}
.panel-head {
display: flex;
justify-content: space-between;
gap: 14px;
align-items: center;
margin-bottom: 18px;
}
.panel-head span {
color: var(--muted);
font-size: 13px;
}
label {
display: grid;
gap: 7px;
color: #344054;
font-size: 14px;
font-weight: 700;
margin-bottom: 14px;
}
input, select, textarea {
width: 100%;
border: 1px solid var(--line);
border-radius: 6px;
background: #fff;
color: var(--text);
font: inherit;
padding: 11px 12px;
outline: none;
}
input:focus, select:focus, textarea:focus {
border-color: var(--primary);
box-shadow: 0 0 0 3px rgba(36, 84, 214, 0.14);
}
textarea {
min-height: 340px;
resize: vertical;
font-family: Consolas, "Courier New", monospace;
line-height: 1.45;
}
.compact textarea {
min-height: 118px;
}
.grid-2 {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 12px;
}
.checkline {
grid-template-columns: 18px 1fr;
align-items: center;
font-weight: 600;
}
.checkline input {
width: 18px;
height: 18px;
}
.field-help {
margin: -6px 0 14px;
color: var(--muted);
font-size: 13px;
line-height: 1.45;
}
.field-help code {
color: var(--text);
background: #eef2ff;
border: 1px solid var(--line);
border-radius: 4px;
padding: 1px 4px;
}
.primary {
width: 100%;
min-height: 48px;
border: 0;
border-radius: 6px;
background: var(--primary);
color: #fff;
font-size: 15px;
font-weight: 800;
cursor: pointer;
}
.primary:hover { background: var(--primary-dark); }
.primary:disabled { cursor: wait; opacity: 0.68; }
.results {
margin-top: 18px;
}
.preview-panel {
margin-top: 18px;
}
.preview-note {
margin: 6px 0 0;
color: var(--muted);
font-size: 13px;
font-weight: 500;
}
.approve {
min-height: 40px;
border: 0;
border-radius: 6px;
padding: 9px 14px;
background: var(--accent);
color: #fff;
font-weight: 800;
cursor: pointer;
}
.approve:disabled {
opacity: 0.65;
cursor: wait;
}
.preview-layout {
display: grid;
grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
gap: 14px;
min-height: 620px;
}
.preview-list {
border: 1px solid var(--line);
border-radius: 6px;
background: #fbfcff;
padding: 10px;
overflow: auto;
}
.preview-page {
display: block;
width: 100%;
border: 1px solid transparent;
border-radius: 6px;
background: transparent;
color: var(--text);
cursor: pointer;
font: inherit;
font-size: 13px;
font-weight: 700;
line-height: 1.35;
margin: 0 0 8px;
padding: 10px;
text-align: left;
overflow-wrap: anywhere;
}
.preview-page:hover,
.preview-page.active {
border-color: color-mix(in srgb, var(--primary) 35%, var(--line));
background: color-mix(in srgb, var(--primary) 8%, white);
color: var(--primary-dark);
}
.preview-frame {
width: 100%;
height: 620px;
border: 1px solid var(--line);
border-radius: 6px;
background: #fff;
}
.downloads {
display: flex;
flex-wrap: wrap;
gap: 10px;
margin-bottom: 14px;
}
.downloads a {
display: inline-flex;
align-items: center;
min-height: 38px;
padding: 8px 12px;
border: 1px solid var(--line);
border-radius: 6px;
color: var(--primary);
text-decoration: none;
font-weight: 800;
background: #fff;
}
pre {
max-height: 320px;
overflow: auto;
margin: 0;
border-radius: 6px;
background: #101828;
color: #ecf2ff;
padding: 14px;
white-space: pre-wrap;
}
@media (max-width: 900px) {
.shell { padding: 18px; }
.topbar, .builder, .grid-2, .preview-layout { grid-template-columns: 1fr; display: grid; }
.status { text-align: left; }
.preview-layout { min-height: auto; }
.preview-frame { height: 520px; }
}
/* === Вкладки Preview / Code Editor === */
.editor-tabs {
display: flex;
gap: 0;
margin-bottom: 0;
border-bottom: 2px solid #2a3142;
}
.tab-btn {
background: transparent;
color: #9ca3af;
border: none;
border-bottom: 3px solid transparent;
padding: 10px 20px;
font-size: 0.95em;
font-weight: 600;
cursor: pointer;
transition: color 0.2s, border-color 0.2s;
}
.tab-btn:hover { color: #e6e6e6; }
.tab-btn.active { color: #60a5fa; border-bottom-color: #60a5fa; }
.tab-content { display: none; }
.tab-content.active { display: grid; }
/* === Code Editor Layout === */
.editor-layout {
grid-template-columns: 220px 1fr;
gap: 0;
min-height: 600px;
background: #0f1419;
border: 1px solid #2a3142;
border-top: 0;
}
.editor-main {
display: flex;
flex-direction: column;
border-left: 1px solid #2a3142;
}
.editor-toolbar {
display: flex;
align-items: center;
gap: 12px;
padding: 10px 16px;
background: #1a1f2e;
border-bottom: 1px solid #2a3142;
font-size: 0.85em;
color: #9ca3af;
}
#editorPageTitle { flex: 1; font-weight: 600; color: #e6e6e6; }
.save-status { font-size: 0.8em; color: #6b7280; }
.save-status.saved { color: #34d399; }
.save-status.dirty { color: #fbbf24; }
.save-btn {
background: #058d28;
color: #fff;
border: none;
border-radius: 4px;
padding: 6px 16px;
font-size: 0.85em;
cursor: pointer;
transition: background 0.2s;
}
.save-btn:hover:not(:disabled) { background: #047621; }
.save-btn:disabled { background: #374151; cursor: not-allowed; }
.editor-area {
flex: 1;
overflow: hidden;
position: relative;
}
#codeEditor {
display: none; /* скрываем textarea, CodeMirror займёт место */
}
/* CodeMirror во всю высоту */
.CodeMirror {
height: 560px !important;
font-family: "Cascadia Code", "Fira Code", "Consolas", monospace;
font-size: 13px;
line-height: 1.5;
}
/* список страниц в редакторе */
#editorPageList .preview-page { font-size: 0.8em; }