Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

Fix broken UI elements

Blue Mouse370e67aa74c8
diff --git a/web/app/pages/Project/View/Panels.tsx b/web/app/pages/Project/View/Panels.tsx
index f42a7bb6b..5dbd540ad 100644
--- a/web/app/pages/Project/View/Panels.tsx
+++ b/web/app/pages/Project/View/Panels.tsx
@@ -230,11 +230,13 @@ const PanelContainer = ({
{onDetailsClick ? (
<div className='mt-2 flex items-center justify-center'>
<Button
- className='max-w-max border border-transparent bg-transparent px-3 py-2 text-sm font-medium text-gray-700 hover:border-gray-200 hover:bg-gray-50 dark:text-gray-200 hover:dark:border-slate-700/80 hover:dark:bg-slate-950'
+ variant='icon'
+ className='gap-1.5 px-3 py-2'
type='button'
onClick={onDetailsClick}
+ aria-label={t('common.details')}
>
- <ScanIcon className='mr-1.5 size-4' />
+ <ScanIcon className='size-4' />
<span>{t('common.details')}</span>
</Button>
</div>
@@ -1640,11 +1642,13 @@ const CombinedMetadataPanel = ({
{canShowDetails ? (
<div className='mt-2 flex items-center justify-center'>
<Button
- className='max-w-max border border-transparent bg-transparent px-3 py-2 text-sm font-medium text-gray-700 hover:border-gray-200 hover:bg-gray-50 dark:text-gray-200 hover:dark:border-slate-700/80 hover:dark:bg-slate-950'
+ variant='icon'
+ className='gap-1.5 px-3 py-2'
type='button'
onClick={() => setDetailsTrigger((n) => n + 1)}
+ aria-label={t('common.details')}
>
- <ScanIcon className='mr-1.5 size-4' />
+ <ScanIcon className='size-4' />
<span>{t('common.details')}</span>
</Button>
</div>
@@ -1859,6 +1863,11 @@ const DetailsTable = ({
})
}, [data])
+ const numericColsCount =
+ 1 + (detailsExtraColumns?.length || 0) + (!hidePercentageInDetails ? 1 : 0)
+ const numericColWidth = `${(60 / numericColsCount).toFixed(3)}%`
+ const gridTemplateColumns = `40% repeat(${numericColsCount}, minmax(0, ${numericColWidth}))`
+
return (
<div>
<div className='mb-2'>
@@ -1874,101 +1883,79 @@ const DetailsTable = ({
ref={parentRef}
className='scrollbar-thin max-h-[500px] overflow-x-auto overflow-y-auto'
>
- <table className='w-full min-w-[640px] border-separate border-spacing-y-1'>
- <thead className='sticky top-0 z-10 bg-white dark:bg-slate-950'>
- <tr className='text-sm text-gray-900 sm:text-base dark:text-gray-50'>
- <th
- className='flex cursor-pointer items-center pl-2 text-left hover:opacity-90'
- style={{ width: '40%' }}
- onClick={() => onSortBy('name')}
- >
+ <div className='min-w-[640px]'>
+ <div
+ className='sticky top-0 z-10 grid bg-white text-sm font-semibold text-gray-900 sm:text-base dark:bg-slate-950 dark:text-gray-50'
+ style={{ gridTemplateColumns }}
+ role='row'
+ >
+ <button
+ type='button'
+ className='flex cursor-pointer items-center py-1 pl-2 text-left hover:opacity-90'
+ onClick={() => onSortBy('name')}
+ role='columnheader'
+ >
+ <span className='truncate'>
{tnMapping[activeTabId as keyof typeof tnMapping]}
+ </span>
+ <Sort
+ className='ml-1 shrink-0'
+ sortByAscend={sort.label === 'name' ? sort.sortByAscend : null}
+ sortByDescend={
+ sort.label === 'name' ? sort.sortByDescend : null
+ }
+ />
+ </button>
+ <button
+ type='button'
+ className='flex cursor-pointer items-center justify-end py-1 pr-2 text-right hover:opacity-90'
+ onClick={() => onSortBy('quantity')}
+ role='columnheader'
+ >
+ <span className='truncate'>
+ {valuesHeaderName || t('project.visitors')}
+ </span>
+ <Sort
+ className='ml-1 shrink-0'
+ sortByAscend={
+ sort.label === 'quantity' ? sort.sortByAscend : null
+ }
+ sortByDescend={
+ sort.label === 'quantity' ? sort.sortByDescend : null
+ }
+ />
+ </button>
+ {detailsExtraColumns?.map((col, idx) => (
+ <button
+ key={`extra-col-${idx}`}
+ type='button'
+ className='flex cursor-pointer items-center justify-end py-1 pr-2 text-right hover:opacity-90'
+ onClick={() => onSortBy(col.sortLabel)}
+ role='columnheader'
+ >
+ <span className='truncate'>{col.header}</span>
<Sort
- className='ml-1'
+ className='ml-1 shrink-0'
sortByAscend={
- sort.label === 'name' ? sort.sortByAscend : null
+ sort.label === col.sortLabel ? sort.sortByAscend : null
}
sortByDescend={
- sort.label === 'name' ? sort.sortByDescend : null
+ sort.label === col.sortLabel ? sort.sortByDescend : null
}
/>
- </th>
- {(() => {
- const numericColsCount =
- 1 +
- (detailsExtraColumns?.length || 0) +
- (!hidePercentageInDetails ? 1 : 0)
- const numericColWidth = `${(60 / numericColsCount).toFixed(3)}%`
- return (
- <th style={{ width: numericColWidth }}>
- <p
- className='flex cursor-pointer items-center justify-end hover:opacity-90'
- onClick={() => onSortBy('quantity')}
- >
- {valuesHeaderName || t('project.visitors')}
- <Sort
- className='ml-1'
- sortByAscend={
- sort.label === 'quantity' ? sort.sortByAscend : null
- }
- sortByDescend={
- sort.label === 'quantity' ? sort.sortByDescend : null
- }
- />
- &nbsp;&nbsp;
- </p>
- </th>
- )
- })()}
- {(() => {
- const numericColsCount =
- 1 +
- (detailsExtraColumns?.length || 0) +
- (!hidePercentageInDetails ? 1 : 0)
- const numericColWidth = `${(60 / numericColsCount).toFixed(3)}%`
- return (
- <>
- {detailsExtraColumns?.map((col, idx) => (
- <th
- key={`extra-col-${idx}`}
- style={{ width: numericColWidth }}
- className='pr-2'
- >
- <p
- className='flex cursor-pointer items-center justify-end hover:opacity-90'
- onClick={() => onSortBy(col.sortLabel)}
- >
- {col.header}
- <Sort
- className='ml-1'
- sortByAscend={
- sort.label === col.sortLabel
- ? sort.sortByAscend
- : null
- }
- sortByDescend={
- sort.label === col.sortLabel
- ? sort.sortByDescend
- : null
- }
- />
- </p>
- </th>
- ))}
- {!hidePercentageInDetails ? (
- <th style={{ width: numericColWidth }} className='pr-2'>
- <p className='flex items-center justify-end'>
- {t('project.percentage')}
- </p>
- </th>
- ) : null}
- </>
- )
- })()}
- </tr>
- </thead>
+ </button>
+ ))}
+ {!hidePercentageInDetails ? (
+ <div
+ className='flex items-center justify-end py-1 pr-2 text-right'
+ role='columnheader'
+ >
+ <span className='truncate'>{t('project.percentage')}</span>
+ </div>
+ ) : null}
+ </div>
- <tbody
+ <div
style={{
position: 'relative',
height: `${rowVirtualizer.getTotalSize()}px`,
@@ -1986,7 +1973,7 @@ const DetailsTable = ({
const isOddRow = virtualRow.index % 2 === 1
return (
- <tr
+ <div
key={`${id}-${entryName}-${Object.values(rest).join('-')}`}
style={{
position: 'absolute',
@@ -1994,16 +1981,16 @@ const DetailsTable = ({
transform: `translateY(${virtualRow.start}px)`,
width: '100%',
height: `${virtualRow.size}px`,
- display: 'flex',
- alignItems: 'center',
+ gridTemplateColumns,
}}
className={cx(
- 'group cursor-pointer text-sm text-gray-900 hover:bg-gray-100 sm:text-base dark:text-gray-50 hover:dark:bg-slate-800',
+ 'group grid cursor-pointer items-center text-sm text-gray-900 hover:bg-gray-100 sm:text-base dark:text-gray-50 hover:dark:bg-slate-800',
{
'bg-gray-50 dark:bg-slate-900': isOddRow,
'cursor-default': disableRowClick,
},
)}
+ role='row'
onClick={() => {
if (disableRowClick) return
const link = getFilterLink(id, entryName)
@@ -2013,13 +2000,10 @@ const DetailsTable = ({
}
}}
>
- <td
- className='flex items-center py-1 pl-2 text-left'
- style={{ width: '40%' }}
- >
+ <div className='flex min-w-0 items-center py-1 pl-2 text-left'>
<span
className={cx(
- 'scrollbar-thin hover-always-overflow flex items-center whitespace-nowrap',
+ 'scrollbar-thin hover-always-overflow flex min-w-0 items-center whitespace-nowrap',
{
capitalize,
},
@@ -2045,58 +2029,28 @@ const DetailsTable = ({
<div className='ml-2 h-4 w-4 group-hover:hidden' />
</>
) : null}
- </td>
- {(() => {
- const numericColsCount =
- 1 +
- (detailsExtraColumns?.length || 0) +
- (!hidePercentageInDetails ? 1 : 0)
- const numericColWidth = `${(60 / numericColsCount).toFixed(3)}%`
- return (
- <td
- style={{ width: numericColWidth }}
- className='py-1 text-right'
- >
- {activeTab === PROJECT_TABS.traffic
- ? nFormatter(valueData, 1)
- : valueData}
- &nbsp;&nbsp;
- </td>
- )
- })()}
- {(() => {
- const numericColsCount =
- 1 +
- (detailsExtraColumns?.length || 0) +
- (!hidePercentageInDetails ? 1 : 0)
- const numericColWidth = `${(60 / numericColsCount).toFixed(3)}%`
- return (
- <>
- {detailsExtraColumns?.map((col, idx) => (
- <td
- key={`extra-cell-${idx}`}
- style={{ width: numericColWidth }}
- className='py-1 pr-2 text-right'
- >
- {col.render(entry)}
- </td>
- ))}
- {!hidePercentageInDetails ? (
- <td
- style={{ width: numericColWidth }}
- className='py-1 pr-2 text-right'
- >
- {perc}%
- </td>
- ) : null}
- </>
- )
- })()}
- </tr>
+ </div>
+ <div className='py-1 pr-2 text-right'>
+ {activeTab === PROJECT_TABS.traffic
+ ? nFormatter(valueData, 1)
+ : valueData}
+ </div>
+ {detailsExtraColumns?.map((col, idx) => (
+ <div
+ key={`extra-cell-${idx}`}
+ className='py-1 pr-2 text-right'
+ >
+ {col.render(entry)}
+ </div>
+ ))}
+ {!hidePercentageInDetails ? (
+ <div className='py-1 pr-2 text-right'>{perc}%</div>
+ ) : null}
+ </div>
)
})}
- </tbody>
- </table>
+ </div>
+ </div>
</div>
</div>
)
diff --git a/web/app/pages/Project/View/components/LiveVisitorsDropdown.tsx b/web/app/pages/Project/View/components/LiveVisitorsDropdown.tsx
index d9f917f40..705dc8241 100644
--- a/web/app/pages/Project/View/components/LiveVisitorsDropdown.tsx
+++ b/web/app/pages/Project/View/components/LiveVisitorsDropdown.tsx
@@ -84,8 +84,8 @@ const LiveVisitorsDropdown = () => {
<div
id='live-visitors-dropdown'
className={cn(
- 'scrollbar-thin absolute top-5 right-0 z-40 mt-2 origin-top-right transform cursor-auto overflow-hidden rounded-md border border-black/10 bg-white text-gray-900 shadow-md transition duration-150 ease-out outline-none dark:border-slate-700/50 dark:bg-slate-950',
- liveInfo.length === 0 || isLoading ? 'min-w-[200px]' : 'min-w-max',
+ 'scrollbar-thin absolute top-full right-0 z-40 mt-2 w-max max-w-[calc(100vw-1rem)] origin-top-right transform cursor-auto overflow-hidden rounded-md border border-black/10 bg-white text-sm text-gray-900 shadow-md transition duration-150 ease-out outline-none max-sm:fixed max-sm:top-20 max-sm:right-2 max-sm:left-2 max-sm:w-auto max-sm:max-w-none dark:border-slate-700/50 dark:bg-slate-950 dark:text-gray-50',
+ liveInfo.length === 0 || isLoading ? 'min-w-[200px]' : 'min-w-0',
isDropdownVisible
? 'pointer-events-auto translate-y-0 scale-100 opacity-100'
: 'pointer-events-none -translate-y-1 scale-95 opacity-0',
@@ -106,7 +106,7 @@ const LiveVisitorsDropdown = () => {
<XIcon className='h-5 w-5 cursor-pointer rounded-md text-gray-900 dark:text-gray-50' />
</button>
</div>
- <div className='scrollbar-thin max-h-[200px] overflow-y-auto px-2'>
+ <div className='scrollbar-thin max-h-[min(320px,calc(100dvh-7rem))] overflow-y-auto px-2'>
{isLoading ? (
<Text as='p' size='sm' className='flex items-center py-2'>
<Spin className='ml-0' />
@@ -118,43 +118,35 @@ const LiveVisitorsDropdown = () => {
{t('project.noData')}
</Text>
) : (
- <div className='table w-full border-separate border-spacing-y-2'>
- <div className='table-row-group'>
- {_map(liveInfo, ({ psid, dv, br, os, cc }) => {
- const params = new URLSearchParams(location.search)
- params.set('psid', psid)
- params.set('tab', PROJECT_TABS.sessions)
+ <div className='flex w-full min-w-0 flex-col gap-2 py-2'>
+ {_map(liveInfo, ({ psid, dv, br, os, cc }) => {
+ const params = new URLSearchParams(location.search)
+ params.set('psid', psid)
+ params.set('tab', PROJECT_TABS.sessions)
- return (
- <Link
- key={psid}
- className='group table-row cursor-pointer text-sm text-gray-900 dark:text-gray-50'
- to={{ search: params.toString() }}
- >
- <div className='table-cell rounded-l-lg bg-gray-100 pr-2 align-middle transition-colors group-hover:bg-gray-200 dark:bg-slate-900 dark:group-hover:bg-slate-700'>
- <Flag
- className='m-2 rounded-xs'
- country={cc}
- size={21}
- alt=''
- aria-hidden='true'
- />
- </div>
- <div className='table-cell bg-gray-100 pr-2 align-middle transition-colors group-hover:bg-gray-200 dark:bg-slate-900 dark:group-hover:bg-slate-700'>
- {os}
- </div>
- <div className='table-cell bg-gray-100 pr-2 align-middle transition-colors group-hover:bg-gray-200 dark:bg-slate-900 dark:group-hover:bg-slate-700'>
- {br}
- </div>
- <div className='table-cell rounded-r-lg bg-gray-100 pr-2 align-middle transition-colors group-hover:bg-gray-200 dark:bg-slate-900 dark:group-hover:bg-slate-700'>
- <Text as='p' className='capitalize'>
- {dv}
- </Text>
- </div>
- </Link>
- )
- })}
- </div>
+ return (
+ <Link
+ key={psid}
+ className='group grid min-w-0 cursor-pointer grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_minmax(0,1fr)] items-center overflow-hidden rounded-lg bg-gray-100 text-sm text-gray-900 transition-colors hover:bg-gray-200 dark:bg-slate-900 dark:text-gray-50 dark:hover:bg-slate-700'
+ to={{ search: params.toString() }}
+ >
+ <div className='pr-2'>
+ <Flag
+ className='m-2 rounded-xs'
+ country={cc}
+ size={21}
+ alt=''
+ aria-hidden='true'
+ />
+ </div>
+ <div className='min-w-0 truncate pr-2'>{os}</div>
+ <div className='min-w-0 truncate pr-2'>{br}</div>
+ <div className='min-w-0 truncate pr-2 capitalize'>
+ {dv}
+ </div>
+ </Link>
+ )
+ })}
</div>
)}
</div>
diff --git a/web/app/pages/Project/tabs/Funnels/FunnelsList.tsx b/web/app/pages/Project/tabs/Funnels/FunnelsList.tsx
index 4f4319ed7..2863e718c 100644
--- a/web/app/pages/Project/tabs/Funnels/FunnelsList.tsx
+++ b/web/app/pages/Project/tabs/Funnels/FunnelsList.tsx
@@ -8,13 +8,14 @@ import {
CursorClickIcon,
ArrowRightIcon,
} from '@phosphor-icons/react'
-import { useMemo, useRef } from 'react'
+import { type MouseEvent, useMemo, useRef } from 'react'
import { useTranslation } from 'react-i18next'
import { Link } from '~/ui/Link'
import { useSearchParams } from 'react-router'
import { Funnel } from '~/lib/models/Project'
import { useAuth } from '~/providers/AuthProvider'
+import Button from '~/ui/Button'
import { Text } from '~/ui/Text'
interface FunnelsListProps {
@@ -113,36 +114,38 @@ const FunnelCard = ({
{funnel.name}
</Text>
<div className='flex shrink-0 items-center gap-1'>
- <button
+ <Button
+ variant='icon'
type='button'
- onClick={(e) => {
+ onClick={(e: MouseEvent<HTMLButtonElement>) => {
e.preventDefault()
e.stopPropagation()
openFunnelSettings(funnel)
}}
aria-label={t('common.settings')}
- className='rounded-md border border-transparent p-1.5 text-gray-800 transition-colors hover:border-gray-300 hover:bg-gray-50 hover:text-gray-900 dark:text-slate-400 hover:dark:border-slate-700/80 dark:hover:bg-slate-900 dark:hover:text-slate-300'
+ className='p-1.5 text-gray-800 dark:text-slate-400 dark:hover:text-slate-300'
>
<SlidersHorizontalIcon className='size-5' />
- </button>
+ </Button>
{allowedToManage ? (
- <button
+ <Button
+ variant='icon'
type='button'
- onClick={(e) => {
+ onClick={(e: MouseEvent<HTMLButtonElement>) => {
e.preventDefault()
e.stopPropagation()
deleteFunnel(funnel.id)
}}
aria-label={t('common.delete')}
className={cx(
- 'rounded-md border border-transparent p-1.5 text-gray-800 transition-colors hover:border-gray-300 hover:bg-gray-50 hover:text-gray-900 dark:text-slate-400 hover:dark:border-slate-700/80 dark:hover:bg-slate-900 dark:hover:text-slate-300',
+ 'p-1.5 text-gray-800 dark:text-slate-400 dark:hover:text-slate-300',
{
'cursor-not-allowed': loading,
},
)}
>
<TrashIcon className='size-5' />
- </button>
+ </Button>
) : null}
</div>
</div>
diff --git a/web/app/pages/Project/tabs/Goals/GoalSettingsModal.tsx b/web/app/pages/Project/tabs/Goals/GoalSettingsModal.tsx
index 37112fe94..8189d8768 100644
--- a/web/app/pages/Project/tabs/Goals/GoalSettingsModal.tsx
+++ b/web/app/pages/Project/tabs/Goals/GoalSettingsModal.tsx
@@ -323,13 +323,15 @@ const GoalSettingsModal = ({
placeholder={t('goals.filterValue')}
className='flex-1'
/>
- <button
+ <Button
+ variant='icon'
type='button'
onClick={() => removeMetadataFilter(index)}
- className='rounded-md border border-transparent p-1.5 text-gray-800 transition-colors hover:border-gray-300 hover:bg-gray-50 hover:text-gray-900 dark:text-slate-400 hover:dark:border-slate-700/80 dark:hover:bg-slate-900 dark:hover:text-slate-300'
+ aria-label={t('common.delete')}
+ className='p-1.5 text-gray-800 dark:text-slate-400 dark:hover:text-slate-300'
>
<TrashIcon className='h-4 w-4' />
- </button>
+ </Button>
</div>
))}
</div>
diff --git a/web/app/pages/Project/tabs/Goals/GoalsView.tsx b/web/app/pages/Project/tabs/Goals/GoalsView.tsx
index d6c213c6b..c7f29c1f9 100644
--- a/web/app/pages/Project/tabs/Goals/GoalsView.tsx
+++ b/web/app/pages/Project/tabs/Goals/GoalsView.tsx
@@ -25,6 +25,7 @@ import {
useCallback,
Suspense,
use,
+ type MouseEvent,
} from 'react'
import { useTranslation } from 'react-i18next'
import { useFetcher, useLoaderData, useRevalidator } from 'react-router'
@@ -415,30 +416,32 @@ const GoalRow = ({
</div>
{/* Action buttons */}
<div className='flex items-center gap-1'>
- <button
+ <Button
+ variant='icon'
type='button'
- onClick={(e) => {
+ onClick={(e: MouseEvent<HTMLButtonElement>) => {
e.preventDefault()
e.stopPropagation()
onEdit(goal.id)
}}
aria-label={t('common.edit')}
- className='rounded-md border border-transparent p-1.5 text-gray-800 transition-colors hover:border-gray-300 hover:bg-gray-50 hover:text-gray-900 dark:text-slate-400 hover:dark:border-slate-700/80 dark:hover:bg-slate-900 dark:hover:text-slate-300'
+ className='p-1.5 text-gray-800 dark:text-slate-400 dark:hover:text-slate-300'
>
<PencilIcon className='size-4' />
- </button>
- <button
+ </Button>
+ <Button
+ variant='icon'
type='button'
- onClick={(e) => {
+ onClick={(e: MouseEvent<HTMLButtonElement>) => {
e.preventDefault()
e.stopPropagation()
setShowDeleteModal(true)
}}
aria-label={t('common.delete')}
- className='rounded-md border border-transparent p-1.5 text-gray-800 transition-colors hover:border-gray-300 hover:bg-gray-50 hover:text-gray-900 dark:text-slate-400 hover:dark:border-slate-700/80 dark:hover:bg-slate-900 dark:hover:text-slate-300'
+ className='p-1.5 text-gray-800 dark:text-slate-400 dark:hover:text-slate-300'
>
<TrashIcon className='size-4' />
- </button>
+ </Button>
<CaretDownIcon
className={cx(
'size-5 text-gray-500 transition-transform dark:text-gray-400',
diff --git a/web/app/ui/Text.tsx b/web/app/ui/Text.tsx
index f92497455..301119d63 100644
--- a/web/app/ui/Text.tsx
+++ b/web/app/ui/Text.tsx
@@ -106,7 +106,7 @@ export const Text = ({
trackingClasses[tracking],
{ truncate },
code &&
- 'rounded-md bg-gray-100 px-1.5 py-0.5 font-mono text-[0.92em] ring-1 ring-gray-200/70 ring-inset dark:bg-slate-900 dark:ring-slate-700/60',
+ 'rounded-md bg-gray-100 px-1.5 py-0.5 font-mono ring-1 ring-gray-200/70 ring-inset dark:bg-slate-900 dark:ring-slate-700/60',
className,
)}
{...props}