Skip to content

Commit d95e66f

Browse files
committed
Added Python Tabs class
1 parent f77b23f commit d95e66f

File tree

4 files changed

+35
-0
lines changed

4 files changed

+35
-0
lines changed

chartlets.py/CHANGES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
- using `schema` instead of `type` property for callback arguments
1717
- using `return` object with `schema` property for callback return values
1818

19+
* New (MUI) components:
20+
- `Tabs`
21+
1922

2023
## Version 0.0.29 (from 2024/11/26)
2124

chartlets.py/chartlets/components/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@
88
from .progress import LinearProgressWithLabel
99
from .charts.vega import VegaChart
1010
from .select import Select
11+
from .tabs import Tabs
1112
from .typography import Typography
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from dataclasses import dataclass, field
2+
3+
from chartlets import Component
4+
5+
6+
@dataclass(frozen=True)
7+
class Tabs(Component):
8+
"""Select components are used for collecting user provided
9+
information from a list of options."""
10+
11+
value: int | None = None
12+
"""The currently selected tab index."""
13+
14+
titles: list[str] = field(default_factory=list)
15+
"""The list of tab titles."""
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from chartlets.components import Tabs
2+
from tests.component_test import make_base
3+
4+
5+
class TabsTest(make_base(Tabs)):
6+
7+
def test_is_json_serializable(self):
8+
self.assert_is_json_serializable(
9+
self.cls(titles=["A", "B", "C"]),
10+
{"type": "Tabs", "titles": ["A", "B", "C"]},
11+
)
12+
13+
self.assert_is_json_serializable(
14+
self.cls(value=1, titles=["A", "B", "C"]),
15+
{"type": "Tabs", "value": 1, "titles": ["A", "B", "C"]},
16+
)

0 commit comments

Comments
 (0)