Skip to content

Commit

Permalink
💄 Improve new version popup animation
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Feb 22, 2023
1 parent 00b6acc commit 31711dc
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 54 deletions.
88 changes: 52 additions & 36 deletions apps/builder/src/components/NewVersionPopup.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import { useTypebot } from '@/features/editor'
import { Button, Flex, HStack, Stack, Text } from '@chakra-ui/react'
import {
Button,
DarkMode,
Flex,
HStack,
SlideFade,
Stack,
Text,
} from '@chakra-ui/react'
import { useEffect, useState } from 'react'
import { sendRequest } from 'utils'
import { PackageIcon } from './icons'
Expand Down Expand Up @@ -42,43 +50,51 @@ export const NewVersionPopup = () => {
window.location.reload()
}

if (!isNewVersionAvailable) return null

return (
<Stack
pos="fixed"
bottom="18px"
left="18px"
bgColor="blue.400"
p="4"
px="4"
rounded="lg"
shadow="lg"
zIndex={10}
borderWidth="1px"
borderColor="blue.300"
maxW="320px"
>
<HStack spacing={3}>
<Stack spacing={4}>
<Stack spacing={1} color="white">
<HStack>
<PackageIcon />{' '}
<Text fontWeight="bold">New version available!</Text>
</HStack>
<DarkMode>
<SlideFade
in={isNewVersionAvailable}
offsetY="20px"
style={{
position: 'fixed',
bottom: '18px',
left: '18px',
zIndex: 42,
}}
unmountOnExit
>
<Stack
bgColor="blue.400"
p="4"
px="4"
rounded="lg"
shadow="lg"
borderWidth="1px"
borderColor="blue.300"
maxW="320px"
>
<HStack spacing={3}>
<Stack spacing={4} color="white">
<Stack spacing={1}>
<HStack>
<PackageIcon />{' '}
<Text fontWeight="bold">New version available!</Text>
</HStack>

<Text fontSize="sm" color="gray.100">
An improved version of Typebot is available. Please reload now to
upgrade.
</Text>
</Stack>
<Flex justifyContent="flex-end">
<Button size="sm" onClick={saveAndReload}>
{typebot?.id ? 'Save and reload' : 'Reload'}
</Button>
</Flex>
<Text fontSize="sm" color="gray.100">
An improved version of Typebot is available. Please reload now
to upgrade.
</Text>
</Stack>
<Flex justifyContent="flex-end">
<Button size="sm" onClick={saveAndReload}>
{typebot?.id ? 'Save and reload' : 'Reload'}
</Button>
</Flex>
</Stack>
</HStack>
</Stack>
</HStack>
</Stack>
</SlideFade>
</DarkMode>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export const TypebotProvider = ({
typebotId,
}: {
children: ReactNode
typebotId: string
typebotId?: string
}) => {
const { status } = useSession()
const { push } = useRouter()
Expand Down
4 changes: 2 additions & 2 deletions apps/builder/src/hooks/useTypebotQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const useTypebotQuery = ({
typebotId,
onError,
}: {
typebotId: string
typebotId?: string
onError?: (error: Error) => void
}) => {
const { data, error, mutate } = useSWR<
Expand All @@ -18,7 +18,7 @@ export const useTypebotQuery = ({
isReadOnly?: boolean
},
Error
>(`/api/typebots/${typebotId}`, fetcher, {
>(typebotId ? `/api/typebots/${typebotId}` : null, fetcher, {
dedupingInterval: env('E2E_TEST') === 'true' ? 0 : undefined,
})
if (error && onError) onError(error)
Expand Down
21 changes: 6 additions & 15 deletions apps/builder/src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const App = ({
pageProps: { session, ...pageProps },
}: AppProps<{ session?: Session }>) => {
useRouterProgressBar()
const { query, pathname, isReady } = useRouter()
const { query, pathname } = useRouter()

useEffect(() => {
pathname.endsWith('/edit')
Expand All @@ -38,13 +38,12 @@ const App = ({
const newPlan = query.stripe?.toString()
if (newPlan === Plan.STARTER || newPlan === Plan.PRO)
toast({
position: 'bottom-right',
position: 'top-right',
status: 'success',
title: 'Upgrade success!',
description: `Workspace upgraded to ${toTitleCase(newPlan)} 🎉`,
})
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isReady])
}, [query.stripe])

const typebotId = query.typebotId?.toString()

Expand All @@ -54,21 +53,13 @@ const App = ({
<ChakraProvider theme={customTheme}>
<SessionProvider session={session}>
<UserProvider>
{typebotId ? (
<TypebotProvider typebotId={typebotId}>
<WorkspaceProvider typebotId={typebotId}>
<Component />
<SupportBubble />
<NewVersionPopup />
</WorkspaceProvider>
</TypebotProvider>
) : (
<WorkspaceProvider>
<TypebotProvider typebotId={typebotId}>
<WorkspaceProvider typebotId={typebotId}>
<Component {...pageProps} />
<SupportBubble />
<NewVersionPopup />
</WorkspaceProvider>
)}
</TypebotProvider>
</UserProvider>
</SessionProvider>
</ChakraProvider>
Expand Down

4 comments on commit 31711dc

@vercel
Copy link

@vercel vercel bot commented on 31711dc Feb 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 31711dc Feb 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

docs – ./apps/docs

docs-git-main-typebot-io.vercel.app
docs.typebot.io
docs-typebot-io.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 31711dc Feb 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

viewer-v2 – ./apps/viewer

an.nigerias.io
app.yvon.earth
ar.nigerias.io
bot.enreso.org
bot.rslabs.pro
bots.bridge.ai
chat.hayuri.id
chicken.cr8.ai
gollum.riku.ai
gsbulletin.com
panther.cr7.ai
panther.cr8.ai
penguin.cr8.ai
talk.gocare.io
test.bot.gives
ticketfute.com
unicorn.cr8.ai
apo.nigerias.io
apr.nigerias.io
aso.nigerias.io
bot.ageenda.com
bot.artiweb.app
bot.devitus.com
bot.jesopizz.it
bot.reeplai.com
bot.scayver.com
bot.tc-mail.com
chat.lalmon.com
chat.sureb4.com
eventhub.com.au
fitness.riku.ai
games.klujo.com
help.taxtree.io
sakuranembro.it
typebot.aloe.do
bot.contakit.com
bot.piccinato.co
bot.sv-energy.it
botc.ceox.com.br
clo.closeer.work
cockroach.cr8.ai
faqs.nigerias.io
feedback.ofx.one
form.syncwin.com
haymanevents.com
kw.wpwakanda.com
bot.viralsangat.com
bot.winglabs.com.br
carsalesenquiry.com
chat.marius.digital
chatbot.matthesv.de
chatbot.repplai.com
demo.botscientis.us
demo.wemakebots.xyz
forms.webisharp.com
kbsub.wpwakanda.com
live.botscientis.us
mentoria.omelhor.vc
nutrisamirbayde.com
order.maitempah.com
quest.wpwakanda.com
support.wawplus.com
survey1.digienge.io
surveys.essiell.com
test.botscientis.us
test.reventepro.com
typebot.stillio.com
wordsandimagery.com
88584434.therpm.club
92109660.therpm.club
abbonamento.bwell.it
bium.gratirabbit.com
bot.ansuraniphone.my
bot.barrettamario.it
bot.cotemeuplano.com
bot.leadbooster.help
bot.mycompay.reviews
chat.hayurihijab.com
chatbee.agfunnel.com
click.sevenoways.com
connect.growthguy.in
forms.bonanza.design
hello.advergreen.com
kuiz.sistemniaga.com
offer.botscientis.us
sellmycarglasgow.com
talkbot.agfunnel.com
tenorioadvogados.com
uppity.wpwakanda.com
abutton.wpwakanda.com
acelera.maxbot.com.br
aidigitalmarketing.kr
help.atlasoutfittersk9.com
herbalife.barrettamario.it
homepageonly.wpwakanda.com
liveconvert.kandalearn.com
mainmenu1one.wpwakanda.com
tarian.theiofoundation.org
ted.meujalecobrasil.com.br
type.dericsoncalari.com.br

@vercel
Copy link

@vercel vercel bot commented on 31711dc Feb 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

builder-v2 – ./apps/builder

app.typebot.io
builder-v2-typebot-io.vercel.app
builder-v2-git-main-typebot-io.vercel.app

Please sign in to comment.