Skip to content

Commit 52959a4

Browse files
authored
cleanup components listed in demo (#89)
1 parent d0323c5 commit 52959a4

File tree

4 files changed

+29
-36
lines changed

4 files changed

+29
-36
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ jobs:
8989

9090
check: # This job does nothing and is only used for the branch protection
9191
if: always()
92-
needs: [lint, npm-build]
92+
needs: [lint, test, npm-build]
9393
runs-on: ubuntu-latest
9494

9595
steps:

README.md

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ users = [
6464
def users_table() -> list[AnyComponent]:
6565
"""
6666
Show a table of four users, `/api` is the endpoint the frontend will connect to
67-
when a user fixes `/` to fetch components to render.
67+
when a user visits `/` to fetch components to render.
6868
"""
6969
return [
7070
c.Page( # Page provides a basic container for components
@@ -119,33 +119,9 @@ Of course, that's a very simple application, the [full demo](https://fastui-demo
119119

120120
### Components
121121

122-
FastUI already defines the following components, all are shown in the [demo app](https://fastui-demo.onrender.com):
123-
124-
- `Text` — renders a string
125-
- `Paragraph` — renders a string as a paragraph
126-
- `PageTitle` — renders nothing, sets the HTML page title
127-
- `Div` — renders a `<div>` with arbitrary components inside
128-
- `Page` — a container for components
129-
- `Heading` — renders a heading `<h1>` to `<h6>`
130-
- `Markdown` — renders markdown, [example](https://fastui-demo.onrender.com)
131-
- `Code` — renders code with highlighting in a `<pre>`
132-
- `Button` — renders a `<button>`
133-
- `Link` — renders a link `<a>`
134-
- `LinkList` — renders a list of links
135-
- `Navbar` — renders a navbar `<nav>`
136-
- `Modal` — renders a modal dialog that opens triggered by an event
137-
- `ServerLoad` — render components fetched from the server, also provides SSE mode to update components based on server sent events
138-
- `Table` — renders a table
139-
- `Details` — renders a table of key/value pairs as a `<dl>`
140-
- `Display` — renders a value based on a display mode
141-
- `Table` — renders a table from a list of Pydantic models
142-
- `Pagination` — renders a pagination component
143-
- `FormFieldInput` — renders a form field using `<input>`
144-
- `FormFieldBoolean` — renders a form field for a boolean using `<input type="checkbox">`
145-
- `FormFieldSelect` — renders a form field using `<select>` or [react-select](https://react-select.com)
146-
- `FormFieldSelectSearch` — renders a form field using [react-select](https://react-select.com) with options updated from the server on search
147-
- `Form` — renders a form using a list of `FormField` components
148-
- `ModelForm` — renders a form based on a Pydantic model; the model's JSON Schema is used to build a list of `FormField` components
122+
FastUI already defines a rich set of components.
123+
124+
All components are listed in the [demo app](https://fastui-demo.onrender.com).
149125

150126
## The Principle (long version)
151127

demo/main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def api_index() -> list[AnyComponent]:
3030
* `Navbar` — see the top of this page
3131
* `Modal` — static example [here](/components#button-and-modal), dynamic content example [here](/components#dynamic-modal)
3232
* `ServerLoad` — see [dynamic modal example](/components#dynamic-modal) and [SSE example](/components#server-load-sse)
33+
* `Image` - example [here](/components#image)
3334
* `Iframe` - example [here](/components#iframe)
3435
* `Table` — See [cities table](/table/cities) and [users table](/table/users)
3536
* `Pagination` — See the bottom of the [cities table](/table/cities)

src/python-fastui/fastui/components/__init__.py

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,40 @@
2626
from .tables import Pagination, Table
2727

2828
__all__ = (
29-
'AnyComponent',
29+
# first we include everything from `AnyComponent`
3030
'Text',
31+
'Paragraph',
32+
'PageTitle',
3133
'Div',
3234
'Page',
3335
'Heading',
36+
'Markdown',
37+
'Code',
38+
'Json',
3439
'Button',
40+
'Link',
41+
'LinkList',
42+
'Navbar',
3543
'Modal',
44+
'ServerLoad',
45+
'Image',
46+
'Iframe',
47+
'Custom',
48+
'Table',
49+
'Pagination',
50+
'Display',
51+
'Details',
52+
'Form',
53+
'FormField',
3654
'ModelForm',
37-
'FormFieldInput',
55+
# then `AnyComponent` itself
56+
'AnyComponent',
57+
# then the other form field types which are included in `AnyComponent` via the `FormField` union
3858
'FormFieldBoolean',
3959
'FormFieldFile',
60+
'FormFieldInput',
4061
'FormFieldSelect',
4162
'FormFieldSelectSearch',
42-
'Form',
43-
'Table',
44-
'Display',
45-
'Details',
46-
'Image',
4763
)
4864

4965

0 commit comments

Comments
 (0)