Skip to content

Commit 9cae195

Browse files
committed
feat(ui): Autohide command context panel, when needed it floats over the viewport more like AutoCAD
1 parent 524c880 commit 9cae195

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

packages/chili-ui/src/CommandContextPanel.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@ import { CommandContext } from "./ribbon/commandContext";
44
import style from "./ribbon/ribbon.module.css";
55

66
export class CommandContextPanel extends HTMLElement {
7-
private readonly _panel = div({ className: style.commandContextPanel });
7+
private readonly _panel = div({
8+
className: style.commandContextOverlay + " " + style.commandContextOverlayHidden,
9+
});
810
private commandContext?: CommandContext;
11+
private _visible = false;
912

1013
constructor() {
1114
super();
@@ -28,14 +31,25 @@ export class CommandContextPanel extends HTMLElement {
2831
}
2932
this.commandContext = new CommandContext(command);
3033
this._panel.append(this.commandContext);
34+
this.setVisible(true);
3135
};
3236

3337
private readonly closeContext = () => {
3438
this.commandContext?.remove();
3539
this.commandContext?.dispose();
3640
this.commandContext = undefined;
3741
this._panel.innerHTML = "";
42+
this.setVisible(false);
3843
};
44+
45+
private setVisible(visible: boolean) {
46+
this._visible = visible;
47+
if (visible) {
48+
this._panel.className = style.commandContextOverlay;
49+
} else {
50+
this._panel.className = style.commandContextOverlay + " " + style.commandContextOverlayHidden;
51+
}
52+
}
3953
}
4054

4155
customElements.define("command-context-panel", CommandContextPanel);

packages/chili-ui/src/ribbon/ribbon.module.css

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,30 @@
251251
border-bottom: 1px solid var(--border-color);
252252
}
253253

254+
.commandContextOverlay {
255+
position: absolute;
256+
top: 0px;
257+
left: 50%;
258+
transform: translateX(-50%);
259+
max-width: 600px;
260+
min-width: 320px;
261+
width: 60%;
262+
z-index: 10;
263+
background: var(--panel-background-color);
264+
/* Subtle, soft shadow only on bottom and sides */
265+
box-shadow:
266+
0 6px 24px -6px rgba(0, 0, 0, 0.1),
267+
0 2px 8px -2px rgba(0, 0, 0, 0.08);
268+
border-radius: 0 0 12px 12px;
269+
opacity: 1;
270+
transition: opacity 0.2s;
271+
pointer-events: auto;
272+
}
273+
.commandContextOverlayHidden {
274+
opacity: 0;
275+
pointer-events: none;
276+
}
277+
254278
.ribbonGroup {
255279
position: relative;
256280
display: grid;

0 commit comments

Comments
 (0)