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!

Restyle dropdowns

Blue Mouse3108c2b85b36
diff --git a/web/app/components/Header/index.tsx b/web/app/components/Header/index.tsx
index 627ea9023..42f5a980e 100644
--- a/web/app/components/Header/index.tsx
+++ b/web/app/components/Header/index.tsx
@@ -685,7 +685,6 @@ const NotAuthedHeader = ({
<Dropdown
items={whitelist}
buttonClassName='!py-0 inline-flex items-center [&>svg]:w-4 [&>svg]:h-4 [&>svg]:mr-0 [&>svg]:ml-1 font-semibold leading-6 !text-base text-slate-800 hover:text-slate-700 dark:text-slate-200 dark:hover:text-white'
- selectItemClassName='text-gray-700 block px-4 py-2 text-base cursor-pointer hover:bg-gray-200 dark:text-gray-50 dark:bg-slate-800 dark:hover:bg-slate-700'
title={
<>
<Flag
diff --git a/web/app/pages/Project/View/ViewProject.tsx b/web/app/pages/Project/View/ViewProject.tsx
index 378a60961..dac5a6a64 100644
--- a/web/app/pages/Project/View/ViewProject.tsx
+++ b/web/app/pages/Project/View/ViewProject.tsx
@@ -2661,13 +2661,6 @@ const ViewProject = () => {
header={t('project.segments')}
onClick={() => loadProjectViews()}
loading={projectViewsLoading || projectViewsLoading === null}
- selectItemClassName={
- !allowedToManage &&
- !(projectViewsLoading || projectViewsLoading === null) &&
- _isEmpty(projectViews)
- ? 'block px-4 py-2 text-sm text-gray-700 dark:border-gray-800 dark:bg-slate-800 dark:text-gray-50'
- : undefined
- }
items={_filter(
[
...projectViews,
@@ -2697,38 +2690,45 @@ const ViewProject = () => {
}
return (
- <span
+ <div
className={cx('flex items-center justify-between space-x-4', {
'cursor-wait': dataLoading,
})}
>
<span>{item.name}</span>
{allowedToManage ? (
- <span className='flex cursor-pointer space-x-2'>
- <PencilIcon
- className='size-4 hover:text-gray-900 dark:hover:text-gray-50'
+ <div className='flex cursor-pointer space-x-1'>
+ <button
onClick={(e) => {
e.stopPropagation()
setProjectViewToUpdate(item)
close()
setIsAddAViewOpened(true)
}}
- strokeWidth={1.5}
- />
- <Trash2Icon
- className={cx('size-4 hover:text-gray-900 dark:hover:text-gray-50', {
- 'cursor-not-allowed': projectViewDeleting,
- })}
+ aria-label={t('common.settings')}
+ className='rounded-md p-1 hover:bg-gray-50 hover:text-gray-900 dark:hover:bg-slate-800 dark:hover:text-slate-200'
+ >
+ <PencilIcon className='size-3' />
+ </button>
+ <button
onClick={(e) => {
e.stopPropagation()
close()
onProjectViewDelete(item.id)
}}
- strokeWidth={1.5}
- />
- </span>
+ aria-label={t('common.settings')}
+ className={cx(
+ 'rounded-md p-1 hover:bg-gray-50 hover:text-gray-900 dark:hover:bg-slate-800 dark:hover:text-slate-200',
+ {
+ 'cursor-not-allowed': projectViewDeleting,
+ },
+ )}
+ >
+ <Trash2Icon className='size-3' />
+ </button>
+ </div>
) : null}
- </span>
+ </div>
)
}}
keyExtractor={(item) => item.id}
@@ -2909,7 +2909,7 @@ const ViewProject = () => {
)
}}
buttonClassName='!px-2.5'
- selectItemClassName='group text-gray-700 dark:text-gray-50 dark:border-gray-800 dark:bg-slate-800 block text-sm cursor-pointer hover:bg-gray-200 dark:hover:bg-slate-700'
+ selectItemClassName='p-0'
keyExtractor={(pair) => pair.id}
onSelect={({ id: pairID, conflicts }) => {
switchTrafficChartMetric(pairID, conflicts)
@@ -2971,7 +2971,7 @@ const ViewProject = () => {
)
}}
buttonClassName='!px-2.5'
- selectItemClassName='group text-gray-700 dark:text-gray-50 dark:border-gray-800 dark:bg-slate-800 block text-sm cursor-pointer hover:bg-gray-200 dark:hover:bg-slate-700'
+ selectItemClassName='p-0'
keyExtractor={(pair) => pair.id}
onSelect={({ id: pairID }) => {
switchActiveErrorFilter(pairID)
diff --git a/web/app/ui/Dropdown.tsx b/web/app/ui/Dropdown.tsx
index 45c8a04e7..c1782ad37 100644
--- a/web/app/ui/Dropdown.tsx
+++ b/web/app/ui/Dropdown.tsx
@@ -6,6 +6,8 @@ import _isEmpty from 'lodash/isEmpty'
import _map from 'lodash/map'
import React, { memo, Fragment, Key } from 'react'
+import { cn } from '~/utils/generic'
+
import Spin from './icons/Spin'
interface DropdownProps<T> {
@@ -99,15 +101,12 @@ function Dropdown<T>({
<MenuItems
static
className={cx(
- 'absolute right-0 z-50 mt-2 w-40 min-w-max origin-top-right rounded-md bg-white ring-1 ring-black/10 focus:outline-hidden dark:bg-slate-800',
+ 'absolute right-0 z-50 mt-2 w-40 min-w-max origin-top-right rounded-md bg-gray-50 p-1 ring-1 ring-black/10 focus:outline-hidden dark:bg-slate-800',
menuItemsClassName,
- {
- 'divide-y divide-gray-100 dark:divide-gray-600': header,
- },
)}
>
{header ? (
- <p className='px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-50'>{header}</p>
+ <p className='mb-1 px-3 py-2 text-sm font-medium text-gray-700 dark:text-gray-50'>{header}</p>
) : null}
{loading ? (
<div className='px-4 py-2'>
@@ -115,16 +114,12 @@ function Dropdown<T>({
<span className='sr-only'>Loading...</span>
</div>
) : (
- _map(items, (item, index) => (
+ _map(items, (item) => (
<MenuItem key={keyExtractor ? keyExtractor(item, close) : (item as Key)}>
<span
- className={cx(
- selectItemClassName ||
- 'block cursor-pointer px-4 py-2 text-sm text-gray-700 hover:bg-gray-200 dark:border-gray-800 dark:bg-slate-800 dark:text-gray-50 dark:hover:bg-slate-700',
- {
- 'rounded-t-md': index === 0 && !header,
- 'rounded-b-md': index === items.length - 1,
- },
+ className={cn(
+ 'block cursor-pointer rounded-md p-2 text-sm text-gray-700 hover:bg-gray-200 dark:text-gray-50 dark:hover:bg-slate-700',
+ selectItemClassName,
)}
role='menuitem'
tabIndex={0}
diff --git a/web/app/utils/generic.ts b/web/app/utils/generic.ts
index 135386592..9dc218205 100644
--- a/web/app/utils/generic.ts
+++ b/web/app/utils/generic.ts
@@ -1,8 +1,10 @@
+import clsx, { type ClassValue } from 'clsx'
import _find from 'lodash/find'
import _map from 'lodash/map'
import _reduce from 'lodash/reduce'
import _replace from 'lodash/replace'
import _round from 'lodash/round'
+import { twMerge } from 'tailwind-merge'
import { isBrowser } from '~/lib/constants'
@@ -142,3 +144,7 @@ export const getLocaleDisplayName = (locale: string, language: string): string =
}
export const delay = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms))
+
+export const cn = (...args: ClassValue[]) => {
+ return twMerge(clsx(args))
+}
diff --git a/web/package-lock.json b/web/package-lock.json
index 298a45d51..7030b9f78 100644
--- a/web/package-lock.json
+++ b/web/package-lock.json
@@ -54,6 +54,7 @@
"sonner": "^2.0.3",
"spacetime": "^7.9.0",
"swetrix": "^3.6.1",
+ "tailwind-merge": "^3.3.0",
"timezone-soft": "^1.5.2"
},
"devDependencies": {
@@ -9889,6 +9890,16 @@
"resolved": "https://registry.npmjs.org/tabbable/-/tabbable-6.2.0.tgz",
"integrity": "sha512-Cat63mxsVJlzYvN51JmVXIgNoUokrIaT2zLclCXjRd8boZ0004U4KCs/sToJ75C6sdlByWxpYnb5Boif1VSFew=="
},
+ "node_modules/tailwind-merge": {
+ "version": "3.3.0",
+ "resolved": "https://registry.npmjs.org/tailwind-merge/-/tailwind-merge-3.3.0.tgz",
+ "integrity": "sha512-fyW/pEfcQSiigd5SNn0nApUOxx0zB/dm6UDU/rEwc2c3sX2smWUNbapHv+QRqLGVp9GWX3THIa7MUGPo+YkDzQ==",
+ "license": "MIT",
+ "funding": {
+ "type": "github",
+ "url": "https://github.com/sponsors/dcastil"
+ }
+ },
"node_modules/tailwindcss": {
"version": "4.1.4",
"resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.1.4.tgz",
diff --git a/web/package.json b/web/package.json
index e67c0721a..75791fda0 100644
--- a/web/package.json
+++ b/web/package.json
@@ -68,6 +68,7 @@
"sonner": "^2.0.3",
"spacetime": "^7.9.0",
"swetrix": "^3.6.1",
+ "tailwind-merge": "^3.3.0",
"timezone-soft": "^1.5.2"
},
"browserslist": {