PromucFlow_constructor/app/client/src/components/ads/ButtonTabComponent.tsx
ram-primathon 3b0fb539d5
Property Pane re design (#3057)
Co-authored-by: devrk96 <rohit.kumawat@primathon.in>
Co-authored-by: hetunandu <hetu@appsmith.com>
Co-authored-by: Hetu Nandu <hetunandu@gmail.com>
Co-authored-by: Vicky Bansal <67091118+vicky-primathon@users.noreply.github.com>
Co-authored-by: nandan.anantharamu <nandan.anantharamu@thoughtspot.com>
2021-03-15 17:47:56 +05:30

67 lines
1.7 KiB
TypeScript

import React from "react";
import styled from "styled-components";
import { ControlIcons, ControlIconName } from "icons/ControlIcons";
const ItemWrapper = styled.div<{ selected: boolean }>`
width: 32px;
height: 32px;
display: flex;
align-items: center;
justify-content: center;
background: ${(props) =>
props.selected
? props.theme.colors.propertyPane.activeButtonText
: props.theme.colors.propertyPane.multiDropdownBoxHoverBg};
cursor: pointer;
&:first-of-type {
margin-right: 4px;
}
&&& svg {
path {
fill: ${(props) =>
props.selected
? props.theme.colors.propertyPane.buttonText
: props.theme.colors.propertyPane.jsIconBg} !important;
}
}
`;
const FlexWrapper = styled.div`
display: flex;
`;
export interface ButtonTabOption {
icon: string;
value: string;
}
interface ButtonTabComponentProps {
options: ButtonTabOption[];
values: Array<string>;
selectButton: (value: string) => void;
}
const ButtonTabComponent = (props: ButtonTabComponentProps) => {
return (
<FlexWrapper>
{props.options.map((option: ButtonTabOption, index: number) => {
const controlIconName: ControlIconName = option.icon;
const ControlIcon = ControlIcons[controlIconName];
const isSelected = props.values.includes(option.value);
return (
<ItemWrapper
key={index}
selected={isSelected}
onClick={() => props.selectButton(option.value)}
className={`t--button-tab-${option.value}`}
>
<ControlIcon width={24} height={24} />
</ItemWrapper>
);
})}
</FlexWrapper>
);
};
export default ButtonTabComponent;