#
Windows
Windows are the core containers of the NidamJS desktop environment.
They provide draggable, focusable, resizable, tileable, and dynamically loaded UI panels — fully managed by the internal WindowManager.
The system is declarative and attribute-driven, requiring little to no manual JavaScript wiring.
#
Quick Start
A basic window structure looks like this:
<div nd-window nd-window-endpoint="examples/shared/page-one.html">
<div nd-window-header>
<span>Page One</span>
<button nd-window-button="maximize" title="Maximize">[ ]</button>
<button nd-window-button="close" title="Close">X</button>
</div>
<div nd-window-content>
<!-- Your window content here -->
</div>
</div>
To open it from anywhere:
<button data-modal="examples/shared/page-one.html">Open Page One</button>
The WindowManager automatically detects the data-modal attribute and loads the window content.
#
Core Attributes
The window system is powered by declarative nd- attributes.
#
1. The Window Container (nd-window)
Applied to the root element of a window.
If no size is specified, the default is 768x480.
#
2. The Endpoint (nd-window-endpoint)
Required for dynamic loading & lifecycle management.
- Identifies the window content source.
- Used internally as the unique key in the
WindowManager. - Matches the
data-modaltrigger.
<div nd-window nd-window-endpoint="settings/profile.html"></div>
#
3. Header (nd-window-header)
Defines the draggable top bar.
- Dragging starts only from this element.
- Automatically handles focus on interaction.
- Buttons must live inside the header.
#
4. Window Buttons (nd-window-button)
Control window actions.
Example:
#
5. Content (nd-window-content)
The scrollable inner content container.
<div nd-window-content>
<!-- your app content -->
</div>
Padding and styling are applied automatically.
#
Features & Interactions
#
Focus Management
- Clicking a window brings it to the front.
- Z-index is managed internally.
- The focused window receives the
.focusedclass.
#
Dragging
- Drag starts from
nd-window-header - Automatically restores from maximized when dragging
- Saves position ratios for responsive resizing
- Snap detection is built-in
#
Snap & Tiling
When dragging near screen edges:
- Left → Tile left
- Right → Tile right
- Top → Maximize
- Corners → Quadrant tiling (if enabled in config)
A .snap-indicator overlay appears to preview placement.
#
Maximize / Restore
Handled via:
manager.toggleMaximize(winElement);
CSS class applied:
.maximized
This sets:
top: 0left: 0width: 100%height: 100%
#
Keyboard Support
Escapecloses the topmost window.
#
Animations
Two appearance states are supported:
Animations use scale + opacity transitions.
#
Lifecycle Events
The root container dispatches CustomEvents:
Example:
root.addEventListener('window:opened', (e) => {
console.log('Opened:', e.detail.endpoint);
});
#
Technical Specifications
#
Attribute Reference
- Required for dynamic windows.
#
Styling & Customization
Like Icons, Windows use Design Tokens (CSS Variables).
All tokens are defined under :root.
#
Window Base Tokens
#
Header Tokens
#
Button Tokens
#
Light Defaults
#
Dark Overrides
#
Snap Tokens
#
Variants
#
Glass Window Variant
<div nd-window nd-variant="glass"></div>
Uses backdrop blur + transparency.
#
Architecture Overview
The WindowManager orchestrates:
- Lifecycle (
WindowLifecycle) - Dragging (
WindowDrag) - Tiling (
WindowTiling) - State persistence (
WindowState) - Dynamic loading (
WindowLoader)
You typically do not interact with these directly — use the public API:
manager.open(endpoint);
manager.close(win);
manager.toggleMaximize(win);
manager.focus(win);
manager.getWindows();
#
Summary
The NidamJS Window system provides:
✔ Declarative HTML structure ✔ Built-in drag & snap ✔ Focus & stacking management ✔ Dynamic content loading ✔ Persistent responsive positioning ✔ Design token theming
It behaves like a real desktop OS — inside the browser.