|
| 1 | +# Copyright (c) 2019-2026 by Brockmann Consult Development team |
| 2 | +# Permissions are hereby granted under the terms of the MIT License: |
| 3 | +# https://opensource.org/licenses/MIT. |
| 4 | + |
| 5 | + |
| 6 | +from chartlets import Component, State |
| 7 | +from chartlets.components import ( |
| 8 | + Accordion, |
| 9 | + Typography, |
| 10 | + Box, |
| 11 | + Table |
| 12 | +) |
| 13 | +from chartlets.components.table import TableColumn, TableRow |
| 14 | + |
| 15 | + |
| 16 | +from server.context import Context |
| 17 | +from server.panel import Panel |
| 18 | + |
| 19 | + |
| 20 | +panel = Panel(__name__, title="Panel I") |
| 21 | + |
| 22 | + |
| 23 | +# noinspection PyUnusedLocal |
| 24 | +@panel.layout() |
| 25 | +def render_panel( |
| 26 | + ctx: Context, |
| 27 | +) -> Component: |
| 28 | + columns: list[TableColumn] = [ |
| 29 | + {"id": "id", "label": "ID", "sortDirection": "desc"}, |
| 30 | + { |
| 31 | + "id": "firstName", |
| 32 | + "label": "First Name", |
| 33 | + "align": "left", |
| 34 | + "sortDirection": "desc", |
| 35 | + }, |
| 36 | + {"id": "lastName", "label": "Last Name", "align": "center"}, |
| 37 | + {"id": "age", "label": "Age"}, |
| 38 | + ] |
| 39 | + |
| 40 | + rows: TableRow = [ |
| 41 | + ["1", "John", "Doe", 30], |
| 42 | + ["2", "Jane", "Smith", 25], |
| 43 | + ["3", "Peter", "Jones", 40], |
| 44 | + ] |
| 45 | + |
| 46 | + table = Table(id="table", rows=rows, columns=columns, hover=True) |
| 47 | + |
| 48 | + info_text = Typography(id="info_text", children=["This is a text."], style={"margin": "30px"}) |
| 49 | + |
| 50 | + accordion1 = Accordion( |
| 51 | + id="accordion1", |
| 52 | + label="Accordion No.1", |
| 53 | + icon="arrow_drop_down", |
| 54 | + children=[info_text], |
| 55 | + ) |
| 56 | + |
| 57 | + accordion2 = Accordion( |
| 58 | + id="accordion2", |
| 59 | + label="Accordion No.2", |
| 60 | + icon="arrow_drop_down", |
| 61 | + # expanded=True, |
| 62 | + # disabled=True |
| 63 | + children=[table, info_text], |
| 64 | + ) |
| 65 | + |
| 66 | + return Box( |
| 67 | + style={ |
| 68 | + "display": "flex", |
| 69 | + "flexDirection": "column", |
| 70 | + "width": "100%", |
| 71 | + "height": "100%", |
| 72 | + }, |
| 73 | + children=[accordion1, accordion2], |
| 74 | + ) |
0 commit comments