Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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,480 changes: 794 additions & 686 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,8 @@
"dependencies": {
"@emotion/react": "^11.13.3",
"@emotion/styled": "^11.13.0",
"@mui/material": "^6.1.5",
"@mui/icons-material": "^6.2.1",
"@mui/material": "^6.2.1",
"chartlets": "file:../lib",
"react": "^18.3.1",
"react-dom": "^18.3.1",
Expand Down
3 changes: 2 additions & 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 Expand Up @@ -61,6 +61,7 @@
"zustand": "^5.0"
},
"peerDependencies": {
"@mui/icons-material": "^6.2.1",
"@mui/material": "^6.2.1",
"@mui/x-data-grid": ">=7",
"react": "^18.3.1",
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
@@ -1,9 +1,9 @@
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 @@ -55,8 +55,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}></Icon>}
endIcon={endIcon && <Icon iconName={endIcon}></Icon>}
onClick={handleClick}
>
{text}
Expand Down
20 changes: 20 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,20 @@
import * as MuiIcons from "@mui/icons-material";

interface IconProps {
iconName?: string;
}

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

const IconComponent = (MuiIcons as Record<string, React.ElementType>)[
iconName
];

if (!IconComponent) {
console.warn(`Icon "${iconName}" not found in @mui/icons-material`);
return null;
}

return <IconComponent />;
};
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
@@ -1,8 +1,8 @@
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 @@ -53,7 +53,7 @@ export function IconButton({
disabled={disabled}
onClick={handleClick}
>
<MuiIcon>{icon}</MuiIcon>
<Icon iconName={icon}></Icon>
</MuiIconButton>
</Tooltip>
);
Expand Down
4 changes: 2 additions & 2 deletions chartlets.js/packages/lib/src/plugins/mui/Tabs.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
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 @@ -57,7 +57,7 @@ export function Tabs({
label={tabState ? tabState.label : isString(tab) ? tab : ""}
icon={
tabState &&
tabState.icon && <MuiIcon>{tabState.icon}</MuiIcon>
tabState.icon && <Icon iconName={tabState.icon}></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 @@ -24,7 +24,7 @@ class Button(Component):
"""

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

Expand All @@ -49,10 +49,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 @@ -12,7 +12,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="ChatBubble",
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