Skip to content

Commit df35d9a

Browse files
Merge pull request #2608 from iNavFlight/maintenance-9.x
Maintenance 9.x to maintenance-10.x
2 parents 49de051 + abe8c44 commit df35d9a

71 files changed

Lines changed: 4954 additions & 679 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CLAUDE.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,83 @@ MSP.send_message(MSPCodes.MSP_SOME_CODE, payload, false, () => {
113113
- **i18next** via `data-i18n` attributes: `<span data-i18n="key"></span>`
114114
- **ES6 modules** throughout (`import`/`export`)
115115

116+
## CSS Best Practices
117+
118+
**Core Principle: Let the Browser Do Its Job of Handling Sizes**
119+
120+
Adding CSS to force specific sizes consistently causes problems. Removing that CSS and letting the browser calculate natural dimensions consistently produces better results.
121+
122+
### ❌ Don't Do This
123+
124+
```css
125+
/* Don't force widths on containers */
126+
.controls { width: 285px; }
127+
128+
/* Don't force button widths */
129+
.button { width: 49%; }
130+
131+
/* Especially Don't use pixels for font sizes! */
132+
.text { font-size: 16px; }
133+
```
134+
135+
**Problems caused:**
136+
- Fixed widths create cramped layouts, overlaps, and wasted space
137+
- Forced button widths look unnatural
138+
- Pixel font sizes don't scale across different display densities (200 DPI vs 800 DPI)
139+
- Breaks user font size preferences and accessibility
140+
141+
### ✅ Do This Instead
142+
143+
```css
144+
/* Let containers size naturally */
145+
.controls { width: fit-content; }
146+
/* Or just don't set width at all */
147+
148+
/* Let buttons size based on content */
149+
/* Don't set width on buttons */
150+
151+
/* Use relative units for fonts */
152+
.text { font-size: 1.2em; }
153+
/* Or don't set font-size and use defaults */
154+
```
155+
156+
**Results:**
157+
- Layouts adapt naturally to content
158+
- Elements look properly proportioned
159+
- Text scales correctly across devices
160+
- Respects user preferences
161+
162+
### The Pattern to Recognize
163+
164+
If you're writing CSS to force dimensions and encountering layout problems:
165+
166+
1. **Stop adding more CSS** to "fix" it
167+
2. **Remove the size constraints** causing the problem
168+
3. **Let the browser calculate** natural dimensions
169+
4. **Only add back** minimal constraints if absolutely required
170+
171+
**Most of the time, removing CSS produces better results than adding more CSS.**
172+
173+
### When to Set Sizes
174+
175+
Only force sizes when there's a genuine need:
176+
- Images/icons requiring exact dimensions
177+
- `max-width` for text readability (e.g., `max-width: 80ch`)
178+
- Specific design requirements (but question if they're necessary)
179+
180+
Use modern layout tools:
181+
- **Flexbox** for flexible layouts with `gap`, `justify-content`, `align-items`
182+
- **Grid** for two-dimensional layouts with `grid-template-columns`, `gap`
183+
- **fit-content**, **auto**, **%** instead of fixed pixels
184+
185+
### Real Examples from LED Strip Redesign (2026-01-28)
186+
187+
All three of these problems were fixed by **removing CSS**, not adding more:
188+
189+
1. `.controls { width: 285px; }` → cramped step progress bar → **removed width rule**
190+
2. `.button { width: 49%; }` → unnaturally wide buttons → **removed width rule**
191+
3. `.step { font-size: 16px; }` → doesn't scale → **changed to font-size: 1.5em**
192+
116193
## Debugging
117194

118195
```bash

images/icons/search-white.svg

Lines changed: 11 additions & 4 deletions
Loading

0 commit comments

Comments
 (0)