Skip to content

Commit ee807d5

Browse files
formanb-yogesh
andauthored
Component docs (#35)
* Initial docs * Update chartlets.js/README.md Co-authored-by: b-yogesh <[email protected]> * Update chartlets.py/README.md Co-authored-by: b-yogesh <[email protected]> * Update docs/components.md Co-authored-by: b-yogesh <[email protected]> * Update docs/index.md Co-authored-by: b-yogesh <[email protected]> * Update docs/demo.md Co-authored-by: b-yogesh <[email protected]> * Update docs/usage.md Co-authored-by: b-yogesh <[email protected]> * Initial component docs * Updated component docs * Update * Update chartlets.py/chartlets/component.py Co-authored-by: b-yogesh <[email protected]> * Update chartlets.py/chartlets/component.py Co-authored-by: b-yogesh <[email protected]> * Update chartlets.py/chartlets/components/box.py Co-authored-by: b-yogesh <[email protected]> * Update chartlets.py/chartlets/components/typography.py Co-authored-by: b-yogesh <[email protected]> --------- Co-authored-by: b-yogesh <[email protected]>
1 parent cf0c371 commit ee807d5

File tree

13 files changed

+117
-10
lines changed

13 files changed

+117
-10
lines changed

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 Brockmann Consult Development
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
11
# Chartlets
22

3-
`chartlets` is a framework for server-configured web-UI contributions.
3+
Chartlets is a software framework that allows websites developed with
4+
React to be extended by server-side UI contributions programmed in Python
5+
or other programming languages.
46

57
It comprises a [Python backend package](chartlets.py/README.md)
68
and a [JavaScript/React frontend package](chartlets.js/README.md).
79

10+
Please see the [Documentation]() for more information.
11+
12+
## Features
13+
14+
- Enhance your React web application by UI-contributions programmed in Python
15+
- Enhance your (Python) web API to serve server-side UI-contributions.
16+
- Uses [Material UI](https://mui.com/material-ui/) components and
17+
[Vega-Lite](https://vega.github.io/vega-lite/) charts.
18+
19+
## License
20+
21+
[MIT](https://github.com/bcdev/chartlets/blob/master/LICENSE)

chartlets.py/chartlets/component.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,30 @@
55

66
@dataclass(frozen=True)
77
class Component(ABC):
8+
"""Base class for components.
9+
Provides the common attributes that apply to all components.
10+
"""
811
# Common HTML properties
912
id: str | None = None
13+
"""HTML `id` property. Required for referring to this component."""
14+
1015
name: str | None = None
16+
"""HTML `name` property. Optional."""
17+
1118
value: bool | int | float | str | None = None
19+
"""HTML `value` property. Required for specific components."""
20+
1221
style: dict[str, Any] | None = None
22+
"""HTML `style` property. Optional."""
23+
1324
# We may add more here later
1425
#
1526
# Special non-HTML properties
1627
label: str | None = None
28+
"""Label used by many specific components. Optional """
29+
1730
children: list["Component"] | None = None
31+
"""Children used by many specific components. Optional """
1832

1933
@property
2034
def type(self):

chartlets.py/chartlets/components/box.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,11 @@
55

66
@dataclass(frozen=True)
77
class Box(Container):
8-
pass
8+
"""The Box component is a generic container for grouping other components.
9+
It's a fundamental building block. Think of it as an HTML `<div>` element.
10+
11+
Use the `style` attribute to layout the box and its child components.
12+
"""
13+
14+
component: str | None = None
15+
"""The component to be used, e.g., `div` or `span`."""

chartlets.py/chartlets/components/button.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,8 @@
55

66
@dataclass(frozen=True)
77
class Button(Component):
8+
"""Buttons allow users to take actions, and make choices,
9+
with a single tap."""
10+
811
text: str | None = None
12+
"""The button text."""

chartlets.py/chartlets/components/checkbox.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,11 @@
55

66
@dataclass(frozen=True)
77
class Checkbox(Component):
8+
"""Checkboxes allow the user to select one or more items from a set.
9+
They can be used to turn an option on or off."""
10+
811
value: bool | None = None
12+
"""The checkbox value."""
13+
914
label: str = ""
15+
"""The checkbox label."""

chartlets.py/chartlets/components/dropdown.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,8 @@
55

66
@dataclass(frozen=True)
77
class Dropdown(Component):
8+
"""Dropdown components are used for collecting user provided
9+
information from a list of options."""
10+
811
options: list[tuple[str, str | int | float]] = field(default_factory=list)
12+
"""The options given as a list of (label, value) pairs."""

chartlets.py/chartlets/components/plot.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@
88

99
@dataclass(frozen=True)
1010
class Plot(Component):
11+
"""The plot component is a container for a
12+
[Vega Altair](https://altair-viz.github.io/) chart."""
13+
1114
chart: alt.Chart | None = None
15+
"""The Vega Altair
16+
[chart object](https://altair-viz.github.io/user_guide/generated/toplevel/altair.Chart.html)."""
1217

1318
def to_dict(self) -> dict[str, Any]:
1419
d = super().to_dict()

chartlets.py/chartlets/components/typography.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,14 @@
55

66
@dataclass(frozen=True)
77
class Typography(Component):
8+
"""Use typography to present your design and content as clearly
9+
and efficiently as possible."""
10+
811
text: str | None = None
12+
"""Text to be displayed. Optional"""
13+
14+
color: str | None = None
15+
"""The color of the component."""
16+
17+
variant: str | None = None
18+
"""Applies the theme typography styles."""

chartlets.py/pyproject.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ dev = [
6060
]
6161
doc = [
6262
"mkdocs",
63-
"mkdocs-material"
63+
"mkdocs-material",
64+
"mkdocstrings",
65+
"mkdocstrings-python"
6466
]
6567
demo = [
6668
"pyaml",

0 commit comments

Comments
 (0)