You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# CLAUDE.md — AI Assistant Guide for sections-grid-layout
2
-
3
-
This file provides context for AI assistants working in this repository.
1
+
# CLAUDE.md -- AI Assistant Guide for sections-grid-layout
4
2
5
3
---
6
4
7
5
## Project Overview
8
6
9
7
**sections-grid-layout** is a Home Assistant Lovelace custom **view** plugin that places native HA `hui-section` elements into a CSS Grid with Jinja template evaluation and responsive design support.
The project registers one view layout element (`sections-grid-layout`) plus two helper cards (`gap-card-sgl`, `layout-break-sgl`). It coexists safely with the stock `layout-card`.
16
+
The project registers one custom element (`sections-grid-layout`) and two patches. It coexists safely with the stock `layout-card`.
19
17
20
18
---
21
19
@@ -26,69 +24,71 @@ The project registers one view layout element (`sections-grid-layout`) plus two
Abstract base. Manages `editMode`, card visibility, and the FAB (suppressed in sections mode by GridLayout's `_render_fab()` override).
72
+
`GridLayout` extends `LitElement` directly (no base class).
78
73
79
74
### `grid.ts`
80
75
-**CSS Grid rendering**: Applies `grid-template-areas/columns/rows` from `layout` config
81
76
-**Section management**: Creates/destroys `hui-section` wrappers; maintains `_sectionsCache`; auto-saves new sections to lovelace config
82
-
-**Jinja template evaluation**: Evaluates`{{ states() }}`, `{{ state_attr() }}`, `{% if %}` in `custom_css`; tracks entities in `_trackedEntities`; debounced via `requestAnimationFrame`
77
+
-**Jinja template evaluation**: Calls pure functions from `template.ts` for`{{ states() }}`, `{{ state_attr() }}`, `{% if %}` in `custom_css`; tracks entities in `_trackedEntities`; debounced via `requestAnimationFrame`
83
78
-**Background images**: Fixed positioning, blur, opacity, template support
84
79
-**Kiosk mode**: `layout.kiosk: true` makes `#root` fixed-position, filling viewport below HA header; edit-mode offset adjusts for tab bar
85
80
-**Layout zoom**: `layout.zoom` applies CSS `zoom` to `#root`
86
-
-**Per-section styling**: `scrollable`, `background`, `backdrop_blur`, `zoom`, `overflow` on each `SectionConfig` — applied as classes/inline styles on `.section-container`
87
-
-**Edit mode UI**: Section labels with grid-area name; loose-cards container for orphan cards
88
-
-**`_updateSectionsLovelace()`**: Pushes fresh `lovelace` AND fresh `config` (looked up by `grid_area`) to each `hui-section` so it never renders from a stale snapshot
81
+
-**Per-section styling**: `scrollable`, `background`, `backdrop_blur`, `zoom`, `overflow`, `padding`, `tint`, `variables`, `mediaquery` on each section
82
+
-**Edit mode UI**: Section labels with grid-area name; loose-cards container for orphan cards; overlay tester panel
83
+
-**`_updateSectionsLovelace()`**: Pushes fresh `lovelace` AND fresh `config` to each `hui-section`
84
+
85
+
### Extracted utility modules (pure functions, testable without DOM)
Adds only `sections-grid-layout` to the view type dropdown. Guard flag `_sectionsGridLayoutPatched` prevents double-patching when layout-card is also loaded.
91
+
Adds `sections-grid-layout` to the view type dropdown. Guard flag `_sectionsGridLayoutPatched` prevents double-patching when layout-card is also loaded.
92
92
93
93
### `patches/hui-card-element-editor.ts`
94
94
Preserves `view_layout` when the card element editor saves changes.
@@ -113,6 +113,7 @@ Preserves `view_layout` when the card element editor saves changes.
113
113
| State value |`{{ states('sensor.temperature') }}`|
114
114
| Attribute value |`{{ state_attr('climate.living', 'temperature') }}`|
115
115
| Conditional |`{% if is_state('binary_sensor.dark', 'on') %}...{% endif %}`|
116
+
| Negative |`{% if not is_state('binary_sensor.dark', 'on') %}...{% endif %}`|
116
117
117
118
---
118
119
@@ -121,7 +122,9 @@ Preserves `view_layout` when the card element editor saves changes.
0 commit comments