fix(ui): fix add outside click for modal, fix right menu headers

This commit is contained in:
sylenien 2022-06-27 12:32:54 +02:00
parent 8ae15c799e
commit 6592f33827
8 changed files with 20 additions and 10 deletions

View file

@ -29,7 +29,7 @@ function DashboardEditModal(props: Props) {
const write = ({ target: { value, name } }) => dashboard.update({ [ name ]: value }) const write = ({ target: { value, name } }) => dashboard.update({ [ name ]: value })
return useObserver(() => ( return useObserver(() => (
<Modal open={ show }> <Modal open={ show } onClose={closeHandler}>
<Modal.Header className="flex items-center justify-between"> <Modal.Header className="flex items-center justify-between">
<div>{ 'Edit Dashboard' }</div> <div>{ 'Edit Dashboard' }</div>
<Icon <Icon

View file

@ -41,7 +41,7 @@ function DashboardSelectionModal(props: Props) {
}, []) }, [])
return useObserver(() => ( return useObserver(() => (
<Modal size="small" open={ show }> <Modal size="small" open={ show } onClose={closeHandler}>
<Modal.Header className="flex items-center justify-between"> <Modal.Header className="flex items-center justify-between">
<div>{ 'Add to selected dashboard' }</div> <div>{ 'Add to selected dashboard' }</div>
<Icon <Icon

View file

@ -102,10 +102,10 @@ function WidgetSessions(props: Props) {
show={filteredSessions.sessions.length === 0} show={filteredSessions.sessions.length === 0}
> >
{filteredSessions.sessions.map((session: any) => ( {filteredSessions.sessions.map((session: any) => (
<> <React.Fragment key={ session.sessionId }>
<SessionItem key={ session.sessionId } session={ session } /> <SessionItem session={ session } />
<div className="border-b" /> <div className="border-b" />
</> </React.Fragment>
))} ))}
<div className="w-full flex items-center justify-center py-6"> <div className="w-full flex items-center justify-center py-6">

View file

@ -46,7 +46,7 @@ export default class FunnelSaveModal extends React.PureComponent {
} = this.props; } = this.props;
return ( return (
<Modal size="small" open={ show }> <Modal size="small" open={ show } onClose={this.props.closeHandler}>
<Modal.Header className={ styles.modalHeader }> <Modal.Header className={ styles.modalHeader }>
<div>{ 'Save Funnel' }</div> <div>{ 'Save Funnel' }</div>
<Icon <Icon

View file

@ -63,8 +63,9 @@ function PageInsightsPanel({
return ( return (
<div className="p-4 bg-white"> <div className="p-4 bg-white">
<div className="pt-2 pb-3 flex items-center" style={{ maxWidth: '241px' }}> <div className="pb-3 flex items-center" style={{ maxWidth: '241px', paddingTop: '5px' }}>
<div className="-ml-1 text-lg"> <div className="flex items-center">
<span className="mr-1 text-xl">Clicks</span>
<SelectDateRange period={period} onChange={onDateChange} disableCustom /> <SelectDateRange period={period} onChange={onDateChange} disableCustom />
</div> </div>
<div <div

View file

@ -57,7 +57,7 @@ function SaveSearchModal(props: Props) {
return ( return (
<Modal size="small" open={ show }> <Modal size="small" open={ show } onClose={closeHandler}>
<Modal.Header className={ stl.modalHeader }> <Modal.Header className={ stl.modalHeader }>
<div>{ 'Save Search' }</div> <div>{ 'Save Search' }</div>
<Icon <Icon

View file

@ -22,6 +22,7 @@ const Confirmation = ({
return ( return (
<Modal <Modal
open={show} open={show}
onClose={() => proceed(false)}
> >
<Modal.Header>{header}</Modal.Header> <Modal.Header>{header}</Modal.Header>
<Modal.Content> <Modal.Content>

View file

@ -5,6 +5,7 @@ interface Props {
children: React.ReactNode; children: React.ReactNode;
open?: boolean; open?: boolean;
size ?: 'tiny' | 'small' | 'large' | 'fullscreen'; size ?: 'tiny' | 'small' | 'large' | 'fullscreen';
onClose?: () => void;
} }
function Modal(props: Props) { function Modal(props: Props) {
const { children, open = false, size = 'small' } = props; const { children, open = false, size = 'small' } = props;
@ -28,10 +29,17 @@ function Modal(props: Props) {
style.width = '100%'; style.width = '100%';
} }
const handleClose = (e: React.MouseEvent<HTMLDivElement>) => {
if (e.target === e.currentTarget) {
props.onClose && props.onClose();
}
}
return open ? ( return open ? (
<div <div
className="fixed inset-0 flex items-center justify-center box-shadow animate-fade-in" className="fixed inset-0 flex items-center justify-center box-shadow animate-fade-in"
style={{ zIndex: '999', backgroundColor: 'rgba(0, 0, 0, 0.2)'}} style={{ zIndex: '999', backgroundColor: 'rgba(0, 0, 0, 0.2)'}}
onClick={handleClose}
> >
<div className="absolute z-10 bg-white rounded border" style={style}> <div className="absolute z-10 bg-white rounded border" style={style}>
{children} {children}