Skip to content

Commit 2dd8f1a

Browse files
committed
Python part of Divider
1 parent e32513f commit 2dd8f1a

File tree

6 files changed

+59
-5
lines changed

6 files changed

+59
-5
lines changed

chartlets.js/CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
- using `return` object with `schema` property for callback return values
3939

4040
* New (MUI) components
41+
- `Divider`
4142
- `LinearProgress`
4243
- `RadioGroup` and `Radio`
4344
- `Switch`

chartlets.py/CHANGES.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@
1919
* Added `tooltip` property to interactive components.
2020

2121
* New components
22-
- `Switch`
22+
- `Divider`
2323
- `RadioGroup` and `Radio`
24-
- `Tabs`
24+
- `Switch`
2525
- `Slider`
26-
26+
- `Tabs` and `Tab`
27+
2728
## Version 0.0.29 (from 2024/11/26)
2829

2930
* Fixed a bug that prevents using annotations of type `dict` or `dict[str, T]`.

chartlets.py/chartlets/components/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from .button import IconButton
44
from .checkbox import Checkbox
55
from .charts.vega import VegaChart
6+
from .divider import Divider
67
from .progress import CircularProgress
78
from .progress import CircularProgressWithLabel
89
from .progress import LinearProgress
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from dataclasses import dataclass
2+
3+
from chartlets import Container
4+
5+
6+
@dataclass(frozen=True)
7+
class Divider(Container):
8+
"""The Divider component provides a thin,
9+
unobtrusive line for grouping elements to reinforce visual hierarchy.
10+
"""
11+
12+
label: str | None = None
13+
"""The text label."""
14+
15+
orientation: str | None = None
16+
"""The orientation. Can be `horizontal` (default) or `vertical`."""
17+
18+
variant: str | None = None
19+
"""The variant. One of `fullWidth ` (default), `inset`, and `middle`."""
20+
21+
flexItem: bool | None = None
22+
"""Use the `flexItem` prop to display the divider when it's being
23+
used in a flex container.
24+
"""
25+
26+
textAlign: str | None = None
27+
"""Use the `textAlign` prop to align elements that are
28+
wrapped by the divider. One of `center` (default), `left`, and `right`.
29+
"""

chartlets.py/demo/my_extension/my_panel_3.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from chartlets import Component, Input, State, Output
2-
from chartlets.components import Box, Select, Checkbox, Typography
2+
from chartlets.components import Box, Divider, Select, Checkbox, Typography
33

44
from server.context import Context
55
from server.panel import Panel
@@ -50,7 +50,7 @@ def render_panel(
5050
"height": "100%",
5151
"gap": "6px",
5252
},
53-
children=[opaque_checkbox, color_select, info_text],
53+
children=[opaque_checkbox, color_select, Divider(), info_text],
5454
)
5555

5656

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from chartlets.components import Divider
2+
from tests.component_test import make_base
3+
4+
5+
class DividerTest(make_base(Divider)):
6+
7+
def test_is_json_serializable(self):
8+
self.assert_is_json_serializable(
9+
self.cls(
10+
textAlign="center",
11+
variant="middle",
12+
flexItem=True,
13+
children=["Options"],
14+
),
15+
{
16+
"type": "Divider",
17+
"textAlign": "center",
18+
"variant": "middle",
19+
"flexItem": True,
20+
"children": ["Options"],
21+
},
22+
)

0 commit comments

Comments
 (0)