mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-18 00:56:02 +00:00
64 lines
1.2 KiB
JavaScript
64 lines
1.2 KiB
JavaScript
// @ts-nocheck
|
|
import React from 'react';
|
|
import styled from 'styled-components';
|
|
import theme from '../theme';
|
|
|
|
const ButtonDiv = styled.div`
|
|
padding: 5px 15px;
|
|
// margin: 2px;
|
|
color: black;
|
|
border: 0;
|
|
border-right: 1px solid #ccc;
|
|
height: ${theme.toolBar.height}px;
|
|
|
|
${(props) =>
|
|
!props.disabled &&
|
|
`
|
|
&:hover {
|
|
background-color: #CCC;
|
|
}
|
|
|
|
&:active:hover {
|
|
background-color: #AAA;
|
|
}
|
|
`}
|
|
|
|
${(props) =>
|
|
props.disabled &&
|
|
`
|
|
color: gray;
|
|
`}
|
|
`;
|
|
|
|
const StyledIconSpan = styled.span`
|
|
margin-right: 5px;
|
|
// font-size: 18px;
|
|
color: ${(props) => (props.disabled ? 'gray' : 'blue')};
|
|
`;
|
|
|
|
const ButtonDivInner = styled.div`
|
|
position: relative;
|
|
top: ${(props) => props.patchY}px;
|
|
white-space: nowrap;
|
|
`;
|
|
|
|
export default function ToolbarButton({ children, onClick, icon = undefined, disabled = undefined, patchY = 2 }) {
|
|
return (
|
|
<ButtonDiv
|
|
onClick={() => {
|
|
if (!disabled && onClick) onClick();
|
|
}}
|
|
disabled={disabled}
|
|
>
|
|
<ButtonDivInner patchY={patchY}>
|
|
{icon && (
|
|
<StyledIconSpan disabled={disabled}>
|
|
<span className={icon} />
|
|
</StyledIconSpan>
|
|
)}
|
|
{children}
|
|
</ButtonDivInner>
|
|
</ButtonDiv>
|
|
);
|
|
}
|