Skip to content
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

Fullscreen attachments preview #1500

Merged
merged 1 commit into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions src/components/ImageFullScreen.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React from 'react';
import { ModalContent } from '@taskany/bricks';
import styled from 'styled-components';

import { ModalEvent, dispatchModalEvent } from '../utils/dispatchModal';

interface ImageFullScreenProps {
src?: string;
alt?: string;
}
const StyledImage = styled.img`
cursor: pointer;
width: 100vh;
`;
const StyledWrapperImage = styled.div`
display: flex;
justify-content: center;
`;
const ImageFullScreen: React.FC<ImageFullScreenProps> = ({ src = '', alt = '' }) => {
return (
<ModalContent>
<StyledWrapperImage>
<StyledImage src={src} alt={alt} onClick={dispatchModalEvent(ModalEvent.ImageFullScreen)} />
</StyledWrapperImage>
</ModalContent>
);
};

export default ImageFullScreen;
7 changes: 7 additions & 0 deletions src/components/Page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const HotkeysModal = dynamic(() => import('./HotkeysModal/HotkeysModal'));
const NotificationsHub = dynamic(() => import('./NotificationsHub/NotificationsHub'));
const FeedbackCreateForm = dynamic(() => import('./FeedbackCreateForm/FeedbackCreateForm'));
const WhatsNew = dynamic(() => import('./WhatsNew/WhatsNew'));
const ImageFullScreen = dynamic(() => import('./ImageFullScreen'));

interface PageProps {
user: Session['user'];
Expand Down Expand Up @@ -107,6 +108,12 @@ export const Page: React.FC<PageProps> = ({ user, ssrTime, title = 'Untitled', c
<FeedbackCreateForm />
</ModalOnEvent>

<ModalOnEvent event={ModalEvent.ImageFullScreen}>
<ModalContext.Consumer>
{(ctx) => <ImageFullScreen {...ctx[ModalEvent.ImageFullScreen]} />}
</ModalContext.Consumer>
</ModalOnEvent>

<GoalPreview />

<HotkeysModal />
Expand Down
14 changes: 14 additions & 0 deletions src/hooks/useMarkdown.ts → src/hooks/useMarkdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,23 @@
import remarkEmoji from 'remark-emoji';
import { useRemark, useRemarkSync } from 'react-remark';

import { ModalEvent, dispatchModalEvent } from '../utils/dispatchModal';

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const ssrRenderOptions: any = {
remarkPlugins: [remarkEmoji],
rehypeReactOptions: {
components: {
img: (props: any) => (

Check warning on line 12 in src/hooks/useMarkdown.tsx

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type
// eslint-disable-next-line @next/next/no-img-element, jsx-a11y/alt-text
<img
{...props}
onClick={dispatchModalEvent(ModalEvent.ImageFullScreen, { src: props.src, alt: props.alt })}
style={{ cursor: 'pointer' }}
></img>
),
},
},
};
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const clientRenderOptions: any = {
Expand Down
5 changes: 5 additions & 0 deletions src/utils/dispatchModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export enum ModalEvent {
FilterDeleteModal = 'FilterDeleteModal',
FeedbackCreateModal = 'FeedbackCreateModal',
WhatsNewModal = 'WhatsNewModal',
ImageFullScreen = 'ImageFullScreen',
}

export interface MapModalToComponentProps {
Expand All @@ -30,6 +31,10 @@ export interface MapModalToComponentProps {
[ModalEvent.FilterDeleteModal]: unknown;
[ModalEvent.FeedbackCreateModal]: unknown;
[ModalEvent.WhatsNewModal]: unknown;
[ModalEvent.ImageFullScreen]: {
src: string;
alt?: string;
};
}

interface DispatchModalEvent {
Expand Down
Loading