-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
more example htmy app simplification, refs #42
- Loading branch information
Showing
1 changed file
with
5 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
from datetime import date | ||
|
||
from fastapi import FastAPI | ||
from htmy import Component, ComponentType, Context, html | ||
from htmy import Component, Context, html | ||
from pydantic import BaseModel | ||
|
||
from fasthx.htmy import HTMY, ComponentHeader, CurrentRequest, RouteParams | ||
|
@@ -89,10 +89,8 @@ def htmy(self, context: Context) -> Component: | |
|
||
|
||
@dataclass | ||
class Page: | ||
"""Base page layout.""" | ||
|
||
content: ComponentType | ||
class IndexPage: | ||
"""Index page with TailwindCSS styling.""" | ||
|
||
def htmy(self, context: Context) -> Component: | ||
return ( | ||
|
@@ -109,8 +107,8 @@ def htmy(self, context: Context) -> Component: | |
html.script(src="https://unpkg.com/[email protected]"), | ||
), | ||
html.body( | ||
# Page content | ||
self.content, | ||
# Page content: lazy-loaded user list. | ||
html.div(hx_get="/users", hx_trigger="load", hx_swap="outerHTML"), | ||
class_=( | ||
"h-screen w-screen flex flex-col items-center justify-center " | ||
" gap-4 bg-slate-800 text-white" | ||
|
@@ -120,15 +118,6 @@ def htmy(self, context: Context) -> Component: | |
) | ||
|
||
|
||
@dataclass | ||
class IndexPage: | ||
"""Index page.""" | ||
|
||
def htmy(self, context: Context) -> Component: | ||
# Lazy load the user list. | ||
return Page(html.div(hx_get="/users", hx_trigger="load", hx_swap="outerHTML")) | ||
|
||
|
||
# -- Application | ||
|
||
# Create the app instance. | ||
|