File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66 - `vite: ^7.1.11`
77 - `vitest: ^3.2.4`
88
9+ * Added icon support for ` Button ` , ` IconButton ` and ` Tabs ` components.
10+ (#124 ).
11+
912## Version 0.1.7 (from 2025/12/03)
1013
1114* Updated dependencies
Original file line number Diff line number Diff line change 3030 "dependencies" : {
3131 "@emotion/react" : " ^11.13.3" ,
3232 "@emotion/styled" : " ^11.13.0" ,
33- "@mui/material" : " ^6.1.5 " ,
33+ "@mui/material" : " ^6.2.1 " ,
3434 "chartlets" : " file:../lib" ,
3535 "react" : " ^18.3.1" ,
3636 "react-dom" : " ^18.3.1" ,
4545 "@eslint/compat" : " ^1.4.0" ,
4646 "@eslint/eslintrc" : " ^3.3.1" ,
4747 "@eslint/js" : " ^9.38.0" ,
48+ "@fontsource/material-icons" : " ^5.1.1" ,
4849 "@types/node" : " ^20.11.17" ,
4950 "@types/react" : " ^18.3.11" ,
5051 "@types/react-dom" : " ^18.3.1" ,
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import ReactDOM from "react-dom/client";
99
1010import App from "./App" ;
1111
12+ import "@fontsource/material-icons" ;
1213import "./index.css" ;
1314
1415ReactDOM . createRoot ( document . getElementById ( "root" ) ! ) . render (
Original file line number Diff line number Diff line change 66
77import { type MouseEvent } from "react" ;
88import MuiButton from "@mui/material/Button" ;
9- import MuiIcon from "@mui/material/Icon" ;
109
1110import type { ComponentProps , ComponentState } from "@/index" ;
1211import { Tooltip } from "./Tooltip" ;
12+ import { Icon } from "./Icon" ;
1313
1414interface ButtonState extends ComponentState {
1515 text ?: string ;
@@ -61,8 +61,8 @@ export function Button({
6161 variant = { variant }
6262 color = { color }
6363 disabled = { disabled }
64- startIcon = { startIcon && < MuiIcon > { startIcon } </ MuiIcon > }
65- endIcon = { endIcon && < MuiIcon > { endIcon } </ MuiIcon > }
64+ startIcon = { startIcon && < Icon iconName = { startIcon } / >}
65+ endIcon = { endIcon && < Icon iconName = { endIcon } / >}
6666 onClick = { handleClick }
6767 >
6868 { text }
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright (c) 2019-2026 by Brockmann Consult Development team
3+ * Permissions are hereby granted under the terms of the MIT License:
4+ * https://opensource.org/licenses/MIT.
5+ */
6+
7+ import { describe , it , expect } from "vitest" ;
8+ import { render , screen } from "@testing-library/react" ;
9+ import { Icon } from "./Icon" ;
10+
11+ describe ( "Icon" , ( ) => {
12+ it ( "should render nothing if iconName is not given" , ( ) => {
13+ const { container } = render ( < Icon /> ) ;
14+ expect ( container . firstChild ) . toBeNull ( ) ;
15+ } ) ;
16+
17+ it ( "should render the iconName" , ( ) => {
18+ render ( < Icon iconName = "sunny" /> ) ;
19+ expect ( screen . getByText ( "sunny" ) ) . not . toBeUndefined ( ) ;
20+ } ) ;
21+
22+ it ( "should render a MUI Icon root element" , ( ) => {
23+ render ( < Icon iconName = "home" /> ) ;
24+
25+ const icon = screen . getByText ( "home" ) ;
26+ // MUI Icon renders as a <span> with MuiIcon-root class in default configuration
27+ expect ( icon . tagName . toLowerCase ( ) ) . toEqual ( "span" ) ;
28+ expect ( icon . className ) . toContain ( "MuiIcon-root" ) ;
29+ } ) ;
30+ } ) ;
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright (c) 2019-2026 by Brockmann Consult Development team
3+ * Permissions are hereby granted under the terms of the MIT License:
4+ * https://opensource.org/licenses/MIT.
5+ */
6+
7+ import MuiIcon from "@mui/material/Icon" ;
8+
9+ interface IconProps {
10+ iconName ?: string ;
11+ }
12+
13+ export const Icon = ( { iconName } : IconProps ) => {
14+ if ( ! iconName ) return null ;
15+
16+ return (
17+ < MuiIcon
18+ sx = { {
19+ fontFamily : "Material Icons" ,
20+ textTransform : "none" ,
21+ lineHeight : 1 ,
22+ } }
23+ >
24+ { iconName }
25+ </ MuiIcon >
26+ ) ;
27+ } ;
Original file line number Diff line number Diff line change 66
77import { type MouseEvent } from "react" ;
88import MuiIconButton from "@mui/material/IconButton" ;
9- import MuiIcon from "@mui/material/Icon" ;
109
1110import type { ComponentState , ComponentProps } from "@/index" ;
11+ import { Icon } from "./Icon" ;
1212import { Tooltip } from "./Tooltip" ;
1313
1414interface IconButtonState extends ComponentState {
@@ -59,7 +59,7 @@ export function IconButton({
5959 disabled = { disabled }
6060 onClick = { handleClick }
6161 >
62- < MuiIcon > { icon } </ MuiIcon >
62+ < Icon iconName = { icon } / >
6363 </ MuiIconButton >
6464 </ Tooltip >
6565 ) ;
Original file line number Diff line number Diff line change 55 */
66
77import MuiBox from "@mui/material/Box" ;
8- import MuiIcon from "@mui/material/Icon" ;
98import MuiTabs from "@mui/material/Tabs" ;
109import MuiTab from "@mui/material/Tab" ;
1110
1211import type { ComponentProps , ComponentState } from "@/index" ;
1312import type { SyntheticEvent } from "react" ;
1413import { Box } from "@/plugins/mui/Box" ;
14+ import { Icon } from "./Icon" ;
1515import { isString } from "@/utils/isString" ;
1616import { isComponentState } from "@/types/state/component" ;
1717
@@ -62,8 +62,7 @@ export function Tabs({
6262 key = { index }
6363 label = { tabState ? tabState . label : isString ( tab ) ? tab : "" }
6464 icon = {
65- tabState &&
66- tabState . icon && < MuiIcon > { tabState . icon } </ MuiIcon >
65+ tabState && tabState . icon && < Icon iconName = { tabState . icon } />
6766 }
6867 disabled = { disabled || ( tabState && tabState . disabled ) }
6968 />
Original file line number Diff line number Diff line change 11## Version 0.1.8 (in development)
22
3+ * Added ` size ` and removed ` variant ` property from ` IconButton `
4+ component to align with component in chartlets.js. (#124 )
5+
36## Version 0.1.7 (from 2025/12/03)
47
58* Updated dependencies
You can’t perform that action at this time.
0 commit comments