-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🚸 (results) Improve results action buttons
Now have an export all modal with settings and a better column order form
- Loading branch information
1 parent
1a3596b
commit 08e33fb
Showing
16 changed files
with
645 additions
and
373 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
170 changes: 170 additions & 0 deletions
170
apps/builder/src/features/results/components/ResultsTable/ColumnSettings.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
import { EyeOffIcon, GripIcon, EyeIcon } from '@/components/icons' | ||
import { Stack, Portal, Flex, HStack, IconButton } from '@chakra-ui/react' | ||
import { | ||
DndContext, | ||
closestCenter, | ||
DragOverlay, | ||
useSensors, | ||
PointerSensor, | ||
KeyboardSensor, | ||
useSensor, | ||
DragEndEvent, | ||
DragStartEvent, | ||
} from '@dnd-kit/core' | ||
import { | ||
SortableContext, | ||
verticalListSortingStrategy, | ||
useSortable, | ||
sortableKeyboardCoordinates, | ||
arrayMove, | ||
} from '@dnd-kit/sortable' | ||
import { Text } from '@chakra-ui/react' | ||
import { ResultHeaderCell } from 'models' | ||
import { HeaderIcon } from '../../utils' | ||
import { useState } from 'react' | ||
import { CSS } from '@dnd-kit/utilities' | ||
|
||
type Props = { | ||
resultHeader: ResultHeaderCell[] | ||
columnVisibility: { [key: string]: boolean } | ||
columnOrder: string[] | ||
onColumnOrderChange: (columnOrder: string[]) => void | ||
setColumnVisibility: (columnVisibility: { [key: string]: boolean }) => void | ||
} | ||
|
||
export const ColumnSettings = ({ | ||
resultHeader, | ||
columnVisibility, | ||
setColumnVisibility, | ||
columnOrder, | ||
onColumnOrderChange, | ||
}: Props) => { | ||
const sensors = useSensors( | ||
useSensor(PointerSensor), | ||
useSensor(KeyboardSensor, { | ||
coordinateGetter: sortableKeyboardCoordinates, | ||
}) | ||
) | ||
const [draggingColumnId, setDraggingColumnId] = useState<string | null>(null) | ||
|
||
const onEyeClick = (id: string) => () => { | ||
columnVisibility[id] === false | ||
? setColumnVisibility({ ...columnVisibility, [id]: true }) | ||
: setColumnVisibility({ ...columnVisibility, [id]: false }) | ||
} | ||
const sortedHeader = resultHeader.sort( | ||
(a, b) => columnOrder.indexOf(a.id) - columnOrder.indexOf(b.id) | ||
) | ||
const hiddenHeaders = resultHeader.filter( | ||
(header) => columnVisibility[header.id] === false | ||
) | ||
|
||
const handleDragStart = (event: DragStartEvent) => { | ||
const { active } = event | ||
setDraggingColumnId(active.id as string) | ||
} | ||
|
||
const handleDragEnd = (event: DragEndEvent) => { | ||
const { active, over } = event | ||
|
||
if (active.id !== over?.id) { | ||
const oldIndex = columnOrder.indexOf(active.id as string) | ||
const newIndex = columnOrder.indexOf(over?.id as string) | ||
if (newIndex === -1 || oldIndex === -1) return | ||
const newColumnOrder = arrayMove(columnOrder, oldIndex, newIndex) | ||
onColumnOrderChange(newColumnOrder) | ||
} | ||
} | ||
|
||
return ( | ||
<Stack> | ||
<Stack> | ||
<Text fontWeight="semibold" fontSize="sm"> | ||
Shown in table: | ||
</Text> | ||
<DndContext | ||
sensors={sensors} | ||
collisionDetection={closestCenter} | ||
onDragStart={handleDragStart} | ||
onDragEnd={handleDragEnd} | ||
> | ||
<SortableContext | ||
items={columnOrder} | ||
strategy={verticalListSortingStrategy} | ||
> | ||
{sortedHeader.map((header) => ( | ||
<SortableColumns | ||
key={header.id} | ||
header={header} | ||
onEyeClick={onEyeClick} | ||
hiddenHeaders={hiddenHeaders} | ||
/> | ||
))} | ||
</SortableContext> | ||
<Portal> | ||
<DragOverlay dropAnimation={{ duration: 0 }}> | ||
{draggingColumnId ? <Flex /> : null} | ||
</DragOverlay> | ||
</Portal> | ||
</DndContext> | ||
</Stack> | ||
</Stack> | ||
) | ||
} | ||
|
||
const SortableColumns = ({ | ||
header, | ||
hiddenHeaders, | ||
onEyeClick, | ||
}: { | ||
header: ResultHeaderCell | ||
hiddenHeaders: ResultHeaderCell[] | ||
onEyeClick: (key: string) => () => void | ||
}) => { | ||
const { | ||
attributes, | ||
listeners, | ||
setNodeRef, | ||
transform, | ||
transition, | ||
isDragging, | ||
} = useSortable({ id: header.id }) | ||
|
||
const style = { | ||
transform: CSS.Transform.toString(transform), | ||
transition, | ||
} | ||
|
||
const isHidden = hiddenHeaders.some( | ||
(hiddenHeader) => hiddenHeader.id === header.id | ||
) | ||
|
||
return ( | ||
<Flex | ||
justify="space-between" | ||
ref={setNodeRef} | ||
style={style} | ||
opacity={isDragging || isHidden ? 0.5 : 1} | ||
{...attributes} | ||
> | ||
<HStack> | ||
<IconButton | ||
size="sm" | ||
cursor="grab" | ||
icon={<GripIcon transform="rotate(90deg)" />} | ||
aria-label={'Drag'} | ||
variant="ghost" | ||
{...listeners} | ||
/> | ||
<HeaderIcon header={header} /> | ||
<Text noOfLines={1}>{header.label}</Text> | ||
</HStack> | ||
<IconButton | ||
icon={isHidden ? <EyeOffIcon /> : <EyeIcon />} | ||
size="sm" | ||
aria-label={'Hide column'} | ||
onClick={onEyeClick(header.id)} | ||
/> | ||
</Flex> | ||
) | ||
} |
Oops, something went wrong.
08e33fb
There was a problem hiding this comment.
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:
landing-page-v2 – ./apps/landing-page
landing-page-v2-typebot-io.vercel.app
typebot.io
get-typebot.com
landing-page-v2-git-main-typebot-io.vercel.app
www.get-typebot.com
www.typebot.io
08e33fb
There was a problem hiding this comment.
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-git-main-typebot-io.vercel.app
builder-v2-typebot-io.vercel.app
08e33fb
There was a problem hiding this comment.
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-git-main-typebot-io.vercel.app
docs.typebot.io
08e33fb
There was a problem hiding this comment.
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
stan.vselise.com
start.taxtree.io
typebot.aloe.bot
voicehelp.cr8.ai
zap.fundviser.in
app.chatforms.net
bot.hostnation.de
bot.maitempah.com
bot.phuonghub.com
bot.reviewzer.com
bot.rihabilita.it
cares.urlabout.me
chat.gaswadern.de
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
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
bbutton.wpwakanda.com
bot.coachayongzul.com
mainmenu1one.wpwakanda.com
tarian.theiofoundation.org
ted.meujalecobrasil.com.br
type.dericsoncalari.com.br
bot.pinpointinteractive.com
bot.polychromes-project.com
bot.seidinembroseanchetu.it
chatbot.berbelanjabiz.trade
designguide.techyscouts.com
liveconvert2.kandalearn.com
presente.empresarias.com.mx
sell.sellthemotorhome.co.uk
anamnese.odontopavani.com.br
austin.channelautomation.com
bot.marketingplusmindset.com
bot.seidibergamoseanchetu.it
desabafe.sergiolimajr.com.br
download.venturemarketing.in
piazzatorre.barrettamario.it
type.cookieacademyonline.com
bot.brigadeirosemdrama.com.br
forms.escoladeautomacao.com.br
onboarding.libertydreamcare.ie
type.talitasouzamarques.com.br
agendamento.sergiolimajr.com.br
anamnese.clinicamegasjdr.com.br
bookings.littlepartymonkeys.com
bot.comercializadoraomicron.com
elevateyourmind.groovepages.com
viewer-v2-typebot-io.vercel.app
yourfeedback.comebackreward.com
gerador.verificadordehospedes.com
personal-trainer.barrettamario.it
preagendamento.sergiolimajr.com.br
studiotecnicoimmobiliaremerelli.it
download.thailandmicespecialist.com
register.thailandmicespecialist.com
bot.studiotecnicoimmobiliaremerelli.it
pesquisa.escolamodacomproposito.com.br
anamnese.clinicaramosodontologia.com.br
viewer-v2-git-main-typebot-io.vercel.app