Skip to content

Commit 4896ad2

Browse files
Merge pull request #28 from developerfred/z-index-improve
feat(z-index): add Z-Index Hierarchy
2 parents ae66a7d + b279340 commit 4896ad2

File tree

6 files changed

+93
-13
lines changed

6 files changed

+93
-13
lines changed

src/app/globals.css

Lines changed: 74 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,19 @@
6262
--sidebar-accent-foreground: oklch(0.205 0 0);
6363
--sidebar-border: oklch(0.922 0 0);
6464
--sidebar-ring: oklch(0.708 0 0);
65+
66+
--z-index-base: 1;
67+
--z-index-content: 10;
68+
--z-index-monaco-editor: 20;
69+
--z-index-monaco-widgets: 1000;
70+
--z-index-floating-ui: 50;
71+
--z-index-overlay: 100;
72+
--z-index-modal: 200;
73+
--z-index-popover: 300;
74+
--z-index-toast: 400;
75+
--z-index-tooltip: 500;
76+
--z-index-network-indicator: 50;
77+
--z-index-mobile-nav: 1001;
6578
}
6679

6780
[data-theme="dark"] {
@@ -287,6 +300,17 @@ body {
287300
.card-compact {
288301
padding: 12px !important;
289302
}
303+
304+
.monaco-editor .suggest-widget,
305+
.monaco-editor .monaco-hover,
306+
.monaco-editor .parameter-hints-widget {
307+
z-index: calc(var(--z-index-monaco-widgets) + 100) !important;
308+
}
309+
310+
311+
.mobile-sidebar {
312+
z-index: var(--z-index-mobile-nav);
313+
}
290314
}
291315

292316
@theme inline {
@@ -373,43 +397,86 @@ body {
373397

374398

375399
.monaco-editor .suggest-widget {
376-
z-index: 1000 !important;
400+
z-index: var(--z-index-monaco-widgets) !important;
377401
}
378402

379403
.monaco-editor .monaco-hover {
380-
z-index: 1000 !important;
404+
z-index: var(--z-index-monaco-widgets) !important;
381405
}
382406

383407
.monaco-editor .parameter-hints-widget {
384-
z-index: 1000 !important;
408+
z-index: var(--z-index-monaco-widgets) !important;
385409
}
386410

387411

388412
.monaco-editor {
389413
position: relative;
390-
z-index: 10;
414+
z-index: var(--z-index-monaco-editor);
391415
}
392416

393417

394418
.live-preview-container {
395419
pointer-events: auto;
396420
position: relative;
397-
z-index: 1;
421+
z-index: var(--z-index-content);
398422
}
399423

400424

401425
.editor-container {
402426
position: relative;
403-
z-index: 10;
427+
z-index: var(--z-index-monaco-editor);
428+
isolation: isolate;
429+
404430
}
405431

406432
.preview-container {
407433
position: relative;
408-
z-index: 1;
434+
z-index: var(--z-index-content);
409435
}
410436

411437

412438
.monaco-editor-container,
413439
.preview-container {
414440
transition: width 0.3s ease-in-out;
441+
}
442+
443+
.console-output-panel {
444+
position: relative;
445+
z-index: var(--z-index-content);
446+
}
447+
448+
.console-output-toggle {
449+
position: relative;
450+
z-index: var(--z-index-content);
451+
}
452+
453+
.loading-indicator-overlay {
454+
z-index: var(--z-index-overlay);
455+
}
456+
457+
.tooltip {
458+
z-index: var(--z-index-tooltip);
459+
}
460+
461+
.popover {
462+
z-index: var(--z-index-popover);
463+
}
464+
465+
.mobile-sidebar-toggle {
466+
z-index: var(--z-index-mobile-nav);
467+
}
468+
469+
.network-indicator {
470+
position: fixed;
471+
top: 0;
472+
left: 0;
473+
right: 0;
474+
z-index: var(--z-index-network-indicator);
475+
}
476+
477+
.dashboard-header {
478+
position: sticky;
479+
top: 0;
480+
z-index: var(--z-index-overlay);
481+
backdrop-filter: blur(8px);
415482
}

src/components/Console.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,15 @@ export default function Console({ outputs, onClear }: ConsoleProps) {
126126
);
127127

128128
return (
129-
<Card header={consoleHeader} className="h-1/2 min-h-[220px] flex flex-col">
129+
<Card header={consoleHeader} className="h-1/2 min-h-[220px] flex flex-col" style={{ position: "relative", zIndex: "var(--z-index-content)" }}>
130130
<div
131131
ref={consoleRef}
132132
className="flex-1 font-mono text-sm overflow-y-auto -mt-2 -mb-2 p-2"
133133
style={{
134134
backgroundColor: getColor("surface"),
135135
borderRadius: "4px",
136+
position: "relative",
137+
zIndex: "var(--z-index-content)"
136138
}}
137139
>
138140
{outputs.length === 0 ? (

src/components/LivePreview/LivePreviewContainer.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,14 @@ const LivePreviewContainer: React.FC<LivePreviewContainerProps> = ({
3333
className={`relative h-full ${className}`}
3434
style={{
3535

36-
zIndex: 1,
36+
zIndex: "var(--z-index-content)",
3737
padding: "12px",
3838
width: "100%",
3939
height: "100%",
4040
backgroundColor: getColor("surface"),
4141
borderRadius: "8px",
42-
boxShadow: "inset 0 0 5px rgba(0,0,0,0.05)"
42+
boxShadow: "inset 0 0 5px rgba(0,0,0,0.05)",
43+
position: "relative"
4344
}}
4445
>
4546
<LivePreview

src/components/Playground/ConsoleOutputToggle.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import React from "react";
1+
import type React from "react";
22
import { ChevronDown, ChevronUp } from "lucide-react";
33

44
interface ConsoleOutputToggleProps {
55
isCodeOutputVisible: boolean;
66
toggleCodeOutputVisibility: () => void;
7+
style?: { position: string; zIndex: string; };
78
}
89

910
const ConsoleOutputToggle: React.FC<ConsoleOutputToggleProps> = ({
@@ -18,6 +19,10 @@ const ConsoleOutputToggle: React.FC<ConsoleOutputToggleProps> = ({
1819
bg-surface
1920
network-transition group"
2021
onClick={toggleCodeOutputVisibility}
22+
style={{
23+
position: "relative",
24+
zIndex: "var(--z-index-content)"
25+
}}
2126
>
2227
<div className="flex items-center gap-2">
2328
<span className="text-sm font-medium text-theme-secondary">

src/components/Playground/Main.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,12 @@ export default function Main({
8686
<ConsoleOutputToggle
8787
isCodeOutputVisible={isCodeOutputVisible}
8888
toggleCodeOutputVisibility={toggleCodeOutputVisibility}
89+
style={{ position: "relative", zIndex: "var(--z-index-content)" }}
8990
/>
9091
{isCodeOutputVisible && (
92+
<div style={{ position: "relative", zIndex: "var(--z-index-content)" }}>
9193
<Console outputs={outputs} onClear={clearOutput} />
94+
</div>
9295
)}
9396
</>
9497
);
@@ -143,7 +146,8 @@ export default function Main({
143146
style={{
144147
transition: "width 0.3s ease",
145148
position: "relative",
146-
zIndex: 10
149+
zIndex: "var(--z-index-monaco-editor)",
150+
isolation: "isolate"
147151
}}
148152
>
149153
<div
@@ -175,7 +179,7 @@ export default function Main({
175179
transition: "width 0.3s ease",
176180
borderColor: getColor("border"),
177181
position: "relative",
178-
zIndex: 1
182+
zIndex: "var(--z-index-content)"
179183
}}
180184
>
181185
<div className="flex-grow overflow-auto">

src/components/ui/Card.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ interface CardProps {
1010
bordered?: boolean;
1111
header?: ReactNode;
1212
footer?: ReactNode;
13+
style?: { position: string, zIndex: string};
1314
}
1415

1516
export default function Card({

0 commit comments

Comments
 (0)