Ir para o conteúdo

tempest_fastapi_sdk.ui.layout

Layout: os contêineres estruturais em que uma página organiza o conteúdo.

« Web, UI e utilitários


Shell

Bases: Component

The shared page chrome.

Wraps the page content in <header> / <main> / <footer> landmarks. Use it from a base page's :meth:~tempest_fastapi_sdk.ui.pages.Page.shell so every concrete page inherits the same frame through plain Python inheritance.

Attributes:

Name Type Description
children list[Widget]

The page content, placed in <main>.

header Widget | None

Content of the <header> landmark — usually a :class:~tempest_fastapi_sdk.ui.components.NavBar.

footer Widget | None

Content of the <footer> landmark.

width ShellWidth

"contained" (the default) centres <main> in a 72rem column with a gutter, which suits reading pages. "full" adds the :attr:ComponentClasses.shell_main_full modifier, which drops the maximum width, the centring margin and the padding, so a sidebar-plus-panel layout spans the viewport and owns its own gutters.

classes ComponentClasses

Class names to apply.

Example
from tempest_core import Text, Widget

from tempest_fastapi_sdk.ui.components import NavBar, NavItem
from tempest_fastapi_sdk.ui.layout import Shell
from tempest_fastapi_sdk.ui.pages import Page


class BasePage(Page):
    def shell(self, body: Widget) -> Widget:
        return Shell(
            children=[body],
            header=NavBar(items=[NavItem(label="Início", href="/")]),
            footer=Text(content="© Tempest", tag="small"),
        )

render

render() -> Widget

Compose the shell.

Returns:

Name Type Description
Widget Widget

A <div> holding the landmarks that were given,

Widget

with the content always inside <main>.

Grid

Bases: Component

A CSS grid of equal-width, wrapping columns.

The default min_column_width makes the grid responsive with no media query: columns fit as many as the width allows and reflow to one per row on a phone.

Attributes:

Name Type Description
children list[Widget]

The grid items.

columns int

Fixed column count. 0 (the default) uses the auto-fitting track based on :attr:min_column_width.

min_column_width str

Minimum width of an auto-fitted column, as a CSS length.

gap str

Gap between items, as a CSS length.

classes ComponentClasses

Class names to apply.

Example
from tempest_core import Text

from tempest_fastapi_sdk.ui.layout import Grid

grid = Grid(children=[Text(content="a"), Text(content="b")], gap="1rem")

template

template() -> str

Return the grid-template-columns value.

Returns:

Name Type Description
str str

A fixed repeat(n, 1fr) when :attr:columns is set,

str

otherwise an auto-fitting track.

render

render() -> Widget

Compose the grid.

Returns:

Name Type Description
Widget Widget

A <div> with display: grid and the computed

Widget

track, holding the items unchanged.