From 1027f019e5664daaa4a70d2f65b3b79f6b0ab3a7 Mon Sep 17 00:00:00 2001 From: Alec LaLonde Date: Wed, 6 Jan 2021 20:45:50 -0700 Subject: [PATCH] Added backdropFilter workaround and custom scrollbar for non-webkit browsers (#256) --- .../Player/Section/PlayerGallery.tsx | 23 +++++++++++-------- packages/web/utils/compatibilityHelpers.ts | 11 +++++++++ 2 files changed, 25 insertions(+), 9 deletions(-) create mode 100644 packages/web/utils/compatibilityHelpers.ts diff --git a/packages/web/components/Player/Section/PlayerGallery.tsx b/packages/web/components/Player/Section/PlayerGallery.tsx index eb78e620..0ba5c73e 100644 --- a/packages/web/components/Player/Section/PlayerGallery.tsx +++ b/packages/web/components/Player/Section/PlayerGallery.tsx @@ -19,6 +19,7 @@ import { import React from 'react'; import { FaTimes } from 'react-icons/fa'; +import { isBackdropFilterSupported } from '../../../utils/compatibilityHelpers'; import { ProfileSection } from '../../ProfileSection'; type Props = { player: PlayerFragmentFragment; onRemoveClick: () => void }; @@ -66,6 +67,15 @@ const GalleryItem: React.FC<{ nft: Collectible; noMargin?: boolean }> = ({ export const PlayerGallery: React.FC = ({ player, onRemoveClick }) => { const { isOpen, onOpen, onClose } = useDisclosure(); const { favorites, data, loading } = useOpenSeaCollectibles({ player }); + + const modalContentStyles = isBackdropFilterSupported() ? + { + backgroundColor: 'rgba(255,255,255,0.08)', + backdropFilter: 'blur(8px)' + } : { + backgroundColor: 'rgba(7, 2, 29, 0.91)' + }; + return ( {!loading && @@ -88,7 +98,7 @@ export const PlayerGallery: React.FC = ({ player, onRemoveClick }) => { isCentered scrollBehavior="inside" > - + @@ -110,13 +120,7 @@ export const PlayerGallery: React.FC = ({ player, onRemoveClick }) => { /> - + = ({ player, onRemoveClick }) => { borderBottomRadius="lg" w="100%" css={{ + 'scrollbar-color': 'rgba(70,20,100,0.8) rgba(255,255,255,0)', '::-webkit-scrollbar': { - width: '10px', + width: '8px', background: 'none', }, '::-webkit-scrollbar-thumb': { diff --git a/packages/web/utils/compatibilityHelpers.ts b/packages/web/utils/compatibilityHelpers.ts new file mode 100644 index 00000000..8ff7fe71 --- /dev/null +++ b/packages/web/utils/compatibilityHelpers.ts @@ -0,0 +1,11 @@ + +export const isBackdropFilterSupported = (): boolean => { + // https://developer.mozilla.org/en-US/docs/Web/API/CSS/supports + // https://developer.mozilla.org/en-US/docs/Web/CSS/backdrop-filter#Browser_compatibility + return ( + typeof CSS !== 'undefined' && ( + CSS.supports('-webkit-backdrop-filter', 'blur(1px)') || + CSS.supports('backdrop-filter', 'blur(1px)') + ) + ); +}