import {Children, useState} from 'react';
import styled from '@emotion/styled';
import {IconAdd, IconSubtract} from 'sentry/icons';
import {t} from 'sentry/locale';
type Props = {
children: React.ReactNode;
highUp: boolean;
wrapClassName: string;
};
function Toggle({highUp, wrapClassName, children}: Props) {
const [isExpanded, setIsExpanded] = useState(false);
if (Children.count(children) === 0) {
return null;
}
const wrappedChildren = {children};
if (highUp) {
return wrappedChildren;
}
return (
{
setIsExpanded(!isExpanded);
evt.preventDefault();
}}
>
{isExpanded ? (
) : (
)}
{isExpanded && wrappedChildren}
);
}
export default Toggle;
const IconWrapper = styled('div')<{isExpanded: boolean}>`
border-radius: 2px;
display: inline-flex;
align-items: center;
justify-content: center;
cursor: pointer;
${p =>
p.isExpanded
? `
background: ${p.theme.gray300};
border: 1px solid ${p.theme.gray300};
&:hover {
background: ${p.theme.gray400};
}
`
: `
background: ${p.theme.blue300};
border: 1px solid ${p.theme.blue300};
&:hover {
background: ${p.theme.blue200};
}
`}
`;