Skip to content

Commit 30acf66

Browse files
committed
Draft of ADR for layout handler and styling architecture.
1 parent 0b3779e commit 30acf66

File tree

1 file changed

+334
-0
lines changed

1 file changed

+334
-0
lines changed
Lines changed: 334 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,334 @@
1+
# Layout and Styling Architecture for MMGIS
2+
3+
- **Status**: PROPOSED
4+
- **Date**: 2026-02-10
5+
- **Deciders**: MMGIS Core Team
6+
- **Tags**: layout, styling, ui, panel-system, multi-panel, theming
7+
8+
---
9+
10+
## Executive Summary
11+
12+
Modernize MMGIS's layout and styling architecture to support a flexible, themable plugin framework that aligns with USWDS/Horizon design systems.
13+
14+
**Key Changes**:
15+
- **Layout**: Enhance current panel system with multi-panel support, minimize/close controls, and modern spacing
16+
- **Styling**: Migrate from hard-coded dark theme to flexible, design system-aligned theming
17+
- **Configuration**: Extend mission/tool configs to support panel configuration and theme customization
18+
19+
**Benefits**:
20+
- **Multi-Panel Support**: Multiple plugins can be open simultaneously with independent controls
21+
- **Usability**: Covers our core use cases with incremental enhancement path
22+
- **Consistency**: Align with existing design standards (USWDS/Horizon)
23+
- **Future-proof**: Foundation for grid-based layout system in later development cycle
24+
25+
---
26+
27+
## Terminology Note
28+
29+
To avoid confusion, we use internal terms that differ from MMGIS framework conventions:
30+
31+
| Our Term | MMGIS Framework Term | Description |
32+
|----------|---------------------|-------------|
33+
| Tool | Mission | Each unique instance of MMGIS dashboard |
34+
| Plugin / Component | Tool | Individual interactive components (Draw, Measure, etc.) |
35+
36+
*Note: Custom plugins/components we develop will be located in the `src/essence/Tools/` directory in MMGIS codebase.*
37+
38+
---
39+
40+
## Context and Problem Statement
41+
42+
### Current State: Layout
43+
44+
MMGIS uses a **fixed panel system** where plugins attach to pre-defined containers. Panels interact with the map in two ways:
45+
46+
```
47+
┌──────────────────────────────────────────────────────────┐
48+
│ Top Panel (Header) │
49+
│ [Logo] [Title] [View Switcher] │
50+
├──────────┬───────────────────────────────────────────────┤
51+
│ │ │
52+
│ Left │ │
53+
│ Panel │ Map Canvas (Leaflet/Cesium) │
54+
│ (slides) │ │
55+
│ │ ┌─────────────┐ │
56+
│ │ │ Floating │ │
57+
│ │ │ Panel │ │
58+
├──────────┴──┴─────────────┴──────────────────────────────┤
59+
│ Bottom Panel (slides up) │
60+
└──────────────────────────────────────────────────────────┘
61+
```
62+
63+
#### Panel Types
64+
65+
| Type | Behavior | Code Configuration | Examples |
66+
|------|----------|-------------------|----------|
67+
| **Left Panel** | Slides from left, resizes map canvas | `height: 0` | Info Tool |
68+
| **Bottom Panel** | Slides from bottom, resizes map canvas | `height > 0` | Measure Tool |
69+
| **Floating Panel** | Overlays map, doesn't resize canvas | `"separatedTool": true` | Legend Tool |
70+
71+
**Configuration Example**:
72+
```javascript
73+
// Left Panel Tool
74+
const InfoTool = {
75+
height: 0, // Triggers left panel
76+
width: 300,
77+
make: function() { ... }
78+
}
79+
80+
// Floating Panel Tool (in config)
81+
{
82+
"name": "LegendTool",
83+
"separatedTool": true // Becomes floating
84+
}
85+
```
86+
87+
#### Desktop vs Mobile View
88+
89+
| Feature | Desktop | Mobile |
90+
|---------|---------|--------|
91+
| Panel Support | All three types | Bottom Panel only |
92+
| Map Views | 2D Map, 3D Globe, Image Viewer | 2D Map only |
93+
| Toolset | All 16+ plugins | Reduced set (many hidden) |
94+
95+
### Problems with Current Layout
96+
97+
| Problem | Impact |
98+
|---------|--------|
99+
| **Single-Active Component** | Only one plugin active at a time; activating new one destroys previous |
100+
| **No Panel Controls** | Cannot minimize or close panels without switching tools |
101+
| **Limited Floating Panels** | Floating panels stack and obstruct each other |
102+
| **Basic Visual Design** | Panels lack modern styling, spacing, and visual hierarchy |
103+
| **No Multi-Panel Management** | Cannot manage multiple open panels simultaneously |
104+
105+
### Current State: Styling
106+
107+
MMGIS uses a **centralized CSS architecture** with a dark geospatial theme.
108+
109+
```
110+
src/css/
111+
├── mmgis.css # Core styles, :root variables, animations
112+
├── mmgisUI.css # UI components (buttons, sliders, checkboxes)
113+
├── external/ # Third-party library overrides
114+
│ ├── leaflet.css
115+
│ └── tempus-dominus.css
116+
└── tools.css # Built-in tool-specific styles
117+
118+
src/essence/Tools/<ToolName>/
119+
└── <ToolName>Tool.css # Component-specific styles
120+
```
121+
122+
**Current Theming via CSS Variables**:
123+
```css
124+
/* mmgis.css */
125+
:root {
126+
--color-a: #1c1c1c; /* Dark background */
127+
--color-b: #2e2e2e; /* Panel background */
128+
--color-k: #000000; /* Pure black */
129+
--main-color: #00d8ff; /* Accent color */
130+
}
131+
```
132+
133+
### Problems with Current Styling
134+
135+
| Problem | Impact |
136+
|---------|--------|
137+
| **Hard-coded Dark Theme** | No light mode or alternative themes |
138+
| **Dynamic Inline Styles** | JavaScript frequently injects styles; hard to override |
139+
| **High-Specificity Overrides** | Third-party library overrides require `!important` chains |
140+
| **No Design System Integration** | Doesn't align with USWDS/Horizon standards |
141+
142+
---
143+
144+
## Decision Drivers
145+
146+
1. **Multi-Panel Support**: Enable multiple active plugins simultaneously (e.g., Draw + Measure + Layers)
147+
2. **Modern Visual Design**: Improve panel styling with proper spacing, and visual hierarchy
148+
3. **Floating Panel Management**: Better z-index and stacking management for overlapping panels
149+
4. **Design System Alignment**: Match USWDS or Horizon for enterprise consistency
150+
5. **Configuration-Driven**: Panel behavior and theming defined in mission/tool configs, not hard-coded
151+
6. **Gradual Migration**: Can adopt incrementally without rewriting all 16+ existing tools
152+
7. **Incremental Enhancement**: Build foundation for future grid-based layout system
153+
154+
---
155+
156+
## Assumptions
157+
158+
1. **Panel Architecture Preservation**: Current panel system (left, bottom, floating) can be enhanced without fundamental rewrite
159+
2. **Desktop-First**: Initial implementation focuses on desktop; mobile layout improvements are future work
160+
3. **Backward Compatibility**: Existing tools continue working with current configuration until migrated
161+
4. **Plugin Lifecycle Compatibility**: `make()` and `destroy()` functions can be minimally updated to support multi-panel scenarios
162+
5. **Grid Layout Deferred**: Full grid-based layout system (Gridstack.js) will be implemented in a later development cycle
163+
164+
---
165+
166+
## Considered Options
167+
168+
#### Option 1: Enhanced Panel System (Selected)
169+
170+
**Description**: Extend current panel system with multi-panel support, modern controls, and improved visual design.
171+
172+
173+
**Panel Features**:
174+
- **Multi-Panel Support**: Multiple tools can be open simultaneously
175+
- **Panel Controls**: Minimize, maximize, close buttons on panel header
176+
- **Modern Styling**: Box shadows, border radius, proper spacing, visual hierarchy
177+
- **State Persistence**: Remember panel states across sessions
178+
179+
**Pros**:
180+
- Minimal refactoring of existing architecture
181+
- Works with current jQuery/D3 codebase
182+
- Preserves existing panel types (left, bottom, floating)
183+
- Can be implemented incrementally
184+
185+
**Cons**:
186+
- Still limited to pre-defined panel positions
187+
- Cannot arbitrarily position panels on screen
188+
- Less flexible than full grid system
189+
190+
**Why chosen**:
191+
- Delivers immediate value without major refactoring
192+
- Addresses core usability issues (single-panel limitation)
193+
- Provides foundation for future grid-based system
194+
- Low risk, high impact enhancement
195+
196+
---
197+
198+
#### Option 2: Gridstack.js Grid System (Deferred to Future)
199+
200+
**Description**: Full grid-based layout with drag-and-drop positioning.
201+
202+
**Why deferred**:
203+
- More complex than needed for current requirements
204+
- Can be added later as enhancement to panel system
205+
- Requires more extensive testing and migration effort
206+
- See [Phase 6: Grid-Based Layout System](#phase-6-grid-based-layout-system-q3-2026) for planned implementation
207+
208+
---
209+
210+
#### Option 3: Complete UI Rewrite with React
211+
212+
**Description**: Modernize entire frontend with React framework.
213+
214+
**Why rejected**:
215+
- Too disruptive for current development cycle
216+
- Would require rewriting all 16+ existing tools
217+
- Significant effort (months) with high risk
218+
- Can be reconsidered in future major version
219+
220+
---
221+
222+
### Styling
223+
224+
#### Option 1: USWDS / Horizon
225+
226+
**Description**: A government-standard design system with built-in accessibility and a mature component ecosystem.
227+
228+
**Pros**:
229+
- WCAG 2.1 AA compliant out of the box
230+
- Comprehensive component library (50+ components)
231+
- Built-in light and dark theme support
232+
- Strong documentation and active community
233+
234+
**Cons**:
235+
- May not be a perfect visual fit for all projects
236+
237+
---
238+
239+
#### Option 2: Custom Theme System (CSS Variables)
240+
241+
**Description**: A flexible, custom theming approach built on top of CSS variables.
242+
243+
**Pros**:
244+
- Highly customizable to meet individual project needs
245+
- Enables future creation of custom themes for different deployments
246+
247+
**Cons**:
248+
- Significant upfront effort to design and maintain a theme architecture
249+
- Requires defining and maintaining themes for each project
250+
251+
---
252+
253+
#### Decision
254+
255+
Adopt **USWDS / Horizon** as the default design system to ensure accessibility, consistency, and faster delivery.
256+
In parallel, structure the codebase to support theming so that USWDS becomes one of several themes in a future theme gallery, enabling customization as needs evolve.
257+
258+
---
259+
260+
## Migration Path
261+
262+
### Phase 1: Panel Manager Foundation (Week 1-2)
263+
- [ ] Create `PanelManager_.js` module for multi-panel state management
264+
- [ ] Implement panel registration and tracking system
265+
- [ ] Add panel state management (open, minimized, closed)
266+
- [ ] Add theme loader (`Theme_.js`)
267+
268+
### Phase 2: Panel Controls & UI (Week 3-4)
269+
- [ ] Design and implement panel header component with controls
270+
- [ ] Add minimize, maximize, close button functionality
271+
- [ ] Implement panel state transitions with animations
272+
- [ ] Add keyboard shortcuts for panel controls (accessibility)
273+
- [ ] Create modern panel styling with USWDS design tokens
274+
275+
### Phase 3: Multi-Panel Support (Week 5-6)
276+
- [ ] Update `ToolController_.js` to support multiple active tools
277+
- [ ] Refactor `make()` / `destroy()` lifecycle for multi-panel scenarios
278+
- [ ] Implement backward compatibility layer for single-panel tools
279+
- [ ] Add panel state persistence to database/local storage
280+
- [ ] Test multi-panel scenarios (2-3 panels open simultaneously)
281+
282+
### Phase 4: Theming Integration (Week 7-8)
283+
- [ ] Integrate USWDS CSS framework
284+
- [ ] Create `geospatial-dark.css` preserving current theme as default
285+
- [ ] Update panel components to use USWDS design tokens
286+
- [ ] Replace `mmgisUI.css` components with USWDS equivalents
287+
- [ ] Add theme switcher to Configure page
288+
289+
### Phase 5: Tool Migration & Testing (Week 9-10)
290+
- [ ] Update 3-5 high-priority tools (Draw, Measure, Layers, Info, Legend)
291+
- [ ] Test multi-panel scenarios with updated tools
292+
- [ ] Document plugin migration guide for panel controls
293+
- [ ] Update plugin template with panel best practices
294+
- [ ] Conduct accessibility testing (keyboard navigation, screen readers)
295+
296+
---
297+
298+
## Future Roadmap
299+
300+
### Phase 6: Grid-Based Layout System
301+
- [ ] Evaluate and integrate Gridstack.js library
302+
- [ ] Create grid initialization in `UserInterfaceDefault_.js`
303+
- [ ] Extend config schema with grid `layout` key
304+
- [ ] Implement drag-and-drop panel positioning
305+
- [ ] Add panel resizing with collision detection
306+
- [ ] Migrate panel system to grid-based containers
307+
- [ ] Implement responsive breakpoints for different screen sizes
308+
- [ ] Test backward compatibility with enhanced panel system
309+
310+
### Phase 7: Visual Layout Builder
311+
- [ ] Add drag-and-drop layout editor to Configure page
312+
- [ ] Real-time preview of layout changes
313+
- [ ] Export/import layout templates
314+
- [ ] Component palette for quick plugin addition
315+
- [ ] Visual grid overlay for alignment
316+
- [ ] Layout validation and conflict detection
317+
318+
### Phase 8: Mobile Optimization
319+
- [ ] Refactor `UserInterfaceMobile_.js` with responsive panel system
320+
- [ ] Implement swipeable panel navigation
321+
- [ ] Optimize plugin UI for touch interactions
322+
- [ ] Add mobile-specific panel presets
323+
- [ ] Test multi-panel scenarios on mobile devices
324+
325+
### Phase 9: Advanced Theming
326+
- [ ] Dynamic theme generation from mission config
327+
- [ ] High-contrast accessibility mode
328+
- [ ] Theme gallery for user-contributed themes
329+
- [ ] Theme preview in Configure page
330+
331+
### Phase 10: Plugin Marketplace Integration
332+
- [ ] Sandboxed iframe layout for marketplace plugins
333+
- [ ] Theme API for third-party plugins
334+
- [ ] Layout validation and security checks

0 commit comments

Comments
 (0)