refactor: fix history modal header & popover headers

This commit is contained in:
Aman Harwara
2023-01-24 21:53:04 +05:30
parent 56b7ffeafb
commit 550052f677
2 changed files with 50 additions and 32 deletions

View File

@@ -2,6 +2,7 @@ import { useDisableBodyScrollOnMobile } from '@/Hooks/useDisableBodyScrollOnMobi
import { classNames } from '@standardnotes/snjs' import { classNames } from '@standardnotes/snjs'
import { ReactNode } from 'react' import { ReactNode } from 'react'
import Portal from '../Portal/Portal' import Portal from '../Portal/Portal'
import MobileModalAction from '../Shared/MobileModalAction'
import { useModalAnimation } from '../Shared/useModalAnimation' import { useModalAnimation } from '../Shared/useModalAnimation'
const DisableScroll = () => { const DisableScroll = () => {
@@ -36,12 +37,12 @@ const MobilePopoverContent = ({
ref={setPopoverElement} ref={setPopoverElement}
className="fixed top-0 left-0 z-modal flex h-full w-full flex-col bg-default pt-safe-top pb-safe-bottom" className="fixed top-0 left-0 z-modal flex h-full w-full flex-col bg-default pt-safe-top pb-safe-bottom"
> >
<div className="flex items-center justify-between border-b border-border py-2.5 px-3 text-base"> <div className="grid w-full grid-cols-[0.35fr_1fr_0.35fr] gap-2 border-b border-border py-1.5 px-2 text-base">
<div /> <div />
<div className="font-semibold">{title}</div> <div className="flex items-center justify-center font-semibold">{title}</div>
<button className="font-semibold text-info active:shadow-none active:outline-none" onClick={requestClose}> <MobileModalAction type="primary" slot="right" action={requestClose}>
Done Done
</button> </MobileModalAction>
</div> </div>
<div className={classNames('h-full overflow-y-auto', className)}>{children}</div> <div className={classNames('h-full overflow-y-auto', className)}>{children}</div>
</div> </div>

View File

@@ -1,5 +1,5 @@
import { observer } from 'mobx-react-lite' import { observer } from 'mobx-react-lite'
import { useState } from 'react' import { useRef, useState } from 'react'
import HistoryListContainer from './HistoryListContainer' import HistoryListContainer from './HistoryListContainer'
import { RevisionHistoryModalContentProps } from './RevisionHistoryModalProps' import { RevisionHistoryModalContentProps } from './RevisionHistoryModalProps'
import HistoryModalFooter from './HistoryModalFooter' import HistoryModalFooter from './HistoryModalFooter'
@@ -8,6 +8,8 @@ import { NoteHistoryController } from '@/Controllers/NoteHistory/NoteHistoryCont
import Icon from '../Icon/Icon' import Icon from '../Icon/Icon'
import { classNames } from '@standardnotes/utils' import { classNames } from '@standardnotes/utils'
import { HistoryModalMobileTab } from './utils' import { HistoryModalMobileTab } from './utils'
import MobileModalAction from '../Shared/MobileModalAction'
import Popover from '../Popover/Popover'
const HistoryModalDialogContent = ({ const HistoryModalDialogContent = ({
application, application,
@@ -19,37 +21,52 @@ const HistoryModalDialogContent = ({
}: RevisionHistoryModalContentProps) => { }: RevisionHistoryModalContentProps) => {
const [noteHistoryController] = useState(() => new NoteHistoryController(application, note, selectionController)) const [noteHistoryController] = useState(() => new NoteHistoryController(application, note, selectionController))
const [selectedMobileTab, setSelectedMobileTab] = useState<HistoryModalMobileTab>('Content') const [selectedMobileTab, setSelectedMobileTab] = useState<HistoryModalMobileTab>('List')
const tabOptionRef = useRef<HTMLButtonElement>(null)
const [showTabMenu, setShowTabMenu] = useState(false)
const toggleTabMenu = () => setShowTabMenu((show) => !show)
return ( return (
<> <>
<div className="flex items-center border-b border-border md:hidden"> <div className="grid w-full grid-cols-[0.35fr_1fr_0.35fr] items-center gap-2 border-b border-border py-1 px-2 md:hidden">
<button <MobileModalAction type="secondary" action={toggleTabMenu} slot="left" ref={tabOptionRef}>
className={classNames( <div className="rounded-full border border-border p-0.5">
'relative cursor-pointer border-0 bg-default px-3 py-2.5 text-sm focus:shadow-inner', <Icon type="more" />
selectedMobileTab === 'List' ? 'font-medium text-info shadow-bottom' : 'text-text', </div>
)} </MobileModalAction>
onClick={() => { <Popover
setSelectedMobileTab('List') title="Advanced"
}} open={showTabMenu}
anchorElement={tabOptionRef.current}
disableMobileFullscreenTakeover={true}
togglePopover={toggleTabMenu}
align="start"
portal={false}
className="w-1/2 !min-w-0 divide-y divide-border border border-border"
> >
List <button
</button> onClick={() => {
<button setSelectedMobileTab('List')
className={classNames( toggleTabMenu()
'relative cursor-pointer border-0 bg-default px-3 py-2.5 text-sm focus:shadow-inner', }}
selectedMobileTab === 'Content' ? 'font-medium text-info shadow-bottom' : 'text-text', className="p-1.5 text-base font-semibold hover:bg-contrast focus:bg-info-backdrop focus:shadow-none focus:outline-none"
)} >
onClick={() => { List
setSelectedMobileTab('Content') </button>
}} <button
> onClick={() => {
Content setSelectedMobileTab('Content')
</button> toggleTabMenu()
<div className="mx-auto text-base font-semibold">History</div> }}
<button className="ml-auto mr-2 rounded-full border border-border p-1.5" onClick={dismissModal}> className="p-1.5 text-base font-semibold hover:bg-contrast focus:bg-info-backdrop focus:shadow-none focus:outline-none"
<Icon type="close" className="h-4 w-4" /> >
</button> Content
</button>
</Popover>
<div className="text-center text-base font-semibold">History</div>
<MobileModalAction type="primary" slot="right" action={dismissModal}>
Done
</MobileModalAction>
</div> </div>
<div className="flex min-h-0 flex-grow"> <div className="flex min-h-0 flex-grow">
<div <div