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

Fix/image viewer review #2708

Merged
merged 8 commits into from
Jan 14, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ const ImageViewerMeta: ComponentMeta<typeof ImageViewer> = {
},
argTypes: {},
args: {
images: [{ id: 1, url: 'https://picsum.photos/1000/1000' }],
images: [
{
id: 1,
url: 'https://img.freepik.com/free-photo/young-boy-learning-how-ride-horse_23-2150460636.jpg',
},
],
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ import { Icon, CloseIcon } from '@/components/ui/icon';

const ImageViewerBasic = ({ ...props }: any) => {
const Images = [
{ id: 1, url: 'https://picsum.photos/1000/1000', title: 'Image 1' },
{ id: 2, url: 'https://picsum.photos/1000/1000', title: 'Image 2' },
{ id: 3, url: 'https://picsum.photos/1000/1000', title: 'Image 3' },
{
id: 1,
url: 'https://img.freepik.com/free-photo/young-boy-learning-how-ride-horse_23-2150460636.jpg',
title: 'Image 1',
},
];
const [visible, setVisible] = useState(false);
return (
Expand All @@ -22,7 +24,7 @@ const ImageViewerBasic = ({ ...props }: any) => {
<Image
source={{ uri: Images[0].url }}
className="w-[200px] h-[200px]"
resizeMode="contain"
resizeMode="cover"
/>
</Pressable>

Expand All @@ -40,7 +42,7 @@ const ImageViewerBasic = ({ ...props }: any) => {
keyExtractor={(item, index) => item.id + '-' + index}
>
<ImageViewerCloseButton>
<Icon as={CloseIcon} />
<Icon as={CloseIcon} className="text-secondary-500" />
</ImageViewerCloseButton>
</ImageViewerContent>
</ImageViewerBackdrop>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,19 @@ This is an illustration of **ImageViewer** component.
px: '$8',
}}
showComponentRenderer={true}
showArgsController={true}
showArgsController={false}
metaData={{
code: `
function App() {
const [visible, setVisible] = React.useState(false);
const Images = [{ id: 1, url: 'https://picsum.photos/1000/1000' }];
const Images = [{ id: 1, url: 'https://img.freepik.com/free-photo/young-boy-learning-how-ride-horse_23-2150460636.jpg' }];
return (
<Center>
<Pressable onPress={() => setVisible(true)}>
<Image
source={{ uri: Images[0].url }}
className="w-[200px] h-[200px]"
resizeMode="contain"
resizeMode="cover"
/>
</Pressable>
<ImageViewer isOpen={visible} onClose={() => setVisible(false)}>
Expand All @@ -77,7 +77,7 @@ This is an illustration of **ImageViewer** component.
keyExtractor={(item, index) => item.id + '-' + index}
>
<ImageViewerCloseButton>
<Icon as={CloseIcon}/>
<Icon as={CloseIcon} className='text-secondary-500'/>
</ImageViewerCloseButton>
</ImageViewerContent>
</ImageViewerBackdrop>
Expand Down Expand Up @@ -369,19 +369,19 @@ import { Center } from '@/components/ui/center';
px: '$8',
}}
showComponentRenderer={true}
showArgsController={true}
showArgsController={false}
metaData={{
code: `
function App() {
const [visible, setVisible] = React.useState(false);
const Images = [{ id: 1, url: 'https://picsum.photos/1000/1000' }];
const Images = [{ id: 1, url: 'https://img.freepik.com/free-photo/young-boy-learning-how-ride-horse_23-2150460636.jpg' }];
return (
<Center>
<Pressable onPress={() => setVisible(true)}>
<Image
source={{ uri: Images[0].url }}
className="w-[200px] h-[200px]"
resizeMode="contain"
resizeMode="cover"
/>
</Pressable>
<ImageViewer isOpen={visible} onClose={() => setVisible(false)}>
Expand All @@ -394,7 +394,7 @@ import { Center } from '@/components/ui/center';
keyExtractor={(item, index) => item.id + '-' + index}
>
<ImageViewerCloseButton>
<Icon as={CloseIcon}/>
<Icon as={CloseIcon} className='text-secondary-500'/>
</ImageViewerCloseButton>
</ImageViewerContent>
</ImageViewerBackdrop>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const BackdropStyle = tva({
});

const CloseButtonStyle = tva({
base: 'absolute top-4 right-4 z-10 bg-white rounded-full w-8 h-8 justify-center items-center cursor-pointer',
base: 'absolute top-4 right-4 z-10 rounded-full w-8 h-8 justify-center items-center cursor-pointer hover:bg-primary-500 transition-all duration-300',
});

const UIImageViewer = createImageViewer({
Expand Down
2 changes: 1 addition & 1 deletion packages/unstyled/image-viewer/src/ImageViewerContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ const ImageViewerContent = (
})
.onEnd((event: any) => {
if (scale.value <= 1) {
if (Math.abs(event.translationY) > SCREEN_HEIGHT * 0.2) {
if (Math.abs(event.translationY) > SCREEN_HEIGHT * 0.005) {
runOnJS(onClose)();
}
}
Expand Down
Loading