Skip to content

Commit 351990b

Browse files
author
danil-nizamov
committed
updated dark theme
1 parent 08c10cb commit 351990b

File tree

2 files changed

+80
-14
lines changed

2 files changed

+80
-14
lines changed

diagram.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
// diagram.js
22
const DIAGRAM = { NODE_WIDTH: 240, ROW_H: 22, PADDING_X: 10, HEADER_H: 28, GAP: 8 };
33

4-
/* --- header colors --- */
5-
const TABLE_COLORS = {
6-
white: '#ffffff',
7-
blue: '#eaf2ff',
8-
green: '#e9f8f1',
9-
red: '#ffecec',
10-
};
11-
function getHeaderFill(table) {
12-
const key = (table && table.color) || 'white';
13-
return TABLE_COLORS[key] || TABLE_COLORS.white;
14-
}
4+
/* --- header colors (theme-aware via CSS variables) --- */
5+
const TABLE_COLOR_VARS = {
6+
white: '--tbl-white',
7+
blue: '--tbl-blue',
8+
green: '--tbl-green',
9+
red: '--tbl-red',
10+
};
11+
12+
function getHeaderFill(table) {
13+
const key = (table && table.color) || 'white';
14+
const varName = TABLE_COLOR_VARS[key] || '--tbl-white';
15+
const val = getComputedStyle(document.documentElement).getPropertyValue(varName).trim();
16+
return val || '#ffffff';
17+
}
18+
1519

1620
/* Build a path for a rectangle that has ONLY the top corners rounded */
1721
function roundedTopRectPath(x, y, w, h, rx, ry) {

style.css

Lines changed: 65 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
/* Put these with your other :root vars */
2+
:root {
3+
/* header fills (light) */
4+
--tbl-white: #ffffff;
5+
--tbl-blue: #8eb3f0;
6+
--tbl-green: #bbe5d1;
7+
--tbl-red: #f8caca;
8+
}
9+
10+
@media (prefers-color-scheme: dark) {
11+
:root {
12+
/* darker tints that read well with white text */
13+
--tbl-white: #4a5a7b; /* slate-ish */
14+
--tbl-blue: #0c2658; /* deep blue */
15+
--tbl-green: #07402d; /* deep green */
16+
--tbl-red: #5d1d1d; /* deep red */
17+
}
18+
}
19+
120
/* Variables mapped to the other app’s palette (light) */
221
:root {
322
--bg: #ffffff; /* base background */
@@ -9,6 +28,10 @@
928
--fk: #0ea5e9; /* accent-primary */
1029
--danger: #dc2626; /* error */
1130
--accent: #0ea5e9; /* accent-primary */
31+
--canvas: #f8fafc; /* was hard-coded on #diagram */
32+
--control-bg: #ffffff; /* inputs & buttons bg (light) */
33+
--control-border: #e2e8f0; /* inputs & buttons border (light) */
34+
--fk: #0ea5e9; /* light blue for light theme */
1235
}
1336

1437
/* Dark mode: override only color variables */
@@ -27,6 +50,10 @@
2750
--fk: #38bdf8;
2851
--danger: #ef4444;
2952
--accent: #38bdf8;
53+
--canvas: #1e2640;
54+
--control-bg: #1f2937;
55+
--control-border: #94a3b8;
56+
--fk: #ffffff; /* arrows & markers turn white in dark theme */
3057
}
3158
}
3259

@@ -50,11 +77,11 @@
5077
main.layout{display:grid;grid-template-columns:300px 1fr;height:calc(100% - 50px)}
5178
#diagram-wrap{width:100%;height:100%}
5279

53-
#diagram{background:#f8fafc}
80+
#diagram{ background: var(--canvas); }
5481

5582
aside#sidebar{
5683
padding:10px;overflow:auto;border-right:1px solid var(--stroke);
57-
background:#f8fafc
84+
background: var(--bg);
5885
}
5986
.card{
6087
background:var(--box);
@@ -66,10 +93,41 @@
6693
label{display:flex;flex-direction:column;gap:.25rem;margin:.4rem 0}
6794
label.row{flex-direction:row;align-items:center;gap:.5rem}
6895

69-
input,select,button{padding:.5rem;border:1px solid #e2e8f0;border-radius:6px;font:inherit}
96+
/* Make controls use the tokens in both modes */
97+
input, select, button {
98+
padding: .5rem;
99+
border: 0.5px solid var(--control-border);
100+
border-radius: 6px;
101+
background: var(--control-bg);
102+
color: var(--fg);
103+
font: inherit;
104+
}
70105
input[type="checkbox"]{padding:0}
71106
button{cursor:pointer;border-radius:.5rem}
72107

108+
/* Dark-mode specifics */
109+
@media (prefers-color-scheme: dark) {
110+
/* 1) Sidebar “menus” (cards) should have no border in dark */
111+
.card { border: none; }
112+
113+
/* 2) Buttons should be dark with light-grey border */
114+
button { background: var(--control-bg); border-color: var(--control-border); }
115+
116+
/* Optional: make the danger button less blinding in dark */
117+
button.danger {
118+
background: rgba(239, 68, 68, 0.12);
119+
border-color: rgba(239, 68, 68, 0.45);
120+
color: var(--danger);
121+
}
122+
123+
/* 3) Inputs dark with grey default (placeholder) text */
124+
input::placeholder,
125+
textarea::placeholder {
126+
color: var(--muted);
127+
opacity: 1; /* ensure consistent grey */
128+
}
129+
}
130+
73131
/* Danger button colors mapped to semantic tokens (no layout change) */
74132
button.danger{
75133
background:#fef2f2; /* error-bg */
@@ -81,6 +139,10 @@
81139

82140
text{font-size:12px;fill:var(--fg);dominant-baseline:middle}
83141
.table-title{font-weight:600}
142+
.table-box {
143+
fill: var(--box) !important;
144+
stroke: var(--stroke) !important;
145+
}
84146

85147
.table.selected rect{stroke:var(--accent);stroke-width:2}
86148

0 commit comments

Comments
 (0)