-
Notifications
You must be signed in to change notification settings - Fork 2
Image preview modal for mobile breakpoint #2470
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
overlay={true} | ||
zIndex={theme.zIndex.highlightSummaryPopup} | ||
/> | ||
<ModalWrapper aria-modal='true'> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this also have role=dialog
?
|
||
export function MediaModalPortal(): React.ReactPortal | null { | ||
const [isOpen, setIsOpen] = React.useState(false); | ||
const [modalContent, setModalContent] = React.useState<ReactNode>(null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs to handle esc to close
const setClosed = React.useCallback(() => setIsOpen(false), [setIsOpen]);
useOnEsc(isOpen, setClosed);
`; | ||
|
||
// tslint:disable-next-line:variable-name | ||
const ModalWrapper = styled.div` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this sorta needs to be taking up the whole screen so that it can center things properly, but its gobbling click events so clicking on the overlay isn't closing things. i think you can set a css prop on here to allow click events to pass through and that'll fix it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this whole MediaModalManger setup is pretty convoluted, can you look at the highlightManager and try to share some of the patterns?
don't need the singleton class. stylistically, would be more consistent if it was a function and not a class. PageComponent can construct the manager and store the manager reference
PageComponent should orchestrate managers but there shouldn't be any business logic in there, move all the event listeners into the manager, you can bind your listener to the page component element instead of each individual image so that you don't have to re-apply the listeners when the content changes
@@ -149,6 +147,7 @@ export default class PageComponent extends Component<PagePropTypes> { | |||
return <MinPageHeight> | |||
<this.highlightManager.CardList /> | |||
<PT /> | |||
<MediaModalPortal /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you look above, the CardList is coming from the manager so that you don't need all the wonky binding logic. if you prefer, you could leave the component separate and pass the manager into it as a prop here, but either of those approaches would be more clear than the singleton binding its doing now
https://openstax.atlassian.net/browse/CORE-652