From 037c068990432d13c4689a9b7ca765102f048c73 Mon Sep 17 00:00:00 2001 From: Carl Gunderson Date: Fri, 5 Jan 2024 21:57:26 -0800 Subject: [PATCH] position arrow safari ios --- src/components/CompanyItem/index.jsx | 108 +++++++++++++++------------ 1 file changed, 60 insertions(+), 48 deletions(-) diff --git a/src/components/CompanyItem/index.jsx b/src/components/CompanyItem/index.jsx index 05e8130..efd3848 100644 --- a/src/components/CompanyItem/index.jsx +++ b/src/components/CompanyItem/index.jsx @@ -126,55 +126,67 @@ const CompanyItem = ({ activeIdx, idx, item, onClick, onNav }) => { ) } -const Arrow = ({ direction, isDisabled, isFilled, item, onClick }) => ( - - - { - if (isDisabled) - return - onClick(e, direction) - } } +const Arrow = ({ direction, isDisabled, isFilled, item, onClick }) => { + const isIos = () => /iPhone|iPod|iPad/i.test(window.navigator.userAgent) + const isSafari = navigator.userAgent.includes('Safari') + && !navigator.userAgent.includes('Chrome') + + const isIosSafari = isIos && isSafari + + return ( + + isDisabled - ? isFilled - ? '#fff' - : item.bgColor - : theme.palette[item.slug].main, - }, - '&.Mui-disabled': { - pointerEvents: 'all', - }, + position: 'absolute', + top: direction === 'prev' + ? [isIosSafari ? '40px' : '20px', '40px'] + : 'auto', + bottom: direction === 'next' + ? [isIosSafari ? '40px' : '20px', '40px'] + : 'auto', }} - children={ - direction === 'next' - ? - : - } - /> - - -) + > + { + if (isDisabled) + return + onClick(e, direction) + } } + sx={{ + borderColor: isFilled ? '#fff' : item.bgColor, + '&:hover svg': { + fill: theme => isDisabled + ? isFilled + ? '#fff' + : item.bgColor + : theme.palette[item.slug].main, + }, + '&.Mui-disabled': { + pointerEvents: 'all', + }, + }} + children={ + direction === 'next' + ? + : + } + /> + + + ) +} export default CompanyItem