abrignoni / abrignoni/iLEAPP

Feature: Structured Icon Support in Table Cells (No HTML Escaping)

Aperta
#1,443 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Python
Stelle
1.2k
Fork
303
Merge medio
4h 32m
PR unite (30g)
216

Descrizione

## Background

Some modules currently use **HTML escaping** in the legacy HTML output to render Feather icons in table cells. This works in the HTML renderer but is not something we want to bring into LAVA.

LAVA **will not allow raw HTML injection** from artifact output. Instead we should provide a structured way for modules to request icons in a cell so the renderer can safely convert that to a Feather icon.

Some important factors to consider in how we approach:

- avoid HTML escaping/hacks
- keep React rendering predictable
- keep parsing minimal during table rendering
- maintain a stable contract between modules and renderers

## Proposed Approach

Introduce a **structured icon object** that can be returned in table cells. The renderer can then convert this object into a Feather icon in LAVA.

Example cell value:

```json
{
"icon": {
"name": "alert-triangle",
"color": "#f59e0b",
"size": 16,
"strokeWidth": 2,
"position": "after",
"tooltip": "missing"
},
"content": "Missing attachment"
}
```
Renderer:
- Name is required, all others are optional
- Render the Feather icon
- Render content as text
- Default position is icon before text

This keeps icon rendering entirely within LAVA instead of embedding presentation logic in module output.

## API Helper

Modules should not construct this object directly. Instead we should provide a helper function in the core (ilapfuncs or similar).

Function:
```python
make_icon(icon_name, icon_props=None, content=None, content_type=None)
```

Example usage:
```python
make_icon(
"alert-triangle",
"Missing attachment",
{"color": "#f59e0b"}
)
```

Benefits:

- Centralized schema definition
- Allows future schema changes without breaking modules
- Keeps artifact code simpler
- Ensures consistent structure in output

## Optional Enhancement

With this schema structure, we could allow the content to be output with a designated type of its own from one of our other render types.

Example:
```json
{
"icon": {
"name": "alert-triangle",
"color": "#f59e0b",
"size": 16,
"strokeWidth": 2,
"position": "after",
"tooltip": "missed call"
},
"content": "+12345678900",
"contentType": "phonenumber"
}
```
Example usage:
```python
make_icon(
"alert-triangle",
"+12345678900",
{"color": "#f59e0b", "tooltip": "Missed Call"},
"phonenumber"
)
```

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.