PromucFlow_constructor/app/client/src/components/ads/Callout.tsx
devrk96 ac23629647
Feature: API Pane Redesign (#2218)
Co-authored-by: Hetu Nandu <hetunandu@gmail.com>
Co-authored-by: Pawan Kumar <pawankumar@Pawans-MacBook-Pro.local>
2021-02-11 18:24:00 +05:30

92 lines
2.4 KiB
TypeScript

import React, { ReactNode } from "react";
import { CommonComponentProps, Classes, Variant } from "./common";
import styled from "styled-components";
import Icon, { IconSize } from "./Icon";
import { Colors } from "constants/Colors";
import Text, { TextType } from "./Text";
type CalloutProps = CommonComponentProps & {
variant?: Variant;
fill?: boolean;
closeButton?: boolean;
text?: string;
label?: ReactNode;
onClose?: () => void;
};
const CalloutContainer = styled.div<{
variant: Variant;
fill?: boolean;
}>`
position: relative;
padding: ${(props) => props.theme.spaces[4]}px
${(props) => props.theme.spaces[12]}px;
background: ${(props) => props.theme.colors.callout[props.variant].bgColor};
${(props) =>
props.fill
? `
display: flex;
align-items: center;
justify-content: center;
`
: null};
.${Classes.ICON} {
cursor: default;
margin-right: ${(props) => props.theme.spaces[4]}px;
svg path {
fill: ${(props) =>
props.variant === Variant.danger
? Colors.WHITE
: props.theme.colors.callout[props.variant].color};
}
}
a {
color: ${(props) => props.theme.colors.callout[props.variant].color};
&:hover {
text-decoration-color: ${(props) =>
props.theme.colors.callout[props.variant].color};
}
span {
color: ${(props) => props.theme.colors.callout[props.variant].color};
}
}
`;
const Label = styled.div<{ variant: Variant }>`
position: absolute;
right: ${(props) => props.theme.spaces[12]}px;
top: ${(props) => props.theme.spaces[5]}px;
.${Classes.ICON} {
margin-right: 0px !important;
cursor: pointer;
svg path {
fill: ${(props) => props.theme.colors.callout[props.variant].color};
}
}
`;
Callout.defaultProps = {
fill: false,
variant: Variant.info,
};
function Callout(props: CalloutProps) {
return (
<CalloutContainer variant={props.variant || Variant.info} fill={props.fill}>
{props.text && props.variant !== Variant.info ? (
<Icon name={props.variant} size={IconSize.MEDIUM} />
) : null}
<Text type={TextType.P2}>{props.text}</Text>
{props.label ? props.label : null}
{props.closeButton ? (
<Label variant={props.variant || Variant.info} onClick={props.onClose}>
<Icon name="close-modal" />
</Label>
) : null}
</CalloutContainer>
);
}
export default Callout;