Added first controls

This commit is contained in:
2025-11-26 20:53:12 +01:00
parent 459c89bae2
commit ce5328fe34
68 changed files with 37849 additions and 87048 deletions

View File

@@ -63,7 +63,7 @@ if __name__ == "__main__":
```python
from fasthtml import serve
from myfasthtml.controls.helpers import mk_button
from myfasthtml.controls.helpers import mk
from myfasthtml.core.commands import Command
from myfasthtml.myfastapp import create_app
@@ -82,7 +82,7 @@ app, rt = create_app(protect_routes=False)
@rt("/")
def get_homepage():
return mk_button("Click Me!", command=hello_command)
return mk.button("Click Me!", command=hello_command)
if __name__ == "__main__":
@@ -97,11 +97,17 @@ if __name__ == "__main__":
### Bind components
```python
from dataclasses import dataclass
from myfasthtml.controls.helpers import mk
@dataclass
class Data:
value: str = "Hello World"
checked: bool = False
# Binds an Input with a label
mk.mk(Input(name="input_name"), binding=Binding(data, attr="value").htmx(trigger="input changed")),
mk.mk(Label("Text"), binding=Binding(data, attr="value")),
@@ -815,6 +821,24 @@ mk.manage_binding(label_elt, Binding(data))
# Input won't trigger updates, but label will still display data
```
## Authentication
session
```
{'access_token': 'xxx',
'refresh_token': 'yyy',
'user_info': {
'email': 'admin@myauth.com',
'username': 'admin',
'roles': ['admin'],
'user_settings': {},
'id': 'uuid',
'created_at': '2025-11-10T15:52:59.006213',
'updated_at': '2025-11-10T15:52:59.006213'
}
}
```
## Contributing
We welcome contributions! To get started: