Skip to content

Commit

Permalink
fix(giphy): search
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Aug 12, 2022
1 parent 6716cf2 commit 5333ba9
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 85 deletions.
60 changes: 0 additions & 60 deletions apps/builder/components/shared/ImageUploadContent/GiphySearch.tsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { Flex, Stack, Text } from '@chakra-ui/react'
import { GiphyFetch } from '@giphy/js-fetch-api'
import { Grid } from '@giphy/react-components'
import { GiphyLogo } from 'assets/logos'
import React, { useState } from 'react'
import { env, isEmpty } from 'utils'
import { Input } from '../Textbox'

type GiphySearchFormProps = {
onSubmit: (url: string) => void
}

const giphyFetch = new GiphyFetch(env('GIPHY_API_KEY') as string)

export const GiphySearchForm = ({ onSubmit }: GiphySearchFormProps) => {
const [inputValue, setInputValue] = useState('')

const fetchGifs = (offset: number) =>
giphyFetch.search(inputValue, { offset, limit: 10 })

const fetchGifsTrending = (offset: number) =>
giphyFetch.trending({ offset, limit: 10 })

return isEmpty(env('GIPHY_API_KEY')) ? (
<Text>NEXT_PUBLIC_GIPHY_API_KEY is missing in environment</Text>
) : (
<Stack>
<Flex align="center">
<Input
flex="1"
autoFocus
placeholder="Search..."
onChange={setInputValue}
value={inputValue}
withVariableButton={false}
/>
<GiphyLogo w="100px" />
</Flex>
<Flex overflowY="scroll" maxH="400px">
<Grid
key={inputValue}
onGifClick={(gif, e) => {
e.preventDefault()
onSubmit(gif.images.downsized.url)
}}
fetchGifs={inputValue === '' ? fetchGifsTrending : fetchGifs}
width={475}
columns={3}
className="my-4"
/>
</Flex>
</Stack>
)
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { useState } from 'react'
import { Button, Flex, HStack, Stack, Text } from '@chakra-ui/react'
import { SearchContextManager } from '@giphy/react-components'
import { Button, Flex, HStack, Stack } from '@chakra-ui/react'
import { UploadButton } from '../buttons/UploadButton'
import { GiphySearch } from './GiphySearch'
import { GiphySearchForm } from './GiphySearchForm'
import { useTypebot } from 'contexts/TypebotContext'
import { Input } from '../Textbox/Input'
import { env, isEmpty } from 'utils'
import { EmojiSearchableList } from './emoji/EmojiSearchableList'

type Props = {
Expand Down Expand Up @@ -123,12 +121,6 @@ const EmbedLinkContent = ({ initialUrl, onNewUrl }: ContentProps) => (
</Stack>
)

const GiphyContent = ({ onNewUrl }: ContentProps) => {
if (isEmpty(env('GIPHY_API_KEY')))
return <Text>NEXT_PUBLIC_GIPHY_API_KEY is missing in environment</Text>
return (
<SearchContextManager apiKey={env('GIPHY_API_KEY') as string}>
<GiphySearch onSubmit={onNewUrl} />
</SearchContextManager>
)
}
const GiphyContent = ({ onNewUrl }: ContentProps) => (
<GiphySearchForm onSubmit={onNewUrl} />
)
2 changes: 1 addition & 1 deletion apps/builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
},
"devDependencies": {
"@babel/core": "7.18.10",
"@playwright/test": "1.24.2",
"@playwright/test": "1.25.0",
"@types/canvas-confetti": "^1.4.3",
"@types/google-spreadsheet": "^3.3.0",
"@types/jsonwebtoken": "8.5.8",
Expand Down
18 changes: 17 additions & 1 deletion apps/builder/playwright/tests/bubbles/image.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,23 @@ test.describe.parallel('Image bubble block', () => {

await page.click('text=Click to edit...')
await page.click('text=Giphy')
await page.click('img >> nth=3', {
const firstGiphyImage = page.locator('.giphy-gif-img >> nth=0')
await expect(firstGiphyImage).toHaveAttribute(
'src',
new RegExp('giphy.com/media', 'gm')
)
const trendingfirstImageSrc = await firstGiphyImage.getAttribute('src')
expect(trendingfirstImageSrc).toMatch(new RegExp('giphy.com/media', 'gm'))
await page.fill('[placeholder="Search..."]', 'fun')
await page.waitForTimeout(500)
await expect(firstGiphyImage).toHaveAttribute(
'src',
new RegExp('giphy.com/media', 'gm')
)
const funFirstImageSrc = await firstGiphyImage.getAttribute('src')
expect(funFirstImageSrc).toMatch(new RegExp('giphy.com/media', 'gm'))
expect(trendingfirstImageSrc).not.toBe(funFirstImageSrc)
await firstGiphyImage.click({
force: true,
position: { x: 0, y: 0 },
})
Expand Down
2 changes: 1 addition & 1 deletion apps/viewer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
},
"devDependencies": {
"@types/papaparse": "5.3.3",
"@playwright/test": "1.24.2",
"@playwright/test": "1.25.0",
"eslint-plugin-react": "^7.30.1",
"@types/cors": "^2.8.12",
"@types/google-spreadsheet": "^3.3.0",
Expand Down
18 changes: 9 additions & 9 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 comments on commit 5333ba9

@vercel
Copy link

@vercel vercel bot commented on 5333ba9 Aug 12, 2022

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 5333ba9 Aug 12, 2022

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

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

@vercel
Copy link

@vercel vercel bot commented on 5333ba9 Aug 12, 2022

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.vercel.app
docs.typebot.io

@vercel
Copy link

@vercel vercel bot commented on 5333ba9 Aug 12, 2022

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 5333ba9 Aug 12, 2022

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-alpha – ./apps/viewer

8jours.top
bot.aws.bj
sat.cr8.ai
bt.id8rs.com
yobot.me
247987.com
am.nigerias.io
finplex.be
vhpage.cr8.ai
bot.aipr.kr
aso.nigerias.io
bot.artiweb.app
ar.nigerias.io
bot.lalmon.com
an.nigerias.io
apo.nigerias.io
ticketfute.com
apr.nigerias.io
eventhub.com.au
chat.sureb4.com
games.klujo.com
sakuranembro.it
typebot.aloe.do
bot.piccinato.co
bot.upfunnel.art
rdhs.digienge.io
faqs.nigerias.io
kw.wpwakanda.com
feedback.ofx.one
clo.closeer.work
typebot.aloe.bot
stan.vselise.com
voicehelp.cr8.ai
app.chatforms.net
bot.phuonghub.com
cares.urlabout.me
bot.maitempah.com
gentleman-shop.fr
bot.agfunnel.tech
fmm.wpwakanda.com
lb.ticketfute.com
k1.kandabrand.com
ov1.wpwakanda.com
ov3.wpwakanda.com
bot.neferlopez.com
andreimayer.com.br
goalsettingbot.com
1988.bouclidom.com
dicanatural.online
ov2.wpwakanda.com
rdhs06.digienge.io
survey.digienge.io
this-is-a-test.com
zap.techadviser.in
bot.digitalbled.com
carsalesenquiry.com
bot.eventhub.com.au
forms.webisharp.com
order.maitempah.com
quest.wpwakanda.com
typebot.stillio.com
survey1.digienge.io
bot.ansuraniphone.my
bium.gratirabbit.com
chat.hayurihijab.com
click.sevenoways.com
bot.cotemeuplano.com
connect.growthguy.in
get.freebotoffer.xyz
abutton.wpwakanda.com
bbutton.wpwakanda.com
aidigitalmarketing.kr
bot.meuesocial.com.br
bot.incusservices.com
bbutton.wpwwakanda.com
chat.missarkansas.org
sbutton.wpwakanda.com
cdd.searchcube.com.sg
apply.ansuraniphone.my
c23111azqw.nigerias.io
form.searchcube.com.sg
felipewelington.com.br
gcase.barrettamario.it
info.clickasuransi.com
kodawariab736.skeep.it
report.gratirabbit.com
view.onlinebotdemo.xyz
resume.gratirabbit.com
83242573.actualizar.xyz
bot.blackboxtips.com.br
signup.hypemarketing.in
bot.upgradesolutions.eu
mainmenu.diddancing.com
subfooter.wpwakanda.com
survey.hypemarketing.in
91181264.your-access.one
form.sergiolimajr.com.br
type.opaulovieira.com.br
bot.blackboxsports.com.br
aibot.angrybranding.co.uk

Please sign in to comment.