Skip to content

Commit

Permalink
🚸 (results) Improve results action buttons
Browse files Browse the repository at this point in the history
Now have an export all modal with settings and a better column order form
  • Loading branch information
baptisteArno committed Feb 14, 2023
1 parent 1a3596b commit 08e33fb
Show file tree
Hide file tree
Showing 16 changed files with 645 additions and 373 deletions.
25 changes: 25 additions & 0 deletions apps/builder/src/components/icons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ export const ChevronLeftIcon = (props: IconProps) => (
</Icon>
)

export const ChevronRightIcon = (props: IconProps) => (
<Icon viewBox="0 0 24 24" {...featherIconsBaseProps} {...props}>
<polyline points="9 18 15 12 9 6"></polyline>
</Icon>
)

export const PlusIcon = (props: IconProps) => (
<Icon viewBox="0 0 24 24" {...featherIconsBaseProps} {...props}>
<line x1="12" y1="5" x2="12" y2="19"></line>
Expand All @@ -57,6 +63,14 @@ export const MoreVerticalIcon = (props: IconProps) => (
</Icon>
)

export const MoreHorizontalIcon = (props: IconProps) => (
<Icon viewBox="0 0 24 24" {...featherIconsBaseProps} {...props}>
<circle cx="12" cy="12" r="1"></circle>
<circle cx="19" cy="12" r="1"></circle>
<circle cx="5" cy="12" r="1"></circle>
</Icon>
)

export const GlobeIcon = (props: IconProps) => (
<Icon viewBox="0 0 24 24" {...featherIconsBaseProps} {...props}>
<circle cx="12" cy="12" r="10"></circle>
Expand Down Expand Up @@ -505,3 +519,14 @@ export const CloudOffIcon = (props: IconProps) => (
<line x1="1" y1="1" x2="23" y2="23"></line>
</Icon>
)

export const ListIcon = (props: IconProps) => (
<Icon viewBox="0 0 24 24" {...featherIconsBaseProps} {...props}>
<line x1="8" y1="6" x2="21" y2="6"></line>
<line x1="8" y1="12" x2="21" y2="12"></line>
<line x1="8" y1="18" x2="21" y2="18"></line>
<line x1="3" y1="6" x2="3.01" y2="6"></line>
<line x1="3" y1="12" x2="3.01" y2="12"></line>
<line x1="3" y1="18" x2="3.01" y2="18"></line>
</Icon>
)
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { GraphNavigationRadioGroup } from './GraphNavigationRadioGroup'
import { AppearanceRadioGroup } from './AppearanceRadioGroup'

export const UserPreferencesForm = () => {
const { setColorMode } = useColorMode()
const { colorMode, setColorMode } = useColorMode()
const { user, updateUser } = useUser()

useEffect(() => {
Expand Down Expand Up @@ -35,7 +35,11 @@ export const UserPreferencesForm = () => {
<Stack spacing={6}>
<Heading size="md">Appearance</Heading>
<AppearanceRadioGroup
defaultValue={user?.preferredAppAppearance ?? 'system'}
defaultValue={
user?.preferredAppAppearance
? user.preferredAppAppearance
: colorMode
}
onChange={changeAppearance}
/>
</Stack>
Expand Down
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>
)
}
Loading

4 comments on commit 08e33fb

@vercel
Copy link

@vercel vercel bot commented on 08e33fb Feb 14, 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 08e33fb Feb 14, 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-git-main-typebot-io.vercel.app
builder-v2-typebot-io.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 08e33fb Feb 14, 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-typebot-io.vercel.app
docs-git-main-typebot-io.vercel.app
docs.typebot.io

@vercel
Copy link

@vercel vercel bot commented on 08e33fb Feb 14, 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

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

Please sign in to comment.