Skip to content

Commit

Permalink
fix(results): 🐛 Ignore cell content for column size
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Jul 1, 2022
1 parent 38a3ee7 commit 994ae61
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 42 deletions.
66 changes: 66 additions & 0 deletions apps/builder/components/results/ResultsTable/Cell.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { chakra, Fade, Button } from '@chakra-ui/react'
import { Cell as CellProps } from '@tanstack/react-table'
import { ExpandIcon } from 'assets/icons'
import { memo } from 'react'

type Props = {
cell: CellProps<any>
size: number
isExpandButtonVisible: boolean
cellIndex: number
onExpandButtonClick: () => void
}

const Cell = ({
cell,
size,
isExpandButtonVisible,
cellIndex,
onExpandButtonClick,
}: Props) => {
return (
<chakra.td
key={cell.id}
px="4"
py="2"
border="1px"
borderColor="gray.200"
whiteSpace="nowrap"
wordBreak="normal"
overflow="hidden"
pos="relative"
style={{
minWidth: size,
maxWidth: size,
}}
>
{cell.renderCell()}
<chakra.span
pos="absolute"
top="0"
right={2}
h="full"
display="inline-flex"
alignItems="center"
>
<Fade unmountOnExit in={isExpandButtonVisible && cellIndex === 1}>
<Button
leftIcon={<ExpandIcon />}
shadow="lg"
size="xs"
onClick={onExpandButtonClick}
>
Open
</Button>
</Fade>
</chakra.span>
</chakra.td>
)
}

export default memo(
Cell,
(prev, next) =>
prev.size === next.size &&
prev.isExpandButtonVisible === next.isExpandButtonVisible
)
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { ColumnSettingsButton } from './ColumnsSettingsButton'
import { useTypebot } from 'contexts/TypebotContext'
import { useDebounce } from 'use-debounce'
import { ResultsActionButtons } from './ResultsActionButtons'
import Row from './Row'
import { Row } from './Row'
import { HeaderRow } from './HeaderRow'

type RowType = {
Expand Down
51 changes: 10 additions & 41 deletions apps/builder/components/results/ResultsTable/Row.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { memo, useState } from 'react'
import React, { useState } from 'react'
import { Row as RowProps } from '@tanstack/react-table'
import { Button, chakra, Fade } from '@chakra-ui/react'
import { ExpandIcon } from 'assets/icons'
import Cell from './Cell'

type Props = {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand All @@ -11,7 +10,7 @@ type Props = {
onExpandButtonClick: () => void
}

const Row = ({ row, bottomElement, onExpandButtonClick }: Props) => {
export const Row = ({ row, bottomElement, onExpandButtonClick }: Props) => {
const [isExpandButtonVisible, setIsExpandButtonVisible] = useState(false)

const showExpandButton = () => setIsExpandButtonVisible(true)
Expand All @@ -29,45 +28,15 @@ const Row = ({ row, bottomElement, onExpandButtonClick }: Props) => {
onMouseLeave={hideExpandButton}
>
{row.getVisibleCells().map((cell, cellIndex) => (
<chakra.td
<Cell
key={cell.id}
px="4"
py="2"
border="1px"
borderColor="gray.200"
whiteSpace="nowrap"
wordBreak="normal"
overflow="hidden"
pos="relative"
>
{cell.renderCell()}
<chakra.span
pos="absolute"
top="0"
right={2}
h="full"
display="inline-flex"
alignItems="center"
>
<Fade unmountOnExit in={isExpandButtonVisible && cellIndex === 1}>
<Button
leftIcon={<ExpandIcon />}
shadow="lg"
size="xs"
onClick={onExpandButtonClick}
>
Open
</Button>
</Fade>
</chakra.span>
</chakra.td>
cell={cell}
size={cell.column.getSize()}
isExpandButtonVisible={isExpandButtonVisible}
cellIndex={cellIndex}
onExpandButtonClick={onExpandButtonClick}
/>
))}
</tr>
)
}

export default memo(
Row,
(prev, next) =>
prev.row.id === next.row.id && prev.isSelected === next.isSelected
)

4 comments on commit 994ae61

@vercel
Copy link

@vercel vercel bot commented on 994ae61 Jul 1, 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 994ae61 Jul 1, 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

vhpage.cr8.ai
an.nigerias.io
apr.nigerias.io
sat.cr8.ai
bot.aws.bj
ar.nigerias.io
apo.nigerias.io
aso.nigerias.io
am.nigerias.io
bt.id8rs.com
chat.sureb4.com
eventhub.com.au
clo.closeer.work
feedback.ofx.one
faqs.nigerias.io
bot.upfunnel.art
games.klujo.com
bot.piccinato.co
sakuranembro.it
stan.vselise.com
voicehelp.cr8.ai
app.chatforms.net
bot.agfunnel.tech
bot.maitempah.com
ov3.wpwakanda.com
ov2.wpwakanda.com
gentleman-shop.fr
ov1.wpwakanda.com
sell.applepie.pro
admin.applepie.pro
goalsettingbot.com
zap.techadviser.in
bot.eventhub.com.au
forms.webisharp.com
this-is-a-test.com
bot.cotemeuplano.com
typebot.stillio.com
bot.ansuraniphone.my
order.maitempah.com
chat.hayurihijab.com
get.freebotoffer.xyz
abutton.wpwakanda.com
bbutton.wpwakanda.com
cdd.searchcube.com.sg
bot.meuesocial.com.br
bot.incusservices.com
sbutton.wpwakanda.com
apply.ansuraniphone.my
c23111azqw.nigerias.io
chat.missarkansas.org
bbutton.wpwwakanda.com
felipewelington.com.br
form.searchcube.com.sg
kodawariab736.skeep.it
gcase.barrettamario.it
info.clickasuransi.com
83242573.actualizar.xyz
view.onlinebotdemo.xyz
bot.upgradesolutions.eu
mainmenu.diddancing.com
subfooter.wpwakanda.com
91181264.your-access.one
form.sergiolimajr.com.br
type.opaulovieira.com.br
hunterbot.saleshunter.ai
bot.cabinrentalagency.com
aibot.angrybranding.co.uk
boyfriend-breakup.riku.ai
type.dericsoncalari.com.br
designguide.techyscouts.com
presente.empresarias.com.mx
onboarding.libertydreamcare.ie
piazzatorre.barrettamario.it
type.talitasouzamarques.com.br
bot.comercializadoraomicron.com
agendamento.sergiolimajr.com.br
personal-trainer.barrettamario.it
bookings.littlepartymonkeys.com
studiotecnicoimmobiliaremerelli.it
preagendamento.sergiolimajr.com.br
viewer-v2-alpha-typebot-io.vercel.app
viewer-v2-alpha-git-main-typebot-io.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 994ae61 Jul 1, 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-typebot-io.vercel.app
docs.typebot.io
docs-git-main-typebot-io.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 994ae61 Jul 1, 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

Please sign in to comment.