web.lib.core.components.toggle-panel.tsx Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of code-quarkus Show documentation
Show all versions of code-quarkus Show documentation
Customize a Web Interface to generate Quarkus starter projects.
import * as React from 'react';
import { useLocalStorage } from '@rehooks/local-storage';
import './toggle-panel.scss';
import { Button } from 'react-bootstrap';
import { useAnalytics } from '../../core/analytics';
import { FaCaretSquareDown, FaCaretSquareLeft, FaCaretSquareRight, FaCaretSquareUp } from 'react-icons/fa';
interface TogglePanelProps {
id: string;
closeLabel?: string;
openLabel?: string
event?: string;
eventContext?: object;
mode?: 'vertical' | 'horizontal';
children: React.ReactNode;
}
export function TogglePanel(props: TogglePanelProps) {
const analytics = useAnalytics();
const [ open, setOpen ] = useLocalStorage(props.id, false);
const mode = props.mode || 'vertical';
const CloseIcon = mode === 'horizontal' ? : ;
const OpenIcon = mode === 'horizontal' ? : ;
const flip = () => {
if (props.event && props.event.length === 2) {
let eventContext = props.eventContext || {};
if (open) {
analytics.event(props.event, { ...eventContext })
}
}
setOpen(!open);
};
return (
<>
{props.children}
>
);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy