fix safari specific issues

This commit is contained in:
checktheroads 2021-01-02 12:54:00 -07:00
parent 8121202bb6
commit 777b117531
6 changed files with 65 additions and 27 deletions

View file

@ -115,6 +115,13 @@ export const Title = (props: TTitle) => {
flexDir="column"
minH={titleHeight}
justifyContent="center"
/* flexBasis
This is a fix for Safari specifically. LMGTFY: Safari flex-basis width. Nutshell: Safari
is stupid, in that it infers the default flex-basis from the width, 100%. Other browsers
don't do this. Without the below fix, the logo will appear gigantic, filling the entire
div up to the parent's max-width. The fix is to hard-code a flex-basis width.
*/
flexBasis={{ base: '100%', lg: '33%' }}
mt={[null, isSubmitting.value ? null : 'auto']}
{...rest}>
<Button

View file

@ -1,5 +1,6 @@
import { useRef } from 'react';
import { Flex } from '@chakra-ui/react';
import { isSafari } from 'react-device-detect';
import { If, Debugger, Greeting, Footer, Header } from '~/components';
import { useConfig, useColorValue } from '~/context';
import { useLGState, useLGMethods } from '~/hooks';
@ -28,11 +29,17 @@ export const Frame = (props: TFrame) => {
<Flex
bg={bg}
w="100%"
id="__hyperglass"
color={color}
flex="1 0 auto"
flexDir="column"
minHeight="100vh"
ref={containerRef}>
id="__hyperglass"
ref={containerRef}
/** minHeight
* This is a Safari-specific fix. Without it, the footer will appear to be "under" the
* viewport. Safari needs `-webkit-fill-available`, but other browsers need `100vh`.
* @see https://allthingssmitty.com/2020/05/11/css-fix-for-100vh-in-mobile-webkit/
*/
minHeight={isSafari ? '-webkit-fill-available' : '100vh'}>
<Header resetForm={handleReset} />
<Flex
px={2}

View file

@ -1,5 +1,7 @@
import dynamic from 'next/dynamic';
import { Box, Flex, Icon, IconButton, Slide } from '@chakra-ui/react';
import { Flex, Icon, IconButton } from '@chakra-ui/react';
import { AnimatePresence } from 'framer-motion';
import { AnimatedDiv } from '~/components';
import { useColorValue } from '~/context';
import { useLGState, useOpposingColor } from '~/hooks';
@ -13,27 +15,33 @@ export const ResetButton = (props: TResetButton) => {
const bg = useColorValue('primary.500', 'primary.300');
const color = useOpposingColor(bg);
return (
<Slide direction="left" in={isSubmitting.value} unmountOnExit style={{ width: 'auto' }}>
<Box
bg={bg}
left={0}
zIndex={4}
bottom={24}
boxSize={12}
color={color}
position="fixed"
borderRightRadius="md"
mb={developerMode ? 14 : undefined}>
<Flex boxSize="100%" justifyContent="center" alignItems="center" {...rest}>
<IconButton
color="current"
variant="ghost"
aria-label="Reset"
onClick={resetForm}
icon={<Icon as={LeftArrow} boxSize={8} />}
/>
</Flex>
</Box>
</Slide>
<AnimatePresence>
{isSubmitting.value && (
<AnimatedDiv
bg={bg}
left={0}
zIndex={4}
bottom={24}
boxSize={12}
color={color}
position="fixed"
animate={{ x: 0 }}
exit={{ x: '-100%' }}
borderRightRadius="md"
initial={{ x: '-100%' }}
mb={developerMode ? { base: 0, lg: 14 } : undefined}
transition={{ duration: 0.15, ease: [0.4, 0, 0.2, 1] }}>
<Flex boxSize="100%" justifyContent="center" alignItems="center" {...rest}>
<IconButton
variant="unstyled"
color="current"
aria-label="Reset"
onClick={resetForm}
icon={<Icon as={LeftArrow} boxSize={8} />}
/>
</Flex>
</AnimatedDiv>
)}
</AnimatePresence>
);
};

View file

@ -30,6 +30,7 @@
"next": "^10.0.4",
"react": "^17.0.1",
"react-countdown": "^2.2.1",
"react-device-detect": "^1.15.0",
"react-dom": "^17.0.1",
"react-fast-compare": "^3.2.0",
"react-flow-renderer": "^8.2.3",

View file

@ -30,7 +30,10 @@ const App = (props: TApp) => {
<meta name="og:image" content="/images/opengraph.jpg" />
<meta property="og:image:width" content="1200" />
<meta property="og:image:height" content="630" />
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, user-scalable=no, maximum-scale=1.0, minimum-scale=1.0"
/>
</Head>
<HyperglassProvider config={config}>
<Component {...pageProps} />

View file

@ -5466,6 +5466,13 @@ react-countdown@^2.2.1:
dependencies:
prop-types "^15.7.2"
react-device-detect@^1.15.0:
version "1.15.0"
resolved "https://registry.yarnpkg.com/react-device-detect/-/react-device-detect-1.15.0.tgz#5321f94ae3c4d51ef399b0502a6c739e32d0f315"
integrity sha512-ywjtWW04U7vaJK87IAFHhKozZhTPeDVWsfYx5CxQSQCjU5+fnMMxWZt9HnVWaNTqBEn6g8wCNWyqav7sXJrURg==
dependencies:
ua-parser-js "^0.7.23"
react-dom@^17.0.1:
version "17.0.1"
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-17.0.1.tgz#1de2560474ec9f0e334285662ede52dbc5426fc6"
@ -6766,6 +6773,11 @@ typescript@^4.0.3:
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.0.3.tgz#153bbd468ef07725c1df9c77e8b453f8d36abba5"
integrity sha512-tEu6DGxGgRJPb/mVPIZ48e69xCn2yRmCgYmDugAVwmJ6o+0u1RI18eO7E7WBTLYLaEVVOhwQmcdhQHweux/WPg==
ua-parser-js@^0.7.23:
version "0.7.23"
resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.23.tgz#704d67f951e13195fbcd3d78818577f5bc1d547b"
integrity sha512-m4hvMLxgGHXG3O3fQVAyyAQpZzDOvwnhOTjYz5Xmr7r/+LpkNy3vJXdVRWgd1TkAb7NGROZuSy96CrlNVjA7KA==
unherit@^1.0.4:
version "1.1.3"
resolved "https://registry.yarnpkg.com/unherit/-/unherit-1.1.3.tgz#6c9b503f2b41b262330c80e91c8614abdaa69c22"