1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
lens/src/renderer/components/button/button.tsx
Alex Andreev af71834676
Moving dock info panel to the top (#1007)
* Moving EditorPanel to the top

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>

* Preventing save with empty yaml

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>

* Make tooltips in @withTooltip narrower

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>

* Not showing api errors in icon

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>

* Success notification for create resource operation

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>

* Button outlined style

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>

* Making second button to stay outlined

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>

* Fine-tuning dock info panel colors

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>

* Removing border-radius from ace-editor

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
2020-10-02 09:32:20 +03:00

59 lines
1.5 KiB
TypeScript

import "./button.scss";
import React, { ButtonHTMLAttributes, ReactNode } from "react";
import { cssNames } from "../../utils";
import { TooltipDecoratorProps, withTooltip } from "../tooltip";
export interface ButtonProps extends ButtonHTMLAttributes<any>, TooltipDecoratorProps {
label?: React.ReactNode;
waiting?: boolean;
primary?: boolean;
accent?: boolean;
plain?: boolean;
outlined?: boolean;
hidden?: boolean;
active?: boolean;
big?: boolean;
round?: boolean;
href?: string; // render as hyperlink
target?: "_blank"; // in case of using @href
}
@withTooltip
export class Button extends React.PureComponent<ButtonProps, {}> {
private link: HTMLAnchorElement;
private button: HTMLButtonElement;
render() {
const { className, waiting, label, primary, accent, plain, hidden, active, big, round, outlined, tooltip, children, ...props } = this.props;
const btnProps = props as Partial<ButtonProps>;
if (hidden) return null;
btnProps.className = cssNames('Button', className, {
waiting, primary, accent, plain, active, big, round, outlined
});
const btnContent: ReactNode = (
<>
{label}
{children}
</>
);
// render as link
if (this.props.href) {
return (
<a {...btnProps} ref={e => this.link = e}>
{btnContent}
</a>
)
}
// render as button
return (
<button type="button" {...btnProps} ref={e => this.button = e}>
{btnContent}
</button>
)
}
}