Skip to content

Commit 4881c39

Browse files
Abstract IconButton
1 parent e30fc98 commit 4881c39

File tree

9 files changed

+21
-442
lines changed

9 files changed

+21
-442
lines changed

docs/pages/x/api/charts/toolbar-button.json

+2-161
Original file line numberDiff line numberDiff line change
@@ -1,171 +1,12 @@
11
{
2-
"props": {
3-
"action": {
4-
"type": {
5-
"name": "union",
6-
"description": "func<br>&#124;&nbsp;{ current?: { focusVisible: func } }"
7-
}
8-
},
9-
"centerRipple": { "type": { "name": "bool" }, "default": "false" },
10-
"color": {
11-
"type": {
12-
"name": "enum",
13-
"description": "'default'<br>&#124;&nbsp;'error'<br>&#124;&nbsp;'info'<br>&#124;&nbsp;'inherit'<br>&#124;&nbsp;'primary'<br>&#124;&nbsp;'secondary'<br>&#124;&nbsp;'success'<br>&#124;&nbsp;'warning'"
14-
},
15-
"default": "'default'"
16-
},
17-
"disabled": { "type": { "name": "bool" }, "default": "false" },
18-
"disableFocusRipple": { "type": { "name": "bool" }, "default": "false" },
19-
"disableRipple": { "type": { "name": "bool" }, "default": "false" },
20-
"disableTouchRipple": { "type": { "name": "bool" }, "default": "false" },
21-
"edge": {
22-
"type": {
23-
"name": "enum",
24-
"description": "'end'<br>&#124;&nbsp;'start'<br>&#124;&nbsp;false"
25-
},
26-
"default": "false"
27-
},
28-
"focusRipple": { "type": { "name": "bool" }, "default": "false" },
29-
"focusVisibleClassName": { "type": { "name": "string" } },
30-
"LinkComponent": { "type": { "name": "elementType" }, "default": "'a'" },
31-
"loading": { "type": { "name": "bool" }, "default": "null" },
32-
"loadingIndicator": {
33-
"type": { "name": "node" },
34-
"default": "<CircularProgress color=\"inherit\" size={16} />"
35-
},
36-
"onFocusVisible": { "type": { "name": "func" } },
37-
"size": {
38-
"type": {
39-
"name": "enum",
40-
"description": "'large'<br>&#124;&nbsp;'medium'<br>&#124;&nbsp;'small'"
41-
},
42-
"default": "'medium'"
43-
},
44-
"sx": {
45-
"type": {
46-
"name": "union",
47-
"description": "Array&lt;func<br>&#124;&nbsp;object<br>&#124;&nbsp;bool&gt;<br>&#124;&nbsp;func<br>&#124;&nbsp;object"
48-
},
49-
"additionalInfo": { "sx": true }
50-
},
51-
"TouchRippleProps": { "type": { "name": "object" } },
52-
"touchRippleRef": {
53-
"type": {
54-
"name": "union",
55-
"description": "func<br>&#124;&nbsp;{ current?: { pulsate: func, start: func, stop: func } }"
56-
}
57-
}
58-
},
2+
"props": {},
593
"name": "ToolbarButton",
604
"imports": [
615
"import { ToolbarButton } from '@mui/x-charts/Toolbar';",
626
"import { ToolbarButton } from '@mui/x-charts';",
637
"import { ToolbarButton } from '@mui/x-charts-pro';"
648
],
65-
"classes": [
66-
{
67-
"key": "colorError",
68-
"className": "MuiToolbarButton-colorError",
69-
"description": "Styles applied to the root element if `color=\"error\"`.",
70-
"isGlobal": false
71-
},
72-
{
73-
"key": "colorInfo",
74-
"className": "MuiToolbarButton-colorInfo",
75-
"description": "Styles applied to the root element if `color=\"info\"`.",
76-
"isGlobal": false
77-
},
78-
{
79-
"key": "colorInherit",
80-
"className": "MuiToolbarButton-colorInherit",
81-
"description": "Styles applied to the root element if `color=\"inherit\"`.",
82-
"isGlobal": false
83-
},
84-
{
85-
"key": "colorPrimary",
86-
"className": "MuiToolbarButton-colorPrimary",
87-
"description": "Styles applied to the root element if `color=\"primary\"`.",
88-
"isGlobal": false
89-
},
90-
{
91-
"key": "colorSecondary",
92-
"className": "MuiToolbarButton-colorSecondary",
93-
"description": "Styles applied to the root element if `color=\"secondary\"`.",
94-
"isGlobal": false
95-
},
96-
{
97-
"key": "colorSuccess",
98-
"className": "MuiToolbarButton-colorSuccess",
99-
"description": "Styles applied to the root element if `color=\"success\"`.",
100-
"isGlobal": false
101-
},
102-
{
103-
"key": "colorWarning",
104-
"className": "MuiToolbarButton-colorWarning",
105-
"description": "Styles applied to the root element if `color=\"warning\"`.",
106-
"isGlobal": false
107-
},
108-
{
109-
"key": "disabled",
110-
"className": "Mui-disabled",
111-
"description": "State class applied to the root element if `disabled={true}`.",
112-
"isGlobal": true
113-
},
114-
{
115-
"key": "edgeEnd",
116-
"className": "MuiToolbarButton-edgeEnd",
117-
"description": "Styles applied to the root element if `edge=\"end\"`.",
118-
"isGlobal": false
119-
},
120-
{
121-
"key": "edgeStart",
122-
"className": "MuiToolbarButton-edgeStart",
123-
"description": "Styles applied to the root element if `edge=\"start\"`.",
124-
"isGlobal": false
125-
},
126-
{
127-
"key": "loading",
128-
"className": "MuiToolbarButton-loading",
129-
"description": "Styles applied to the root element if `loading={true}`.",
130-
"isGlobal": false
131-
},
132-
{
133-
"key": "loadingIndicator",
134-
"className": "MuiToolbarButton-loadingIndicator",
135-
"description": "Styles applied to the loadingIndicator element.",
136-
"isGlobal": false
137-
},
138-
{
139-
"key": "loadingWrapper",
140-
"className": "MuiToolbarButton-loadingWrapper",
141-
"description": "Styles applied to the loadingWrapper element.",
142-
"isGlobal": false
143-
},
144-
{
145-
"key": "root",
146-
"className": "MuiToolbarButton-root",
147-
"description": "Styles applied to the root element.",
148-
"isGlobal": false
149-
},
150-
{
151-
"key": "sizeLarge",
152-
"className": "MuiToolbarButton-sizeLarge",
153-
"description": "Styles applied to the root element if `size=\"large\"`.",
154-
"isGlobal": false
155-
},
156-
{
157-
"key": "sizeMedium",
158-
"className": "MuiToolbarButton-sizeMedium",
159-
"description": "Styles applied to the root element if `size=\"medium\"`.",
160-
"isGlobal": false
161-
},
162-
{
163-
"key": "sizeSmall",
164-
"className": "MuiToolbarButton-sizeSmall",
165-
"description": "Styles applied to the root element if `size=\"small\"`.",
166-
"isGlobal": false
167-
}
168-
],
9+
"classes": [],
16910
"muiName": "MuiToolbarButton",
17011
"filename": "/packages/x-charts/src/Toolbar/ToolbarButton.tsx",
17112
"inheritance": null,
Original file line numberDiff line numberDiff line change
@@ -1,136 +1 @@
1-
{
2-
"componentDescription": "",
3-
"propDescriptions": {
4-
"action": {
5-
"description": "A ref for imperative actions. It currently only supports <code>focusVisible()</code> action."
6-
},
7-
"centerRipple": {
8-
"description": "If <code>true</code>, the ripples are centered. They won&#39;t start at the cursor interaction position."
9-
},
10-
"color": {
11-
"description": "The color of the component. It supports both default and custom theme colors, which can be added as shown in the <a href=\"https://mui.com/material-ui/customization/palette/#custom-colors\">palette customization guide</a>."
12-
},
13-
"disabled": { "description": "If <code>true</code>, the component is disabled." },
14-
"disableFocusRipple": {
15-
"description": "If <code>true</code>, the keyboard focus ripple is disabled."
16-
},
17-
"disableRipple": {
18-
"description": "If <code>true</code>, the ripple effect is disabled.<br>⚠️ Without a ripple there is no styling for :focus-visible by default. Be sure to highlight the element by applying separate styles with the <code>.Mui-focusVisible</code> class."
19-
},
20-
"disableTouchRipple": {
21-
"description": "If <code>true</code>, the touch ripple effect is disabled."
22-
},
23-
"edge": {
24-
"description": "If given, uses a negative margin to counteract the padding on one side (this is often helpful for aligning the left or right side of the icon with content above or below, without ruining the border size and shape)."
25-
},
26-
"focusRipple": {
27-
"description": "If <code>true</code>, the base button will have a keyboard focus ripple."
28-
},
29-
"focusVisibleClassName": {
30-
"description": "This prop can help identify which element has keyboard focus. The class name will be applied when the element gains the focus through keyboard interaction. It&#39;s a polyfill for the <a href=\"https://drafts.csswg.org/selectors-4/#the-focus-visible-pseudo\">CSS :focus-visible selector</a>. The rationale for using this feature <a href=\"https://github.com/WICG/focus-visible/blob/HEAD/explainer.md\">is explained here</a>. A <a href=\"https://github.com/WICG/focus-visible\">polyfill can be used</a> to apply a <code>focus-visible</code> class to other components if needed."
31-
},
32-
"LinkComponent": {
33-
"description": "The component used to render a link when the <code>href</code> prop is provided."
34-
},
35-
"loading": {
36-
"description": "If <code>true</code>, the loading indicator is visible and the button is disabled. If <code>true \\| false</code>, the loading wrapper is always rendered before the children to prevent <a href=\"https://github.com/mui/material-ui/issues/27853\">Google Translation Crash</a>."
37-
},
38-
"loadingIndicator": {
39-
"description": "Element placed before the children if the button is in loading state. The node should contain an element with <code>role=&quot;progressbar&quot;</code> with an accessible name. By default, it renders a <code>CircularProgress</code> that is labeled by the button itself."
40-
},
41-
"onFocusVisible": {
42-
"description": "Callback fired when the component is focused with a keyboard. We trigger a <code>onFocus</code> callback too."
43-
},
44-
"size": {
45-
"description": "The size of the component. <code>small</code> is equivalent to the dense button styling."
46-
},
47-
"sx": {
48-
"description": "The system prop that allows defining system overrides as well as additional CSS styles."
49-
},
50-
"TouchRippleProps": { "description": "Props applied to the <code>TouchRipple</code> element." },
51-
"touchRippleRef": {
52-
"description": "A ref that points to the <code>TouchRipple</code> element."
53-
}
54-
},
55-
"classDescriptions": {
56-
"colorError": {
57-
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
58-
"nodeName": "the root element",
59-
"conditions": "<code>color=\"error\"</code>"
60-
},
61-
"colorInfo": {
62-
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
63-
"nodeName": "the root element",
64-
"conditions": "<code>color=\"info\"</code>"
65-
},
66-
"colorInherit": {
67-
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
68-
"nodeName": "the root element",
69-
"conditions": "<code>color=\"inherit\"</code>"
70-
},
71-
"colorPrimary": {
72-
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
73-
"nodeName": "the root element",
74-
"conditions": "<code>color=\"primary\"</code>"
75-
},
76-
"colorSecondary": {
77-
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
78-
"nodeName": "the root element",
79-
"conditions": "<code>color=\"secondary\"</code>"
80-
},
81-
"colorSuccess": {
82-
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
83-
"nodeName": "the root element",
84-
"conditions": "<code>color=\"success\"</code>"
85-
},
86-
"colorWarning": {
87-
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
88-
"nodeName": "the root element",
89-
"conditions": "<code>color=\"warning\"</code>"
90-
},
91-
"disabled": {
92-
"description": "State class applied to {{nodeName}} if {{conditions}}.",
93-
"nodeName": "the root element",
94-
"conditions": "<code>disabled={true}</code>"
95-
},
96-
"edgeEnd": {
97-
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
98-
"nodeName": "the root element",
99-
"conditions": "<code>edge=\"end\"</code>"
100-
},
101-
"edgeStart": {
102-
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
103-
"nodeName": "the root element",
104-
"conditions": "<code>edge=\"start\"</code>"
105-
},
106-
"loading": {
107-
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
108-
"nodeName": "the root element",
109-
"conditions": "<code>loading={true}</code>"
110-
},
111-
"loadingIndicator": {
112-
"description": "Styles applied to {{nodeName}}.",
113-
"nodeName": "the loadingIndicator element"
114-
},
115-
"loadingWrapper": {
116-
"description": "Styles applied to {{nodeName}}.",
117-
"nodeName": "the loadingWrapper element"
118-
},
119-
"root": { "description": "Styles applied to the root element." },
120-
"sizeLarge": {
121-
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
122-
"nodeName": "the root element",
123-
"conditions": "<code>size=\"large\"</code>"
124-
},
125-
"sizeMedium": {
126-
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
127-
"nodeName": "the root element",
128-
"conditions": "<code>size=\"medium\"</code>"
129-
},
130-
"sizeSmall": {
131-
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
132-
"nodeName": "the root element",
133-
"conditions": "<code>size=\"small\"</code>"
134-
}
135-
}
136-
}
1+
{ "componentDescription": "", "propDescriptions": {}, "classDescriptions": {} }

packages/x-charts-pro/src/ChartsToolbarPro/internal/ChartsToolbarZoomInButton.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,14 @@ interface ChartsToolbarZoomInButtonProps {
2121
}
2222

2323
export function ChartsToolbarZoomInButton({ slots, slotProps }: ChartsToolbarZoomInButtonProps) {
24-
const buttonRef = React.useRef<HTMLButtonElement>(null);
2524
const { instance } = useChartContext<[UseChartProZoomSignature]>();
2625
const ZoomInIcon = slots?.zoomInIcon ?? materialSlots.zoomInIcon;
2726
const Tooltip = slots?.baseTooltip ?? materialSlots.baseTooltip;
2827
const { localeText } = useChartsLocalization();
2928

3029
return (
3130
<Tooltip title={localeText.zoomIn}>
32-
<ToolbarButton ref={buttonRef} onClick={() => instance.zoomIn()}>
31+
<ToolbarButton onClick={() => instance.zoomIn()}>
3332
<ZoomInIcon {...slotProps?.zoomInIcon} />
3433
</ToolbarButton>
3534
</Tooltip>

packages/x-charts-pro/src/ChartsToolbarPro/internal/ChartsToolbarZoomOutButton.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,14 @@ interface ChartsToolbarZoomOutButtonProps {
2121
}
2222

2323
export function ChartsToolbarZoomOutButton({ slots, slotProps }: ChartsToolbarZoomOutButtonProps) {
24-
const buttonRef = React.useRef<HTMLButtonElement>(null);
2524
const { instance } = useChartContext<[UseChartProZoomSignature]>();
2625
const ZoomOutIcon = slots?.zoomOutIcon ?? materialSlots.zoomOutIcon;
2726
const Tooltip = slots?.baseTooltip ?? materialSlots.baseTooltip;
2827
const { localeText } = useChartsLocalization();
2928

3029
return (
3130
<Tooltip title={localeText.zoomOut}>
32-
<ToolbarButton ref={buttonRef} onClick={() => instance.zoomOut()}>
31+
<ToolbarButton onClick={() => instance.zoomOut()}>
3332
<ZoomOutIcon {...slotProps?.zoomOutIcon} />
3433
</ToolbarButton>
3534
</Tooltip>

0 commit comments

Comments
 (0)