Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

chore: update a11y and styles of notifications v2 (#21124)

Jonathan Summers-Muir59d64b9375b0
diff --git a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationRow.tsx b/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationRow.tsx
index 9ce93a9f040..c525b3c1011 100644
--- a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationRow.tsx
+++ b/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationRow.tsx
@@ -67,8 +67,8 @@ const NotificationRow: ItemRenderer<Notification, NotificationRowProps> = ({
ref={ref}
className={clsx(
`p-4 flex justify-between gap-x-3 group`,
- index !== 0 ? 'border-t' : '',
- status !== 'new' ? 'bg-background' : ''
+ index !== 0 ? 'border-t border-overlay' : '',
+ status === 'new' ? 'bg-surface-100/50' : 'bg-background'
)}
>
<div ref={viewRef} className="flex flex-col gap-y-2.5 w-full py-0.5">
@@ -135,8 +135,9 @@ const NotificationRow: ItemRenderer<Notification, NotificationRowProps> = ({
return (
<Button
key={key}
- type="outline"
+ type="default"
icon={<IconExternalLink strokeWidth={1.5} size={14} />}
+ asChild
>
<Link href={url} target="_blank" rel="noreferrer">
{action.label}
@@ -147,7 +148,7 @@ const NotificationRow: ItemRenderer<Notification, NotificationRowProps> = ({
return (
<Button
key={key}
- type="outline"
+ type="default"
onClick={() => onButtonAction(action.action_type)}
>
{action.label}
diff --git a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationsFilter.tsx b/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationsFilter.tsx
index 38c160871b9..b620c9b5485 100644
--- a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationsFilter.tsx
+++ b/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationsFilter.tsx
@@ -1,19 +1,27 @@
-import { Settings2Icon } from 'lucide-react'
+import { RotateCcw, Settings2Icon } from 'lucide-react'
import { useState } from 'react'
import {
Button,
Checkbox_Shadcn_,
+ CommandGroup_Shadcn_,
+ CommandInput_Shadcn_,
+ CommandItem_Shadcn_,
+ CommandSeparator_Shadcn_,
+ Command_Shadcn_,
+ DropdownMenuLabel,
+ Label_Shadcn_,
PopoverContent_Shadcn_,
PopoverTrigger_Shadcn_,
Popover_Shadcn_,
ScrollArea,
- Separator,
+ cn,
} from 'ui'
+import { CommandGroup } from '@ui/components/shadcn/ui/command'
+import { CriticalIcon, WarningIcon } from 'components/ui/Icons'
import { useOrganizationsQuery } from 'data/organizations/organizations-query'
import { useProjectsQuery } from 'data/projects/projects-query'
import { useNotificationsStateSnapshot } from 'state/notifications'
-import { CriticalIcon, WarningIcon } from 'components/ui/Icons'
export const NotificationsFilter = ({ activeTab }: { activeTab: 'inbox' | 'archived' }) => {
const [open, setOpen] = useState(false)
@@ -23,89 +31,158 @@ export const NotificationsFilter = ({ activeTab }: { activeTab: 'inbox' | 'archi
const { data: projects } = useProjectsQuery()
return (
- <Popover_Shadcn_ modal={false} open={open} onOpenChange={setOpen}>
+ <Popover_Shadcn_ modal={true} open={open} onOpenChange={setOpen}>
<PopoverTrigger_Shadcn_ asChild>
<Button
type={snap.numFiltersApplied > 0 ? 'default' : 'text'}
- icon={<Settings2Icon size={14} />}
- className="px-1"
+ icon={<Settings2Icon size={14} strokeWidth={1} />}
+ className="px-1 h-[26px]"
>
{snap.numFiltersApplied > 0 &&
`${snap.numFiltersApplied} filter${snap.numFiltersApplied > 1 ? 's' : ''} applied`}
</Button>
</PopoverTrigger_Shadcn_>
<PopoverContent_Shadcn_ className="p-0 w-64" side="bottom" align="end">
- <div className="p-2">
- <p className="text-xs text-foreground-light">Filter notifications</p>
- </div>
- <Separator />
-
- <ScrollArea className="h-[240px]">
- <div className="p-2 flex flex-col gap-y-2">
- <p className="text-xs">Status</p>
- <div className="flex items-center gap-x-2">
- <Checkbox_Shadcn_
+ <Command_Shadcn_>
+ <CommandInput_Shadcn_ placeholder="Find filter..." />
+ <ScrollArea className="max-h-[240px] py-1 overflow-y-auto">
+ <CommandGroup_Shadcn_>
+ <DropdownMenuLabel>Status</DropdownMenuLabel>
+ <CommandItem_Shadcn_
disabled={activeTab === 'archived'}
- checked={snap.filterStatuses.includes('unread')}
- onCheckedChange={() => snap.setFilters('unread', 'status')}
- />
- <p className={`text-xs ${activeTab === 'archived' ? 'opacity-50' : ''}`}>Unread</p>
- </div>
- </div>
- <Separator />
- <div className="p-2 flex flex-col gap-y-2">
- <p className="text-xs">Priority</p>
- <div className="flex items-center gap-x-2">
- <Checkbox_Shadcn_
- checked={snap.filterPriorities.includes('Warning')}
- onCheckedChange={() => snap.setFilters('Warning', 'priority')}
- />
- <WarningIcon className="w-2 h-2" />
- <p className="text-xs">Warning</p>
- </div>
- <div className="flex items-center gap-x-2">
- <Checkbox_Shadcn_
- checked={snap.filterPriorities.includes('Critical')}
- onCheckedChange={() => snap.setFilters('Critical', 'priority')}
- />
- <CriticalIcon className="w-2 h-2" />
- <p className="text-xs">Critical</p>
- </div>
- </div>
- <Separator />
- <div className="p-2 flex flex-col gap-y-2">
- <p className="text-xs">Organizations</p>
- {(organizations ?? []).map((org) => (
- <div key={org.slug} className="flex items-center gap-x-2">
- <Checkbox_Shadcn_
- checked={snap.filterOrganizations.includes(org.slug)}
- onCheckedChange={() => snap.setFilters(org.slug, 'organizations')}
- />
- <p className="text-xs">{org.name}</p>
- </div>
- ))}
- </div>
- <Separator />
- <div className="p-2 flex flex-col gap-y-2">
- <p className="text-xs">Projects</p>
- {(projects ?? []).map((project) => (
- <div key={project.ref} className="flex items-center gap-x-2">
- <Checkbox_Shadcn_
- checked={snap.filterProjects.includes(project.ref)}
- onCheckedChange={() => snap.setFilters(project.ref, 'projects')}
- />
- <p className="text-xs">{project.name}</p>
- </div>
- ))}
- </div>
- </ScrollArea>
-
- <Separator />
- <div className="p-2 flex justify-end">
- <Button type="default" onClick={() => snap.resetFilters()}>
- Reset filters
- </Button>
- </div>
+ onSelect={() => {
+ snap.setFilters('unread', 'status')
+ }}
+ >
+ <Label_Shadcn_
+ htmlFor={'unread'}
+ className={cn(
+ 'flex items-center gap-x-2 text-xs text-foreground-light transition-colors',
+ snap.filterStatuses.includes('unread') && 'text-foreground'
+ )}
+ >
+ <Checkbox_Shadcn_
+ name="unread"
+ checked={snap.filterStatuses.includes('unread')}
+ ></Checkbox_Shadcn_>
+ Unread
+ </Label_Shadcn_>
+ </CommandItem_Shadcn_>
+ </CommandGroup_Shadcn_>
+ <CommandSeparator_Shadcn_ />
+ <CommandGroup_Shadcn_>
+ <DropdownMenuLabel>Priority</DropdownMenuLabel>
+ <CommandItem_Shadcn_
+ onSelect={() => {
+ snap.setFilters('Warning', 'priority')
+ }}
+ className="flex items-center gap-x-2"
+ >
+ <Label_Shadcn_
+ htmlFor={'warning'}
+ className={cn(
+ 'flex items-center gap-x-2 text-xs text-foreground-light transition-colors',
+ snap.filterPriorities.includes('Warning') && 'text-foreground'
+ )}
+ >
+ <Checkbox_Shadcn_
+ name="warning"
+ checked={snap.filterPriorities.includes('Warning')}
+ ></Checkbox_Shadcn_>
+ <WarningIcon className="w-2 h-2" />
+ Warning
+ </Label_Shadcn_>
+ </CommandItem_Shadcn_>
+ <CommandItem_Shadcn_
+ key={'critical'}
+ onSelect={() => {
+ snap.setFilters('Critical', 'priority')
+ }}
+ >
+ <Label_Shadcn_
+ htmlFor={'critical'}
+ className={cn(
+ 'flex items-center gap-x-2 text-xs text-foreground-light transition-colors',
+ snap.filterPriorities.includes('Critical') && 'text-foreground'
+ )}
+ >
+ <Checkbox_Shadcn_
+ name="critical"
+ checked={snap.filterPriorities.includes('Critical')}
+ ></Checkbox_Shadcn_>
+ <CriticalIcon className="w-2 h-2" />
+ Critical
+ </Label_Shadcn_>
+ </CommandItem_Shadcn_>
+ </CommandGroup_Shadcn_>
+ <CommandSeparator_Shadcn_ />
+ <CommandGroup_Shadcn_>
+ <DropdownMenuLabel>Organizations</DropdownMenuLabel>
+ {(organizations ?? []).map((org) => (
+ <CommandItem_Shadcn_
+ key={org.slug}
+ className="flex items-center gap-x-2"
+ onSelect={() => {
+ snap.setFilters(org.slug, 'organizations')
+ }}
+ >
+ <Label_Shadcn_
+ htmlFor={`${org.slug}`}
+ className={cn(
+ 'flex items-center gap-x-2 text-xs text-foreground-light transition-colors',
+ snap.filterOrganizations.includes(org.slug) && 'text-foreground'
+ )}
+ >
+ <Checkbox_Shadcn_
+ name={`${org.slug}`}
+ checked={snap.filterOrganizations.includes(org.slug)}
+ className=""
+ ></Checkbox_Shadcn_>
+ {org.name}
+ </Label_Shadcn_>
+ </CommandItem_Shadcn_>
+ ))}
+ </CommandGroup_Shadcn_>
+ <CommandSeparator_Shadcn_ />
+ <CommandGroup_Shadcn_>
+ <DropdownMenuLabel>Projects</DropdownMenuLabel>
+ {(projects ?? []).map((project) => (
+ <CommandItem_Shadcn_
+ key={project.ref}
+ className="flex items-center gap-x-2"
+ onSelect={(event) => {
+ snap.setFilters(project.ref, 'projects')
+ }}
+ >
+ <Label_Shadcn_
+ htmlFor={`${project.ref}`}
+ className={cn(
+ 'flex items-center gap-x-2 text-xs text-foreground-light transition-colors',
+ snap.filterProjects.includes(project.ref) && 'text-foreground'
+ )}
+ >
+ <Checkbox_Shadcn_
+ name={`${project.ref}`}
+ checked={snap.filterProjects.includes(project.ref)}
+ className=""
+ ></Checkbox_Shadcn_>
+ {project.name}
+ </Label_Shadcn_>
+ </CommandItem_Shadcn_>
+ ))}
+ </CommandGroup_Shadcn_>
+ </ScrollArea>
+ <CommandSeparator_Shadcn_ />
+ <CommandGroup>
+ <CommandItem_Shadcn_
+ onSelect={() => snap.resetFilters()}
+ className="flex gap-x-2 items-center"
+ >
+ <RotateCcw className="text-foreground-muted" size={12} strokeWidth={1} />
+ Reset filters
+ </CommandItem_Shadcn_>
+ </CommandGroup>
+ </Command_Shadcn_>
</PopoverContent_Shadcn_>
</Popover_Shadcn_>
)
diff --git a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationsPopover.tsx b/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationsPopover.tsx
index 69491decca8..a255fb4cc62 100644
--- a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationsPopover.tsx
+++ b/apps/studio/components/layouts/ProjectLayout/LayoutHeader/NotificationsPopoverV2/NotificationsPopover.tsx
@@ -8,7 +8,9 @@ import {
PopoverContent_Shadcn_,
PopoverTrigger_Shadcn_,
Popover_Shadcn_,
- Tabs,
+ TabsList_Shadcn_,
+ TabsTrigger_Shadcn_,
+ Tabs_Shadcn_,
} from 'ui'
import AlertError from 'components/ui/AlertError'
@@ -82,7 +84,8 @@ const NotificationsPopoverV2 = () => {
}
return (
- <>
+ <div>
+ {/* wrapped in a div to stop space-x class impacting popover content */}
<Popover_Shadcn_
modal={false}
open={open}
@@ -95,6 +98,8 @@ const NotificationsPopoverV2 = () => {
<Button
type={hasNewNotifications ? 'outline' : 'text'}
className={clsx(
+ 'h-[26px]',
+ // !hasCritical || !hasWarning || !hasNewNotifications ? 'w-[26px]' : '',
'group',
hasNewNotifications ? 'rounded-full px-1.5' : 'px-1',
hasCritical
@@ -105,9 +110,9 @@ const NotificationsPopoverV2 = () => {
)}
icon={
hasCritical ? (
- <CriticalIcon className="transition-all -mr-3.5 group-hover:-mr-1 z-10" />
+ <CriticalIcon className="!w-3.5 !h-3.5 transition-all -mr-3.5 group-hover:-mr-1 z-10" />
) : hasWarning ? (
- <WarningIcon className="transition-all -mr-3.5 group-hover:-mr-1 z-10" />
+ <WarningIcon className="!w-3.5 !h-3.5 transition-all -mr-3.5 group-hover:-mr-1 z-10" />
) : hasNewNotifications ? (
<div
className={clsx(
@@ -133,24 +138,24 @@ const NotificationsPopoverV2 = () => {
<div className="px-4">
<p className="pt-4 pb-1 text-sm">Notifications</p>
<div className="flex items-center">
- <Tabs
- size="medium"
- type="underlined"
- baseClassNames="!space-y-0"
- listClassNames="[&>button>span]:text-xs"
- activeId={activeTab}
- onChange={(tab: 'inbox' | 'archived') => {
- setActiveTab(tab)
+ <Tabs_Shadcn_
+ className="w-full"
+ onValueChange={(tab: string) => {
+ setActiveTab(tab as 'inbox' | 'archived')
if (tab === 'archived' && snap.filterStatuses.includes('unread')) {
snap.setFilters('unread', 'status')
}
}}
+ value={activeTab}
>
- <Tabs.Panel
- id="inbox"
- label="Inbox"
- iconRight={
- isSuccessSummary ? (
+ <div className="flex items-center">
+ <TabsList_Shadcn_ className="flex gap-5 grow border-none">
+ <TabsTrigger_Shadcn_
+ id="inbox"
+ value="inbox"
+ className="px-0 data-[state=active]:bg-transparent flex gap-2"
+ >
+ Inbox
<div
className={clsx([
'flex items-center justify-center text-xs rounded-full bg-surface-300 h-4',
@@ -159,13 +164,18 @@ const NotificationsPopoverV2 = () => {
>
{summary?.unread_count}
</div>
- ) : null
- }
- />
- <Tabs.Panel id="archived" label="Archived" />
- </Tabs>
-
- <NotificationsFilter activeTab={activeTab} />
+ </TabsTrigger_Shadcn_>
+ <TabsTrigger_Shadcn_
+ id="archived"
+ value="archived"
+ className="px-0 data-[state=active]:bg-transparent"
+ >
+ Archived
+ </TabsTrigger_Shadcn_>
+ </TabsList_Shadcn_>
+ <NotificationsFilter activeTab={activeTab} />
+ </div>
+ </Tabs_Shadcn_>
</div>
</div>
<div className="border-t">
@@ -180,7 +190,7 @@ const NotificationsPopoverV2 = () => {
</div>
)}
{isSuccess && (
- <div className="flex flex-1 h-[400px]">
+ <div className="flex flex-1 h-[400px] bg-background">
{notifications.length > 0 &&
!(activeTab === 'archived' && snap.filterStatuses.includes('unread')) ? (
<InfiniteList
@@ -259,7 +269,7 @@ const NotificationsPopoverV2 = () => {
)}
</PopoverContent_Shadcn_>
</Popover_Shadcn_>
- </>
+ </div>
)
}
diff --git a/packages/ui/src/components/shadcn/ui/checkbox.tsx b/packages/ui/src/components/shadcn/ui/checkbox.tsx
index f7be4968cb3..6ac93373628 100644
--- a/packages/ui/src/components/shadcn/ui/checkbox.tsx
+++ b/packages/ui/src/components/shadcn/ui/checkbox.tsx
@@ -13,13 +13,17 @@ const Checkbox = React.forwardRef<
<CheckboxPrimitive.Root
ref={ref}
className={cn(
- 'peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground',
+ 'peer h-4 w-4 shrink-0 rounded border border-control bg-control/25 ring-offset-background',
+ 'transition-colors duration-150 ease-in-out',
+ 'hover:border-strong',
+ 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2',
+ 'disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-foreground data-[state=checked]:text-background',
className
)}
{...props}
>
<CheckboxPrimitive.Indicator className={cn('flex items-center justify-center text-current')}>
- <Check className="h-4 w-4" />
+ <Check className="h-3 w-3" strokeWidth={4} />
</CheckboxPrimitive.Indicator>
</CheckboxPrimitive.Root>
))