2020-01-15 20:42:02 +05:00
|
|
|
import "./ToolIcon.scss";
|
|
|
|
|
|
|
|
import React from "react";
|
|
|
|
|
|
|
|
type ToolIconProps =
|
|
|
|
| {
|
|
|
|
type: "button";
|
|
|
|
icon: React.ReactNode;
|
|
|
|
"aria-label": string;
|
|
|
|
title?: string;
|
|
|
|
name?: string;
|
|
|
|
id?: string;
|
|
|
|
onClick?(): void;
|
|
|
|
}
|
|
|
|
| {
|
|
|
|
type: "radio";
|
|
|
|
icon: React.ReactNode;
|
|
|
|
title?: string;
|
|
|
|
name?: string;
|
|
|
|
id?: string;
|
|
|
|
checked: boolean;
|
|
|
|
onChange?(): void;
|
|
|
|
};
|
|
|
|
|
|
|
|
export function ToolIcon(props: ToolIconProps) {
|
|
|
|
if (props.type === "button")
|
|
|
|
return (
|
2020-01-17 15:55:17 +03:00
|
|
|
<label className="ToolIcon" title={props.title}>
|
2020-01-15 20:42:02 +05:00
|
|
|
<button
|
|
|
|
className="ToolIcon_type_button"
|
|
|
|
aria-label={props["aria-label"]}
|
|
|
|
type="button"
|
|
|
|
onClick={props.onClick}
|
|
|
|
>
|
|
|
|
<div className="ToolIcon__icon">{props.icon}</div>
|
|
|
|
</button>
|
|
|
|
</label>
|
|
|
|
);
|
|
|
|
|
|
|
|
return (
|
2020-01-17 15:55:17 +03:00
|
|
|
<label className="ToolIcon" title={props.title}>
|
2020-01-15 20:42:02 +05:00
|
|
|
<input
|
|
|
|
className="ToolIcon_type_radio"
|
|
|
|
type="radio"
|
|
|
|
name={props.name}
|
|
|
|
id={props.id}
|
|
|
|
onChange={props.onChange}
|
|
|
|
checked={props.checked}
|
|
|
|
/>
|
|
|
|
<div className="ToolIcon__icon">{props.icon}</div>
|
|
|
|
</label>
|
|
|
|
);
|
|
|
|
}
|