2021-08-05 11:16:26 +00:00
|
|
|
import * as React from "react";
|
|
|
|
|
import styled from "styled-components";
|
|
|
|
|
import { Button, ButtonGroup, IButtonProps } from "@blueprintjs/core";
|
|
|
|
|
|
|
|
|
|
import BaseControl, { ControlProps } from "./BaseControl";
|
|
|
|
|
import { ControlIcons } from "icons/ControlIcons";
|
|
|
|
|
import { ThemeProp } from "components/ads/common";
|
2021-09-09 15:10:22 +00:00
|
|
|
import {
|
|
|
|
|
ButtonBorderRadius,
|
|
|
|
|
ButtonBorderRadiusTypes,
|
|
|
|
|
} from "components/constants";
|
2021-12-07 09:45:18 +00:00
|
|
|
import { replayHighlightClass } from "globalStyles/portals";
|
2021-08-05 11:16:26 +00:00
|
|
|
|
|
|
|
|
const StyledButtonGroup = styled(ButtonGroup)`
|
|
|
|
|
height: 33px;
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
const StyledButton = styled(Button)<ThemeProp & IButtonProps>`
|
|
|
|
|
border: ${(props) =>
|
|
|
|
|
props.active ? `1px solid #6A86CE` : `1px solid #A9A7A7`};
|
|
|
|
|
border-radius: 0;
|
|
|
|
|
box-shadow: none !important;
|
|
|
|
|
background-image: none !important;
|
|
|
|
|
background-color: #ffffff !important;
|
|
|
|
|
& > div {
|
|
|
|
|
display: flex;
|
|
|
|
|
}
|
|
|
|
|
&.bp3-active {
|
|
|
|
|
box-shadow: none !important;
|
|
|
|
|
background-color: #ffffff !important;
|
|
|
|
|
}
|
|
|
|
|
&:hover {
|
|
|
|
|
background-color: #ffffff !important;
|
|
|
|
|
}
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
export interface BorderRadiusOptionsControlProps extends ControlProps {
|
|
|
|
|
propertyValue: ButtonBorderRadius | undefined;
|
|
|
|
|
onChange: (borderRaidus: ButtonBorderRadius) => void;
|
2021-08-24 13:53:15 +00:00
|
|
|
options: any[];
|
2021-08-05 11:16:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class BorderRadiusOptionsControl extends BaseControl<
|
|
|
|
|
BorderRadiusOptionsControlProps
|
|
|
|
|
> {
|
|
|
|
|
constructor(props: BorderRadiusOptionsControlProps) {
|
|
|
|
|
super(props);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static getControlType() {
|
|
|
|
|
return "BORDER_RADIUS_OPTIONS";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public render() {
|
2021-08-24 13:53:15 +00:00
|
|
|
const { options, propertyValue } = this.props;
|
2021-08-05 11:16:26 +00:00
|
|
|
|
|
|
|
|
return (
|
2021-12-07 09:45:18 +00:00
|
|
|
<StyledButtonGroup className={replayHighlightClass} fill>
|
2021-08-24 13:53:15 +00:00
|
|
|
{options.map((option: ButtonBorderRadius) => {
|
|
|
|
|
const active =
|
|
|
|
|
option === ButtonBorderRadiusTypes.SHARP
|
|
|
|
|
? propertyValue === option || propertyValue === undefined
|
|
|
|
|
: propertyValue === option;
|
|
|
|
|
const icon =
|
|
|
|
|
option === ButtonBorderRadiusTypes.SHARP ? (
|
|
|
|
|
<ControlIcons.BORDER_RADIUS_SHARP color="#979797" width={15} />
|
|
|
|
|
) : option === ButtonBorderRadiusTypes.ROUNDED ? (
|
|
|
|
|
<ControlIcons.BORDER_RADIUS_ROUNDED color="#979797" width={15} />
|
|
|
|
|
) : (
|
|
|
|
|
<ControlIcons.BORDER_RADIUS_CIRCLE color="#979797" width={15} />
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<StyledButton
|
|
|
|
|
active={active}
|
|
|
|
|
icon={icon}
|
|
|
|
|
key={option}
|
|
|
|
|
large
|
|
|
|
|
onClick={() => this.toggleOption(option)}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
{/* <StyledButton
|
2021-08-05 11:16:26 +00:00
|
|
|
active={propertyValue === ButtonBorderRadiusTypes.SHARP || undefined}
|
|
|
|
|
icon={<ControlIcons.BORDER_RADIUS_SHARP color="#979797" width={15} />}
|
|
|
|
|
large
|
|
|
|
|
onClick={() => this.toggleOption(ButtonBorderRadiusTypes.SHARP)}
|
|
|
|
|
/>
|
|
|
|
|
<StyledButton
|
|
|
|
|
active={propertyValue === ButtonBorderRadiusTypes.ROUNDED}
|
|
|
|
|
icon={
|
|
|
|
|
<ControlIcons.BORDER_RADIUS_ROUNDED color="#979797" width={15} />
|
|
|
|
|
}
|
|
|
|
|
large
|
|
|
|
|
onClick={() => this.toggleOption(ButtonBorderRadiusTypes.ROUNDED)}
|
|
|
|
|
/>
|
|
|
|
|
<StyledButton
|
|
|
|
|
active={propertyValue === ButtonBorderRadiusTypes.CIRCLE}
|
|
|
|
|
icon={
|
|
|
|
|
<ControlIcons.BORDER_RADIUS_CIRCLE color="#979797" width={15} />
|
|
|
|
|
}
|
|
|
|
|
large
|
|
|
|
|
onClick={() => this.toggleOption(ButtonBorderRadiusTypes.CIRCLE)}
|
2021-08-24 13:53:15 +00:00
|
|
|
/> */}
|
2021-08-05 11:16:26 +00:00
|
|
|
</StyledButtonGroup>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private toggleOption = (option: ButtonBorderRadius) => {
|
|
|
|
|
this.updateProperty(this.props.propertyName, option);
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default BorderRadiusOptionsControl;
|