import React from 'react';
import { useHistory } from 'react-router-dom';
import Helmet from 'soapbox/components/helmet';
import { useSoapboxConfig } from 'soapbox/hooks';
import { Card, CardBody, CardHeader, CardTitle } from '../card/card';
export interface IColumn {
/** Route the back button goes to. */
backHref?: string,
/** Column title text. */
label?: string,
/** Whether this column should have a transparent background. */
transparent?: boolean,
/** Whether this column should have a title and back button. */
withHeader?: boolean,
/** Extra class name for top
element. */
className?: string,
/** Ref forwarded to column. */
ref?: React.Ref
}
/** A backdrop for the main section of the UI. */
const Column: React.FC = React.forwardRef((props, ref: React.ForwardedRef): JSX.Element => {
const { backHref, children, label, transparent = false, withHeader = true, className } = props;
const history = useHistory();
const soapboxConfig = useSoapboxConfig();
const handleBackClick = () => {
if (backHref) {
history.push(backHref);
return;
}
if (history.length === 1) {
history.push('/');
} else {
history.goBack();
}
};
const renderChildren = () => (
{withHeader ? (
) : null}
{children}
);
return (
{label}
{soapboxConfig.appleAppId && (
)}
{renderChildren()}
);
});
export default Column;