Skip to content

Commit

Permalink
Merge pull request #192 from bcgsc/release/v6.10.0
Browse files Browse the repository at this point in the history
Release/v6.10.0
  • Loading branch information
kttkjl committed Mar 30, 2022
2 parents 9188e12 + 21d8fdc commit 8b8849e
Show file tree
Hide file tree
Showing 41 changed files with 1,017 additions and 520 deletions.
11 changes: 11 additions & 0 deletions app/common.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,20 @@ type ExpOutliersType = {
tpm: number | null;
} & RecordDefaults;

type TemplateType = {
ident: string;
name: string;
};

type AppendixType = RecordDefaults & {
text: string;
};

export {
RecordDefaults,
UserType,
TemplateType,
AppendixType,
GroupType,
UserProjectsType,
UserGroupMemberType,
Expand Down
File renamed without changes.
File renamed without changes.
36 changes: 27 additions & 9 deletions app/components/DataTable/components/ImageViewer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ import Image, { ImageType } from '@/components/Image';

import './index.scss';

type ImageDataProp = { image: ImageType } | { image: ImageType[] };

type ImageViewerProps = {
/** Handles dialog close */
onClose: () => void;
/** Row object selected from table */
selectedRow: { image: ImageType },
selectedRow: ImageDataProp,
/** Dialog open state */
isOpen: boolean;
};
Expand All @@ -28,21 +30,37 @@ const ImageViewer = ({
onClose();
}, [onClose]);

let renderedImage;
if (selectedRow.image) {
if (Array.isArray(selectedRow.image)) {
renderedImage = selectedRow.image.map((img) => (
<Image
image={img}
showTitle
showCaption
isZoomable={false}
/>
));
} else {
renderedImage = (
<Image
image={selectedRow.image}
showTitle
showCaption
isZoomable={false}
/>
);
}
}

return (
<Dialog
onClose={handleClose}
open={isOpen}
maxWidth="xl"
>
<DialogContent>
{selectedRow.image && (
<Image
image={selectedRow.image}
showTitle
showCaption
isZoomable={false}
/>
)}
{renderedImage}
</DialogContent>
<DialogActions>
<Button color="primary" onClick={handleClose}>
Expand Down
128 changes: 65 additions & 63 deletions app/components/Image/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ import './index.scss';

type ImageProps = {
image?: ImageType;
height?: number;
width?: number;
height?: number | string;
width?: number | string;
showTitle?: boolean;
showCaption?: boolean;
isZoomable?: boolean;
/** Style to apply to img tag */
imgStyle?: React.ComponentPropsWithoutRef<'img'>['style'];
};

const Image = ({
Expand All @@ -22,11 +24,12 @@ const Image = ({
format,
key,
} = {} as ImageType,
height = 0,
width = 0,
height = undefined,
width = undefined,
showTitle = false,
showCaption = false,
isZoomable = true,
imgStyle = {},
}: ImageProps): JSX.Element => {
const [isZoomed, setIsZoomed] = useState(false);

Expand All @@ -37,68 +40,67 @@ const Image = ({
}, [isZoomable]);

return (
<>
{data && (
<>
<div className="image">
{showTitle && title && (
<Typography variant="h3">
{title}
</Typography>
)}
<Button
classes={{ root: 'image__button' }}
component="label"
data && (
<>
<div className="image">
{showTitle && title && (
<Typography variant="h3">
{title}
</Typography>
)}
<Button
classes={{ root: 'image__button' }}
component="label"
onClick={handleZoom}
>
<img
className={`image ${isZoomable && !isZoomed ? 'image__zoom--in' : ''}`}
src={`data:image/${format};base64,${data}`}
alt={title}
key={key}
height={Number.isInteger(height) ? `${height}px` : height}
width={Number.isInteger(width) ? `${height}px` : width}
style={imgStyle}
/>
</Button>
{showCaption && caption && (
<Typography className="image__caption" variant="caption">
{caption}
</Typography>
)}
</div>
{isZoomed && (
<Fade in={isZoomed}>
<button
className="image__dialog-background"
onClick={handleZoom}
type="button"
>
<img
className={`image ${isZoomable && !isZoomed ? 'image__zoom--in' : ''}`}
src={`data:image/${format};base64,${data}`}
alt={title}
key={key}
height={height ? `${height}px` : undefined}
width={width ? `${width}px` : undefined}
/>
</Button>
{showCaption && caption && (
<Typography className="image__caption" variant="caption">
{caption}
</Typography>
)}
</div>
{isZoomed && (
<Fade in={isZoomed}>
<button
className="image__dialog-background"
onClick={handleZoom}
type="button"
<div
className="image__dialog-button"
>
<div
className="image__dialog-button"
>
{showTitle && title && (
<Typography variant="h3">
{title}
</Typography>
)}
<img
className={`image__data ${isZoomable && isZoomed ? 'image__zoom--out' : ''}`}
src={`data:image/${format};base64,${data}`}
alt={title}
key={key}
/>
{showCaption && caption && (
<Typography className="image__caption" variant="caption">
{caption}
</Typography>
)}
</div>
</button>
</Fade>
)}
</>
)}
</>
{showTitle && title && (
<Typography variant="h3">
{title}
</Typography>
)}
<img
className={`image__data ${isZoomable && isZoomed ? 'image__zoom--out' : ''}`}
src={`data:image/${format};base64,${data}`}
alt={title}
key={key}
/>
{showCaption && caption && (
<Typography className="image__caption" variant="caption">
{caption}
</Typography>
)}
</div>
</button>
</Fade>
)}
</>
)
);
};

Expand Down
Loading

0 comments on commit 8b8849e

Please sign in to comment.