From 8aa31dd6681611b989eaf583e237f716b3cc5bb5 Mon Sep 17 00:00:00 2001 From: Austin Piel Date: Tue, 25 Aug 2020 18:35:44 -0700 Subject: [PATCH] update(ImageViewer): Add `dropdownAbove` prop (#398) * Add dropdownAbove prop to ImageViewer * comment update --- .../components/ImageViewer/ZoomControls.tsx | 12 +++++-- .../core/src/components/ImageViewer/story.tsx | 31 +++++++++++++++++-- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/packages/core/src/components/ImageViewer/ZoomControls.tsx b/packages/core/src/components/ImageViewer/ZoomControls.tsx index 10f267ee0..f874221ae 100644 --- a/packages/core/src/components/ImageViewer/ZoomControls.tsx +++ b/packages/core/src/components/ImageViewer/ZoomControls.tsx @@ -46,13 +46,15 @@ export type ZoomControlsProps = { iconSize?: number | string; /** Custom style sheet. */ styleSheet?: StyleSheet; + /** Place dropdown menu above */ + dropdownAbove?: boolean; }; /** Zoom controls that can be used with an image viewer component */ export default function ZoomControls({ styleSheet, ...props }: ZoomControlsProps) { const [styles, cx] = useStyles(styleSheet ?? styleSheetZoomControls); const [visible, setVisible] = useState(false); - const { onScale, scale = 1, iconSize = '2em' } = props; + const { onScale, scale = 1, iconSize = '2em', dropdownAbove } = props; const zoomOptions = ZOOM_OPTIONS.map((zoom: { label: string; scale: number }) => ({ ...zoom, @@ -89,7 +91,13 @@ export default function ZoomControls({ styleSheet, ...props }: ZoomControlsProps {visible && ( - + {zoomOptions.map((zoom) => ( diff --git a/packages/core/src/components/ImageViewer/story.tsx b/packages/core/src/components/ImageViewer/story.tsx index c4846a52b..0c8cd92fd 100644 --- a/packages/core/src/components/ImageViewer/story.tsx +++ b/packages/core/src/components/ImageViewer/story.tsx @@ -6,13 +6,32 @@ import Row from '../Row'; type ImageViewerDemoProps = { width?: string; height?: string; + controlsBottom?: boolean; }; -function ImageViewerDemo({ width, height }: ImageViewerDemoProps) { +function ImageViewerDemo({ width, height, controlsBottom }: ImageViewerDemoProps) { const [scale, setScale] = useState(1); const [rotation, setRotation] = useState(0); - return ( + return controlsBottom ? ( + <> + + setRotation(value)} /> + } + > + setScale(value)} /> + + + ) : ( <> ; +} + +withControlsBottom.story = { + name: 'With dropdownAbove set.', +};