diff --git a/src/screens/Notifications/__tests__/PageList.test.ts b/src/screens/Notifications/__tests__/PageList.test.ts index 54f38c909..24a61e623 100644 --- a/src/screens/Notifications/__tests__/PageList.test.ts +++ b/src/screens/Notifications/__tests__/PageList.test.ts @@ -1,13 +1,10 @@ import {describe, expect, it, jest} from '@jest/globals' import {type NotificationView} from '#/state/queries/notifications/grouped/types' -import {getRowBorderColor} from '#/screens/Notifications/components/NotificationItem/Item/Root' import { buildRows, getPlaceholderRow, - isUnreadBorder, } from '#/screens/Notifications/components/PageList' -import {type Theme} from '#/alf' // The placeholder helper doesn't need the native runtime or analytics setup. jest.mock('#/lib/hooks/useBottomBarOffset', () => ({})) @@ -103,51 +100,4 @@ describe('buildRows', () => { dividers([notification('a', lastYear), notification('b', lastYear)]), ).toEqual([false, true]) }) - - it('counts the borders on both sides of an unread notification', () => { - const rows = buildRows( - [ - notification('a', today, false), - notification('b', today), - notification('c', lastYear, false), - notification('d', lastYear), - ], - 'all', - ) - // The border above each row, then the one below the last - expect([ - ...rows.map((row, i) => isUnreadBorder(rows[i - 1], row)), - isUnreadBorder(rows.at(-1), undefined), - ]).toEqual([ - false, // above "Today" - true, // "Today" | a - true, // a | b - false, // b | "Earlier" - true, // "Earlier" | c - true, // c | d - false, // below d - ]) - }) -}) - -describe('getRowBorderColor', () => { - function theme(name: Theme['name']) { - return { - name, - atoms: { - border_contrast_low: {borderColor: '#low'}, - border_contrast_medium: {borderColor: '#medium'}, - }, - } as unknown as Theme - } - - it('is stronger beside an unread row in the dark theme', () => { - expect(getRowBorderColor(theme('dark'), true)).toBe('#medium') - expect(getRowBorderColor(theme('dark'), false)).toBe('#low') - }) - - it('is the usual divider colour in the other themes', () => { - expect(getRowBorderColor(theme('dim'), true)).toBe('#low') - expect(getRowBorderColor(theme('light'), true)).toBe('#low') - }) }) diff --git a/src/screens/Notifications/components/NotificationItem/Item/Root.tsx b/src/screens/Notifications/components/NotificationItem/Item/Root.tsx index 18d2d9421..29a4a58d8 100644 --- a/src/screens/Notifications/components/NotificationItem/Item/Root.tsx +++ b/src/screens/Notifications/components/NotificationItem/Item/Root.tsx @@ -10,7 +10,7 @@ import { } from 'react-native' import {WebAuxClickWrapper} from '#/view/com/util/WebAuxClickWrapper' -import {atoms as a, select, type Theme, tokens, useTheme} from '#/alf' +import {atoms as a, tokens, useTheme} from '#/alf' import {useLink} from '#/components/Link' import {SubtleHover} from '#/components/SubtleHover' import {SuppressHoverContext, useRowHover} from './hover' @@ -42,29 +42,14 @@ export function useItemContext() { } /** - * The background colour of a row, tinted while unread. The dark themes use - * design's own tints, which aren't in the palette: `primary_25` barely shows - * against their backgrounds. + * The background colour of a row, tinted while unread. Dim uses design's own + * tint, which isn't in its palette: its `primary_25` barely shows against + * its background. */ export function useRowBackgroundColor(isRead: boolean) { const t = useTheme() if (isRead) return t.atoms.bg.backgroundColor - return select(t.name, { - light: t.palette.primary_25, - dim: '#071F40', - dark: '#202F43', - }) -} - -/** - * The colour of a border on or beside a row. The dark theme's unread tint is - * about as light as `border_contrast_low`, which vanishes against it, so - * there a border that touches an unread row is a step stronger. - */ -export function getRowBorderColor(t: Theme, touchesUnread: boolean) { - return touchesUnread && t.name === 'dark' - ? t.atoms.border_contrast_medium.borderColor - : t.atoms.border_contrast_low.borderColor + return t.name === 'dim' ? '#071F40' : t.palette.primary_25 } /** diff --git a/src/screens/Notifications/components/NotificationItem/Item/media.tsx b/src/screens/Notifications/components/NotificationItem/Item/media.tsx index c47917ee6..41ffde972 100644 --- a/src/screens/Notifications/components/NotificationItem/Item/media.tsx +++ b/src/screens/Notifications/components/NotificationItem/Item/media.tsx @@ -14,7 +14,7 @@ import {PlayButtonIcon} from '#/components/video/PlayButtonIcon' import {IS_WEB} from '#/env' import {app} from '#/lexicons' import * as bsky from '#/types/bsky' -import {getRowBorderColor, useItemContext} from './Root' +import {useItemContext} from './Root' type Thumbnail = { /** @@ -198,8 +198,7 @@ function cornerRadius(isOuter: boolean) { /** * Outlined container for compact previews of feeds, starter packs, links and - * quoted posts. Its border is the one the same embeds have in a post, but - * for the dark theme's unread tint, see `getRowBorderColor`. It is + * quoted posts. Its border is the one the same embeds have in a post. It is * transparent on the unread tint, so it doesn't punch a white hole in the row. */ export function Card({ @@ -219,7 +218,7 @@ export function Card({ a.rounded_md, a.curve_continuous, a.border, - {borderColor: getRowBorderColor(t, !isRead)}, + t.atoms.border_contrast_low, isRead && t.atoms.bg, style, ]}> diff --git a/src/screens/Notifications/components/NotificationItem/index.tsx b/src/screens/Notifications/components/NotificationItem/index.tsx index cc682b4fa..b8a14878a 100644 --- a/src/screens/Notifications/components/NotificationItem/index.tsx +++ b/src/screens/Notifications/components/NotificationItem/index.tsx @@ -1,4 +1,8 @@ +import {View} from 'react-native' + import {type NotificationView} from '#/state/queries/notifications/grouped/types' +import {SHOW_ROW_BORDERS} from '#/screens/Notifications/rowBorders' +import {atoms as a, useTheme} from '#/alf' import { GeneratorLikeNotification, LikeNotification, @@ -40,9 +44,27 @@ export {LoadingSkeleton} from './LoadingSkeleton' */ export function NotificationItem({ notification, + hasDivider = false, }: { notification: NotificationView + /** + * Whether to draw a divider above the row, when `SHOW_ROW_BORDERS` is on. + */ + hasDivider?: boolean }) { + const t = useTheme() + return ( + + + + ) +} + +function NotificationRow({notification}: {notification: NotificationView}) { switch (notification.type) { case 'like': return diff --git a/src/screens/Notifications/components/PageList.tsx b/src/screens/Notifications/components/PageList.tsx index 9c7281e7d..6852657c1 100644 --- a/src/screens/Notifications/components/PageList.tsx +++ b/src/screens/Notifications/components/PageList.tsx @@ -33,10 +33,7 @@ import { LoadingSkeleton, NotificationItem, } from '#/screens/Notifications/components/NotificationItem' -import { - getRowBorderColor, - useRowBackgroundColor, -} from '#/screens/Notifications/components/NotificationItem/Item/Root' +import {useRowBackgroundColor} from '#/screens/Notifications/components/NotificationItem/Item/Root' import {usePager} from '#/screens/Notifications/components/PagerView' import {RefreshPill} from '#/screens/Notifications/components/RefreshPill' import {useRefreshPillMetrics} from '#/screens/Notifications/refreshPillMetrics' @@ -293,26 +290,14 @@ export function PageList({ ) case 'notification': return ( - - - + ) case 'followersHeader': return @@ -374,15 +359,7 @@ export function PageList({ @@ -526,32 +503,17 @@ function isUnreadRow(row: Row | undefined) { ) } -/** - * Whether the border between two rows touches an unread row, which can make - * it stronger, see `getRowBorderColor`. - */ -export function isUnreadBorder(above: Row | undefined, below: Row | undefined) { - return isUnreadRow(above) || isUnreadRow(below) -} - function SectionHeader({ section, isUnreadAbove, - isUnreadBelow, }: { section: 'today' | 'earlier' /** - * Whether the row above is unread, for the colour of the border "Earlier" - * draws above itself. Without row borders, "Earlier" also sits a gap below - * the last row, and the gap takes that row's tint so the tint runs right - * down to the header's border. + * Whether the row above is unread. Without row borders, "Earlier" sits a + * gap below the last row, and the gap takes that row's tint so the tint + * runs right down to the header's border. */ isUnreadAbove: boolean - /** - * Whether the row below is unread, for the colour of the border below the - * header. - */ - isUnreadBelow: boolean }) { const t = useTheme() const {t: l} = useLingui() @@ -568,11 +530,7 @@ function SectionHeader({ section === 'today' ? a.py_sm : [a.border_t, a.pt_md, a.pb_sm], // Rows are divided, so the header is too SHOW_ROW_BORDERS && a.border_b, - // Per side, since the rows above and below can differ - { - borderTopColor: getRowBorderColor(t, isUnreadAbove), - borderBottomColor: getRowBorderColor(t, isUnreadBelow), - }, + t.atoms.border_contrast_low, ]}> {section === 'today' diff --git a/src/view/screens/Storybook/Notifications.tsx b/src/view/screens/Storybook/Notifications.tsx index 0c0896f55..f6dc96867 100644 --- a/src/view/screens/Storybook/Notifications.tsx +++ b/src/view/screens/Storybook/Notifications.tsx @@ -52,9 +52,10 @@ export function Notifications() { a.overflow_hidden, t.atoms.border_contrast_low, ]}> - {notifications.map(notification => ( + {notifications.map((notification, index) => ( 0} notification={ readState === 'fixture' ? notification