Skip to content

Commit e318456

Browse files
committed
Updated AI guidelines for html components
1 parent 5b53824 commit e318456

1 file changed

Lines changed: 27 additions & 4 deletions

File tree

ai/HTML_COMPONENTS.md

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,30 @@ def about(request):
966966

967967
---
968968

969-
## 20. Code Style Rules
969+
## 20. Theming Patterns — Best Practice
970+
971+
Instead of hardcording colors, the best approach is to use a central system for storing
972+
theme data. This can be done by creating a `web/ui/components/theme.py` which stores a class named `Theme`, then
973+
theming can be done through using `Theme's` class attributes e.g., `Theme.accent_color`.
974+
975+
### Example of theme.py
976+
977+
```python
978+
# web/ui/components/theme.py
979+
980+
class Theme:
981+
accent_color = "rgba(0, 35, 6, 1)"
982+
border_radius = "12px"
983+
font_size = "1rem"
984+
# Other theming options here
985+
```
986+
987+
> For a Duck project, a centralized system is recommended not only for theming but also for metadata and this
988+
> type of data can be stored in `web/meta.py` (optional).
989+
990+
---
991+
992+
## 21. Code Style Rules
970993

971994
These are project-specific conventions for Duck Framework codebase.
972995
Follow them on all code written for this project.
@@ -1009,7 +1032,7 @@ def build_card(self, title: str) -> Card:
10091032

10101033
---
10111034

1012-
## 21. Common Mistakes to Avoid
1035+
## 22. Common Mistakes to Avoid
10131036

10141037
### Setting styles/props after construction (outside lifecycle)
10151038

@@ -1088,7 +1111,7 @@ btn = Button(text="Toggle", style={"display": "block"})
10881111

10891112
---
10901113

1091-
## 22. How to Look Up Any Component
1114+
## 23. How to Look Up Any Component
10921115

10931116
Before writing code that uses a Duck component you're unsure about:
10941117

@@ -1108,7 +1131,7 @@ Before writing code that uses a Duck component you're unsure about:
11081131

11091132
---
11101133

1111-
## 23. Helpful Sources
1134+
## 24. Helpful Sources
11121135

11131136
The following sources may help in digging more info on components:
11141137
- **https://github.com/duckframework/duck?tab=readme-ov-file#webui**

0 commit comments

Comments
 (0)