feat: add modal overlay for type definitions

Implement a modal popup system for viewing type definitions without leaving
the current context, with browser-like back/forward navigation.

Modal UI Components:
- Full-screen overlay with centered modal dialog
- Header with title, close button, and navigation controls
- Scrollable content area for type definition
- Back (←) and forward (→) navigation buttons
- Visual disabled state for navigation at history bounds

Navigation Features:
- Click any type reference in root schema to open in modal
- Click type references within modal to navigate deeper
- Keyboard shortcuts: Alt+← (back), Alt+→ (forward), Escape (close)
- History tracking with array and index pointer
- History resets on modal close

JavaScript Implementation:
- `openTypeModal(typeName, addToHistory)`: Open/navigate to type
- `showType(typeName)`: Clone and display type definition content
- `navigateHistory(direction)`: Handle back/forward navigation
- `closeModal()`: Close modal and reset state
- `updateNavButtons()`: Enable/disable nav buttons based on position

CSS Styling (102 lines added):
- `.modal-overlay`: Fixed positioning with semi-transparent background
- `.modal`: Centered container with max dimensions and shadow
- `.modal-header`: Flex layout for nav, title, and close button
- `.modal-nav-btn`: Styled navigation buttons with disabled state
- `.modal-content`: Scrollable content with padding

Identifier Updates:
- Add modal-related IDs and classes to identifiers.rs
- New ID: `modal-overlay`
- New classes: modal, modal-active, modal-header, modal-title, modal-close,
  modal-content, modal-nav, modal-nav-btn, disabled
This commit is contained in:
LGUG2Z committed 2025-12-22 09:31:29 -08:00
1 parent f32d94d929
commit c6835ddbb2
7 files changed
+312 -8

No files matched your search

+34
View File
@@ -15,6 +15,7 @@ pub struct HtmlIds {
pub sidebar_toggle: &'static str,
pub root_schema: &'static str,
pub definitions: &'static str,
pub modal_overlay: &'static str,
}
/// All static HTML IDs
@@ -25,6 +26,7 @@ pub const IDS: HtmlIds = HtmlIds {
sidebar_toggle: "sidebar-toggle",
root_schema: "root-schema",
definitions: "definitions",
modal_overlay: "modal-overlay",
};
/// CSS class names organized by category
@@ -123,6 +125,18 @@ pub struct CssClasses {
pub usages: &'static str,
pub usage_section: &'static str,
pub usage_list: &'static str,
// Modal
pub modal_overlay: &'static str,
pub modal: &'static str,
pub modal_active: &'static str,
pub modal_header: &'static str,
pub modal_title: &'static str,
pub modal_close: &'static str,
pub modal_content: &'static str,
pub modal_nav: &'static str,
pub modal_nav_btn: &'static str,
pub modal_nav_disabled: &'static str,
}
/// All CSS class names
@@ -220,6 +234,18 @@ pub const CSS: CssClasses = CssClasses {
usages: "usages",
usage_section: "usage-section",
usage_list: "usage-list",
// Modal
modal_overlay: "modal-overlay",
modal: "modal",
modal_active: "modal-active",
modal_header: "modal-header",
modal_title: "modal-title",
modal_close: "modal-close",
modal_content: "modal-content",
modal_nav: "modal-nav",
modal_nav_btn: "modal-nav-btn",
modal_nav_disabled: "disabled",
};
/// Type-specific badge class suffixes (used with type-badge prefix)
@@ -281,4 +307,12 @@ mod tests {
assert!(TYPE_CLASSES.integer.starts_with("type-"));
assert!(TYPE_CLASSES.array.starts_with("type-"));
}
#[test]
fn test_modal_nav_classes_are_valid() {
// Modal navigation CSS classes should not contain spaces
assert!(!CSS.modal_nav.contains(' '));
assert!(!CSS.modal_nav_btn.contains(' '));
assert!(!CSS.modal_nav_disabled.contains(' '));
}
}