diff --git a/.babelrc b/.babelrc index cfae37f6e..189f09ac0 100644 --- a/.babelrc +++ b/.babelrc @@ -1,7 +1,5 @@ { - "presets": [ - "next/babel" - ], + "presets": ["next/babel"], "plugins": [ [ "styled-components", @@ -12,4 +10,4 @@ } ] ] -} \ No newline at end of file +} diff --git a/src/components/Container.ts b/src/components/Container.ts index d455d2ed5..b95a304a1 100644 --- a/src/components/Container.ts +++ b/src/components/Container.ts @@ -12,9 +12,8 @@ const Container = styled.div` export default Container; - export const DisclaimerContainer = styled.div` - margin: 16px 0; + margin: 16px 0; color: rgb(158, 150, 137); font-size: 14px; `; diff --git a/src/components/FavButton.tsx b/src/components/FavButton.tsx index 3be4b5f07..32a988e8b 100644 --- a/src/components/FavButton.tsx +++ b/src/components/FavButton.tsx @@ -1,23 +1,24 @@ -import React from "react"; -import styled from "styled-components"; +import React from 'react'; +import styled from 'styled-components'; const HeartUI = styled.button<{ - isClick: boolean, - size: number, + isClick: boolean; + size: number; }>` - width: ${props => props.size}px; - height: ${props => props.size}px; - float:right; - background: url("/fav-button.png") no-repeat; - cursor: pointer; - background-size: cover; - border: none; - ${({ isClick, size }) => isClick && `background-position: -${28 * size}px;transition: background 1s steps(28);`} + width: ${(props) => props.size}px; + height: ${(props) => props.size}px; + float: right; + background: url('/fav-button.png') no-repeat; + cursor: pointer; + background-size: cover; + border: none; + ${({ isClick, size }) => + isClick && + `background-position: -${ + 28 * size + }px;transition: background 1s steps(28);`} `; - export default function FavButton({ isClick, onClick, size }) { - return ( - - ); -} \ No newline at end of file + return ; +} diff --git a/src/components/FullScreenDropZone.tsx b/src/components/FullScreenDropZone.tsx index 20977552d..ac7ee28c9 100644 --- a/src/components/FullScreenDropZone.tsx +++ b/src/components/FullScreenDropZone.tsx @@ -2,9 +2,9 @@ import React, { useRef } from 'react'; import styled from 'styled-components'; const DropDiv = styled.div` - flex: 1; - display: flex; - flex-direction: column; + flex: 1; + display: flex; + flex-direction: column; `; type Props = React.PropsWithChildren<{ @@ -12,30 +12,34 @@ type Props = React.PropsWithChildren<{ closeModal: () => void; }>; -export default function FullScreenDropZone({ children, showModal, closeModal }: Props) { +export default function FullScreenDropZone({ + children, + showModal, + closeModal, +}: Props) { const closeTimer = useRef(); - + const clearTimer = () => { if (closeTimer.current) { clearTimeout(closeTimer.current); } - } + }; const onDragOver = (e) => { e.preventDefault(); clearTimer(); showModal(); - } + }; const onDragLeave = (e) => { e.preventDefault(); clearTimer(); closeTimer.current = setTimeout(closeModal, 1000); - } + }; return ( {children} ); -}; +} diff --git a/src/components/PhotoSwipe/PhotoSwipe.tsx b/src/components/PhotoSwipe/PhotoSwipe.tsx index 2f211d3f3..5d40327e1 100644 --- a/src/components/PhotoSwipe/PhotoSwipe.tsx +++ b/src/components/PhotoSwipe/PhotoSwipe.tsx @@ -4,11 +4,14 @@ import PhotoswipeUIDefault from 'photoswipe/dist/photoswipe-ui-default'; import classnames from 'classnames'; import events from './events'; import FavButton from 'components/FavButton'; -import { addToFavorites, removeFromFavorites } from 'services/collectionService'; +import { + addToFavorites, + removeFromFavorites, +} from 'services/collectionService'; import { file } from 'services/fileService'; interface Iprops { - isOpen: boolean + isOpen: boolean; items: any[]; options?: Object; onClose?: () => void; @@ -17,28 +20,26 @@ interface Iprops { className?: string; favItemIds: Set; setFavItemIds: (favItemIds: Set) => void; -}; +} function PhotoSwipe(props: Iprops) { - let pswpElement; const [photoSwipe, setPhotoSwipe] = useState>(); const { isOpen } = props; - const [isFav, setIsFav] = useState(false) - + const [isFav, setIsFav] = useState(false); useEffect(() => { - if (!pswpElement) + if (!pswpElement) { return; - if (isOpen) + } + if (isOpen) { openPhotoSwipe(); - + } }, [pswpElement]); useEffect(() => { - if (!pswpElement) - return; + if (!pswpElement) return; if (isOpen) { openPhotoSwipe(); } @@ -47,17 +48,21 @@ function PhotoSwipe(props: Iprops) { } return () => { closePhotoSwipe(); - } + }; }, [isOpen]); function updateFavButton() { setIsFav(isInFav(this?.currItem)); } - const openPhotoSwipe = () => { const { items, options } = props; - let photoSwipe = new Photoswipe(pswpElement, PhotoswipeUIDefault, items, options); + let photoSwipe = new Photoswipe( + pswpElement, + PhotoswipeUIDefault, + items, + options + ); events.forEach((event) => { const callback = props[event]; if (callback || event === 'destroy') { @@ -75,7 +80,6 @@ function PhotoSwipe(props: Iprops) { photoSwipe.listen('beforeChange', updateFavButton); photoSwipe.init(); setPhotoSwipe(photoSwipe); - }; const updateItems = (items = []) => { @@ -88,8 +92,7 @@ function PhotoSwipe(props: Iprops) { }; const closePhotoSwipe = () => { - if (photoSwipe) - photoSwipe.close(); + if (photoSwipe) photoSwipe.close(); }; const handleClose = () => { @@ -102,10 +105,8 @@ function PhotoSwipe(props: Iprops) { const { favItemIds } = props; if (favItemIds && file) { return favItemIds.has(file.id); - } - else - return false; - } + } else return false; + }; const onFavClick = async (file) => { const { favItemIds, setFavItemIds } = props; @@ -114,15 +115,13 @@ function PhotoSwipe(props: Iprops) { await addToFavorites(file); setIsFav(true); setFavItemIds(favItemIds); - } - else { + } else { favItemIds.delete(file.id); - await removeFromFavorites(file) + await removeFromFavorites(file); setIsFav(false); setFavItemIds(favItemIds); - } - } + }; const { id } = props; let { className } = props; className = classnames(['pswp', className]).trim(); @@ -130,7 +129,7 @@ function PhotoSwipe(props: Iprops) {