Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions chartlets.js/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## Version 0.1.8 (in development)

* Added icon support for `Button`, `IconButton` and `Tabs` components.
(#124).

## Version 0.1.7 (from 2025/12/03)

* Updated dependencies
Expand Down
1,574 changes: 845 additions & 729 deletions chartlets.js/package-lock.json

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions chartlets.js/packages/demo/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chartlets-demo",
"version": "0.1.8.dev0",
"version": "0.1.8-dev.0",
"description": "Demonstrator for the Chartlets framework.",
"type": "module",
"files": [
Expand Down Expand Up @@ -30,7 +30,7 @@
"dependencies": {
"@emotion/react": "^11.13.3",
"@emotion/styled": "^11.13.0",
"@mui/material": "^6.1.5",
"@mui/material": "^6.2.1",
"chartlets": "file:../lib",
"react": "^18.3.1",
"react-dom": "^18.3.1",
Expand All @@ -45,6 +45,7 @@
"@eslint/compat": "^1.4.0",
"@eslint/eslintrc": "^3.3.1",
"@eslint/js": "^9.38.0",
"@fontsource/material-icons": "^5.1.1",
"@types/node": "^20.11.17",
"@types/react": "^18.3.11",
"@types/react-dom": "^18.3.1",
Expand Down
1 change: 1 addition & 0 deletions chartlets.js/packages/demo/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import ReactDOM from "react-dom/client";

import App from "./App";

import "@fontsource/material-icons";
import "./index.css";

ReactDOM.createRoot(document.getElementById("root")!).render(
Expand Down
2 changes: 1 addition & 1 deletion chartlets.js/packages/lib/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chartlets",
"version": "0.1.8.dev0",
"version": "0.1.8-dev.0",
"description": "An experimental library for integrating interactive charts into existing JavaScript applications.",
"type": "module",
"files": [
Expand Down
6 changes: 3 additions & 3 deletions chartlets.js/packages/lib/src/plugins/mui/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

import { type MouseEvent } from "react";
import MuiButton from "@mui/material/Button";
import MuiIcon from "@mui/material/Icon";

import type { ComponentProps, ComponentState } from "@/index";
import { Tooltip } from "./Tooltip";
import { Icon } from "./Icon";

interface ButtonState extends ComponentState {
text?: string;
Expand Down Expand Up @@ -61,8 +61,8 @@ export function Button({
variant={variant}
color={color}
disabled={disabled}
startIcon={startIcon && <MuiIcon>{startIcon}</MuiIcon>}
endIcon={endIcon && <MuiIcon>{endIcon}</MuiIcon>}
startIcon={startIcon && <Icon iconName={startIcon} />}
endIcon={endIcon && <Icon iconName={endIcon} />}
onClick={handleClick}
>
{text}
Expand Down
30 changes: 30 additions & 0 deletions chartlets.js/packages/lib/src/plugins/mui/Icon.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright (c) 2019-2026 by Brockmann Consult Development team
* Permissions are hereby granted under the terms of the MIT License:
* https://opensource.org/licenses/MIT.
*/

import { describe, it, expect } from "vitest";
import { render, screen } from "@testing-library/react";
import { Icon } from "./Icon";

describe("Icon", () => {
it("should render nothing if iconName is not given", () => {
const { container } = render(<Icon />);
expect(container.firstChild).toBeNull();
});

it("should render the iconName", () => {
render(<Icon iconName="sunny" />);
expect(screen.getByText("sunny")).not.toBeUndefined();
});

it("should render a MUI Icon root element", () => {
render(<Icon iconName="home" />);

const icon = screen.getByText("home");
// MUI Icon renders as a <span> with MuiIcon-root class in default configuration
expect(icon.tagName.toLowerCase()).toEqual("span");
expect(icon.className).toContain("MuiIcon-root");
});
});
27 changes: 27 additions & 0 deletions chartlets.js/packages/lib/src/plugins/mui/Icon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright (c) 2019-2026 by Brockmann Consult Development team
* Permissions are hereby granted under the terms of the MIT License:
* https://opensource.org/licenses/MIT.
*/

import MuiIcon from "@mui/material/Icon";

interface IconProps {
iconName?: string;
}

export const Icon = ({ iconName }: IconProps) => {
if (!iconName) return null;

return (
<MuiIcon
sx={{
fontFamily: "Material Icons",
textTransform: "none",
lineHeight: 1,
}}
>
{iconName}
</MuiIcon>
);
};
4 changes: 2 additions & 2 deletions chartlets.js/packages/lib/src/plugins/mui/IconButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

import { type MouseEvent } from "react";
import MuiIconButton from "@mui/material/IconButton";
import MuiIcon from "@mui/material/Icon";

import type { ComponentState, ComponentProps } from "@/index";
import { Icon } from "./Icon";
import { Tooltip } from "./Tooltip";

interface IconButtonState extends ComponentState {
Expand Down Expand Up @@ -59,7 +59,7 @@ export function IconButton({
disabled={disabled}
onClick={handleClick}
>
<MuiIcon>{icon}</MuiIcon>
<Icon iconName={icon} />
</MuiIconButton>
</Tooltip>
);
Expand Down
5 changes: 2 additions & 3 deletions chartlets.js/packages/lib/src/plugins/mui/Tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
*/

import MuiBox from "@mui/material/Box";
import MuiIcon from "@mui/material/Icon";
import MuiTabs from "@mui/material/Tabs";
import MuiTab from "@mui/material/Tab";

import type { ComponentProps, ComponentState } from "@/index";
import type { SyntheticEvent } from "react";
import { Box } from "@/plugins/mui/Box";
import { Icon } from "./Icon";
import { isString } from "@/utils/isString";
import { isComponentState } from "@/types/state/component";

Expand Down Expand Up @@ -62,8 +62,7 @@ export function Tabs({
key={index}
label={tabState ? tabState.label : isString(tab) ? tab : ""}
icon={
tabState &&
tabState.icon && <MuiIcon>{tabState.icon}</MuiIcon>
tabState && tabState.icon && <Icon iconName={tabState.icon} />
}
disabled={disabled || (tabState && tabState.disabled)}
/>
Expand Down
3 changes: 3 additions & 0 deletions chartlets.py/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## Version 0.1.8 (in development)

* Added `size` and removed `variant` property from `IconButton`
component to align with component in chartlets.js. (#124)

## Version 0.1.7 (from 2025/12/03)

* Updated dependencies
Expand Down
12 changes: 6 additions & 6 deletions chartlets.py/chartlets/components/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Button(Component):
"""

variant: str | None = None
"""The button variant.
"""The button variant.
One "contained" | "outlined" | "text". Defaults to "text".
"""

Expand All @@ -53,10 +53,10 @@ class IconButton(Component):
"info" | "warning". Defaults to "primary".
"""

variant: str | None = None
"""The button variant.
One "contained" | "outlined" | "text". Defaults to "text".
"""

tooltip: str | None = None
"""Tooltip title. Optional."""

size: str | None = None
"""The button size.
One of "small" | "medium" | "large". Defaults to "medium".
"""
8 changes: 7 additions & 1 deletion chartlets.py/demo/my_extension/my_panel_5.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@
def render_panel(
ctx: Context,
) -> Component:
open_button = Button(id="open_button", text="Open Dialog")
open_button = Button(
id="open_button",
text="Open Dialog",
startIcon="chat_bubble",
variant="outlined",
color="warning",
)
okay_button = Button(id="okay_button", text="Okay")
not_okay_button = Button(id="not_okay_button", text="Not okay")
dialog = Dialog(
Expand Down