diff --git a/demo/main.py b/demo/main.py index b2fa16fe..1671b10d 100644 --- a/demo/main.py +++ b/demo/main.py @@ -28,6 +28,7 @@ def api_index() -> list[AnyComponent]: * `Link` — example [here](/components#link-list) * `LinkList` — example [here](/components#link-list) * `Navbar` — see the top of this page +* `Footer` — see the bottom of this page * `Modal` — static example [here](/components#button-and-modal), dynamic content example [here](/components#dynamic-modal) * `ServerLoad` — see [dynamic modal example](/components#dynamic-modal) and [SSE example](/components#server-load-sse) * `Image` - example [here](/components#image) diff --git a/demo/shared.py b/demo/shared.py index 731d54ff..7b7263c7 100644 --- a/demo/shared.py +++ b/demo/shared.py @@ -40,4 +40,14 @@ def demo_page(*components: AnyComponent, title: str | None = None) -> list[AnyCo *components, ], ), + c.Footer( + extra_text='FastUI Demo', + links=[ + c.Link( + components=[c.Text(text='Github')], on_click=GoToEvent(url='https://github.com/pydantic/FastUI') + ), + c.Link(components=[c.Text(text='PyPI')], on_click=GoToEvent(url='https://pypi.org/project/fastui/')), + c.Link(components=[c.Text(text='NPM')], on_click=GoToEvent(url='https://www.npmjs.com/org/pydantic/')), + ], + ), ] diff --git a/demo/tests.py b/demo/tests.py index 3865cdb6..a6c02161 100644 --- a/demo/tests.py +++ b/demo/tests.py @@ -40,6 +40,11 @@ def test_api_root(): ], 'type': 'Page', }, + { + 'extraText': 'FastUI Demo', + 'links': IsList(length=3), + 'type': 'Footer', + }, ] diff --git a/src/npm-fastui-bootstrap/src/footer.tsx b/src/npm-fastui-bootstrap/src/footer.tsx new file mode 100644 index 00000000..d3d251c3 --- /dev/null +++ b/src/npm-fastui-bootstrap/src/footer.tsx @@ -0,0 +1,22 @@ +import { FC } from 'react' +import { components, models, useClassName } from 'fastui' + +export const Footer: FC = (props) => { + const links = props.links.map((link) => { + link.mode = link.mode || 'footer' + return link + }) + const extraProp = useClassName(props, { el: 'extra' }) + return ( + + ) +} diff --git a/src/npm-fastui-bootstrap/src/index.tsx b/src/npm-fastui-bootstrap/src/index.tsx index 10525181..cf355c90 100644 --- a/src/npm-fastui-bootstrap/src/index.tsx +++ b/src/npm-fastui-bootstrap/src/index.tsx @@ -5,12 +5,15 @@ import type { ClassNameGenerator, CustomRender, models } from 'fastui' import { Modal } from './modal' import { Navbar } from './navbar' import { Pagination } from './pagination' +import { Footer } from './footer' export const customRender: CustomRender = (props) => { const { type } = props switch (type) { case 'Navbar': return () => + case 'Footer': + return () =>