Skip to content

Commit 71d0172

Browse files
committed
add text and color parameter to Typography component
1 parent 4873af5 commit 71d0172

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

chartlets.js/CHANGES.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## Version 0.1.7 (in development)
2+
3+
* Typology component now allows color and text arguments.
4+
If a user uses text and children, the text argument replaces the
5+
children.
6+
17
## Version 0.1.6 (from 2025/06/18)
28

39
* Implemented dynamic resizing for Vega Charts when the side panel's

chartlets.js/packages/lib/src/plugins/mui/Typography.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ interface TypographyState extends ComponentState {
99
gutterBottom?: boolean;
1010
noWrap?: boolean;
1111
variant?: TypographyVariant;
12+
text?: string;
13+
color?: string;
1214
}
1315

1416
interface TypographyProps extends ComponentProps, TypographyState {}
@@ -20,9 +22,13 @@ export const Typography = ({
2022
gutterBottom,
2123
noWrap,
2224
variant,
25+
text,
26+
color,
2327
children: nodes,
2428
onChange,
2529
}: TypographyProps) => {
30+
nodes = text ? [text] : nodes;
31+
2632
return (
2733
<MuiTypography
2834
id={id}
@@ -31,6 +37,7 @@ export const Typography = ({
3137
gutterBottom={gutterBottom}
3238
noWrap={noWrap}
3339
variant={variant}
40+
color={color}
3441
>
3542
<Children nodes={nodes} onChange={onChange} />
3643
</MuiTypography>

chartlets.py/demo/my_extension/my_panel_5.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def render_panel(
3939
ariaDescribedBy="dialog-description",
4040
)
4141

42-
info_text = Typography(id="info_text")
42+
info_text = Typography(id="info_text", color="grey")
4343

4444
return Box(
4545
style={
@@ -63,17 +63,17 @@ def dialog_on_open(ctx: Context, button) -> bool:
6363
@panel.callback(
6464
Input("okay_button", "clicked"),
6565
Output("dialog", "open"),
66-
Output("info_text", "children"),
66+
Output("info_text", "text"),
6767
)
68-
def dialog_on_close(ctx: Context, button) -> tuple[bool, list[str]]:
69-
return False, ["Okay button was clicked!"]
68+
def dialog_on_close(ctx: Context, button) -> tuple[bool, str]:
69+
return False, "Okay button was clicked!"
7070

7171

7272
# noinspection PyUnusedLocal
7373
@panel.callback(
7474
Input("not_okay_button", "clicked"),
7575
Output("dialog", "open"),
76-
Output("info_text", "children"),
76+
Output("info_text", "text"),
7777
)
78-
def dialog_on_close(ctx: Context, button) -> tuple[bool, list[str]]:
79-
return False, ["Not okay button was clicked!"]
78+
def dialog_on_close(ctx: Context, button) -> tuple[bool, str]:
79+
return False, "Not okay button was clicked!"

0 commit comments

Comments
 (0)