|
| 1 | +# Z-Index Guide for PFControl |
| 2 | + |
| 3 | +This document defines the standardized z-index system for the application to prevent layering conflicts and ensure proper visual hierarchy. |
| 4 | + |
| 5 | +## Z-Index Scale |
| 6 | + |
| 7 | +### Body Background (Auto/0) |
| 8 | +- **body element**: `background-color: #1a1a1a` at z-index: auto (0) |
| 9 | + - This is the default dark background for the entire app |
| 10 | + - Elements must be at z-index: 1 or higher to appear above this |
| 11 | + |
| 12 | +### Content Layer (1-999) |
| 13 | +- **1-9**: Decorative overlays and page-level effects |
| 14 | + - `1`: Holiday effects (snow, animations) - above body background |
| 15 | + - `5`: Slider controls (internal z-index) |
| 16 | +- **10-99**: Interactive elements within content |
| 17 | + - `10`: Forms, cards, and content containers (above holiday effects) |
| 18 | + - `10`: Slider thumbs (internal z-index) |
| 19 | + - `40`: Toolbar positioning helpers |
| 20 | + - `48`: Chart drawer |
| 21 | + - `49`: Chart drawer header |
| 22 | + - `50`: Reserved |
| 23 | +- **100-999**: Floating UI elements |
| 24 | + - `100`: Toast notifications, Music player control |
| 25 | + - `998`: Toolbar dropdowns and tooltips |
| 26 | + - `999`: Reserved |
| 27 | + |
| 28 | +### Overlay Layer (1000-9999) |
| 29 | +- **1000-4999**: Page overlays and dialogs |
| 30 | + - `1000`: Page-level modals (Settings, Home, Flights, Create pages) |
| 31 | +- **5000-8999**: Reserved for future overlays |
| 32 | +- **9000-9999**: Critical overlays |
| 33 | + - `9997`: Flight table dropdown backdrops |
| 34 | + - `9998`: Flight table dropdown content, generic dropdowns |
| 35 | + - `9999`: Navbar (top navigation bar) |
| 36 | + |
| 37 | +### Top Layer (10000+) |
| 38 | +- **10000+**: Always-on-top elements |
| 39 | + - `10000`: ACARS sidebars (Chat, Contact, ATIS) |
| 40 | + - `50000`: Critical system modals (use z-50 in Tailwind) |
| 41 | + |
| 42 | +## Component Reference |
| 43 | + |
| 44 | +### Holiday Effects (Content Layer) |
| 45 | +- **SnowEffect.tsx**: `z-index: 1` (canvas) |
| 46 | +- **HolidayAnimations.tsx**: `z-index: 1` (snow drift SVG and snowman) |
| 47 | +- **Purpose**: Above body background but behind all interactive UI elements |
| 48 | + |
| 49 | +### Forms & Interactive Content (Content Layer) |
| 50 | +- **Submit.tsx**: `z-10` (form containers, success messages, wind display) |
| 51 | +- **Purpose**: Interactive content that should appear above holiday effects |
| 52 | + |
| 53 | +### Navigation |
| 54 | +- **Navbar.tsx**: `z-[9999]` (Tailwind class) |
| 55 | +- **Purpose**: Always visible at top of viewport |
| 56 | + |
| 57 | +### Modals & Overlays |
| 58 | +- **Modal.tsx**: `z-50` (Tailwind = 50000) |
| 59 | + - Standard modal overlay and content |
| 60 | +- **Page Modals** (Settings, Home, Flights, Create): `z-index: 1000` |
| 61 | + - Page-specific modal overlays |
| 62 | + |
| 63 | +### Sidebars & Tools |
| 64 | +- **ChatSidebar.tsx**: `z-index: 10000` |
| 65 | +- **ContactAcarsSidebar.tsx**: `z-index: 10000` |
| 66 | +- **ATIS.tsx**: `z-index: 10000` |
| 67 | +- **ChartDrawer.tsx**: |
| 68 | + - Container: `z-index: 48` |
| 69 | + - Header: `z-index: 49` |
| 70 | +- **Toolbar.tsx**: |
| 71 | + - Position helper: `z-index: 40` |
| 72 | + - Dropdown: `z-index: 998` |
| 73 | + |
| 74 | +### Dropdowns & Tooltips |
| 75 | +- **Dropdown.tsx**: `z-index: 9998` |
| 76 | +- **Flight Tables** (Arrivals/Departures): |
| 77 | + - Backdrop: `z-index: 9997` |
| 78 | + - Dropdown: `z-index: 9998` |
| 79 | +- **Chat Tooltips**: `z-[9999]` |
| 80 | + |
| 81 | +### Notifications |
| 82 | +- **Toast.tsx**: `z-[100]` (Tailwind class) |
| 83 | + |
| 84 | +### Settings UI Elements |
| 85 | +- **SoundSettings.tsx**: Internal slider controls |
| 86 | + - Slider track: `z-index: 5` |
| 87 | + - Slider thumb: `z-index: 10` |
| 88 | +- **LayoutSettings.tsx**: Internal slider controls |
| 89 | + - Slider track: `z-index: 5` |
| 90 | + - Slider thumb: `z-index: 10` |
| 91 | +- **HolidayThemeSettings.tsx**: Internal slider controls |
| 92 | + - Slider track: `z-index: 5` |
| 93 | + - Slider thumb: `z-index: 10` |
| 94 | + |
| 95 | +## Usage Guidelines |
| 96 | + |
| 97 | +### When to Use Each Layer |
| 98 | + |
| 99 | +1. **Body Background (0/auto)** |
| 100 | + - Default page backgrounds (sections with bg-black, bg-zinc-900, etc.) |
| 101 | + - These should NOT have explicit z-index values to remain at layer 0 |
| 102 | + |
| 103 | +2. **Content Layer (1-999)** |
| 104 | + - Normal page content (0) |
| 105 | + - In-content interactive elements (1-99) |
| 106 | + - Floating UI tied to specific content (100-999) |
| 107 | + |
| 108 | +3. **Overlay Layer (1000-9999)** |
| 109 | + - Page-level modals and dialogs (1000-4999) |
| 110 | + - Navigation and critical UI (9000-9999) |
| 111 | + |
| 112 | +4. **Top Layer (10000+)** |
| 113 | + - Always-visible sidebars |
| 114 | + - System-level modals |
| 115 | + - Emergency/critical notifications |
| 116 | + |
| 117 | +### Visual Layer Order (Bottom to Top) |
| 118 | + |
| 119 | +``` |
| 120 | +[0] Body background (#1a1a1a) |
| 121 | +[0] Page sections with bg-black, bg-zinc-900 (no z-index) |
| 122 | +[1] Holiday effects (snow, snowman, animations) |
| 123 | +[10] Forms, cards, and interactive content (above holiday effects) |
| 124 | +[10-99] Other interactive content elements |
| 125 | +[100-999] Tooltips and floating UI |
| 126 | +[1000-9999] Modals, dropdowns, navigation |
| 127 | +[10000+] Sidebars and top-layer modals |
| 128 | +``` |
| 129 | + |
| 130 | +### Best Practices |
| 131 | + |
| 132 | +1. **Use named constants**: Define z-index values in this document and reference them in comments |
| 133 | +2. **Avoid arbitrary values**: Use values from this scale |
| 134 | +3. **Group related elements**: Keep related UI elements in the same z-index range |
| 135 | +4. **Leave gaps**: Don't use every number - leave room for future additions |
| 136 | +5. **Document exceptions**: If you need to deviate from this system, document why |
| 137 | + |
| 138 | +### Tailwind Z-Index Classes |
| 139 | + |
| 140 | +Tailwind provides these z-index utilities: |
| 141 | +- `z-0` = 0 |
| 142 | +- `z-10` = 10 |
| 143 | +- `z-20` = 20 |
| 144 | +- `z-30` = 30 |
| 145 | +- `z-40` = 40 |
| 146 | +- `z-50` = 50 (50000 in some contexts) |
| 147 | +- `z-auto` = auto |
| 148 | +- `z-[value]` = custom value (e.g., `z-[9999]`) |
| 149 | + |
| 150 | +## Migration Notes |
| 151 | + |
| 152 | +When updating z-index values: |
| 153 | +1. Check this document for the correct layer |
| 154 | +2. Update the component |
| 155 | +3. Test with other overlapping components |
| 156 | +4. Update this document if adding new patterns |
| 157 | + |
| 158 | +## Common Issues & Solutions |
| 159 | + |
| 160 | +### Issue: Holiday effects not visible |
| 161 | +**Solution**: Holiday effects must be at `z-index: 1` or higher to appear above the body background (`#1a1a1a` at z-index: 0). Page sections should NOT have explicit z-index values to remain at layer 0. |
| 162 | + |
| 163 | +### Issue: Holiday effects appearing above UI elements |
| 164 | +**Solution**: Ensure holiday effects use `z-index: 1` and interactive elements use z-index: 10 or higher |
| 165 | + |
| 166 | +### Issue: Modals hidden behind navigation |
| 167 | +**Solution**: Navigation should be z-9999, modals should be z-50000 (z-50) |
| 168 | + |
| 169 | +### Issue: Dropdowns cut off by parent containers |
| 170 | +**Solution**: Use portal rendering or ensure parent has lower z-index |
| 171 | + |
| 172 | +### Issue: Multiple overlays fighting for top position |
| 173 | +**Solution**: Use proper layer from this guide, don't just add +1 |
| 174 | + |
| 175 | +## Testing Checklist |
| 176 | + |
| 177 | +When changing z-index values, test these scenarios: |
| 178 | +- [ ] Holiday effects visible but behind all UI |
| 179 | +- [ ] Navbar always on top (except modals) |
| 180 | +- [ ] Modals cover everything except other modals |
| 181 | +- [ ] Dropdowns appear above their trigger elements |
| 182 | +- [ ] Tooltips readable and not obscured |
| 183 | +- [ ] Sidebars accessible and properly layered |
| 184 | +- [ ] Toast notifications visible |
| 185 | +- [ ] No unintended layering conflicts |
| 186 | + |
| 187 | +--- |
| 188 | + |
| 189 | +**Last Updated**: 2025-11-14 |
| 190 | +**Maintainer**: Development Team |
0 commit comments