From f40f52990516456d4d079b0202f08290f4b19724 Mon Sep 17 00:00:00 2001 From: diondiondion Date: Thu, 12 Feb 2026 17:30:10 +0100 Subject: [PATCH] [Glitch] Implement Collection list item design Port c44cc1f5c3bafb49a324f8f72a42a91d09eecfe3 to glitch-soc Signed-off-by: Claire --- .../glitch/features/collections/index.tsx | 64 +++++++++++++++---- .../features/collections/styles.module.scss | 48 ++++++++++++++ 2 files changed, 98 insertions(+), 14 deletions(-) create mode 100644 app/javascript/flavours/glitch/features/collections/styles.module.scss diff --git a/app/javascript/flavours/glitch/features/collections/index.tsx b/app/javascript/flavours/glitch/features/collections/index.tsx index a68cd5e3c6..9132580f68 100644 --- a/app/javascript/flavours/glitch/features/collections/index.tsx +++ b/app/javascript/flavours/glitch/features/collections/index.tsx @@ -1,7 +1,8 @@ -import { useEffect, useMemo, useCallback } from 'react'; +import { useEffect, useMemo, useCallback, useId } from 'react'; import { defineMessages, useIntl, FormattedMessage } from 'react-intl'; +import classNames from 'classnames'; import { Helmet } from 'react-helmet'; import { Link } from 'react-router-dom'; @@ -10,10 +11,12 @@ import ListAltIcon from '@/material-icons/400-24px/list_alt.svg?react'; import MoreHorizIcon from '@/material-icons/400-24px/more_horiz.svg?react'; import SquigglyArrow from '@/svg-icons/squiggly_arrow.svg?react'; import { openModal } from 'flavours/glitch/actions/modal'; +import type { ApiCollectionJSON } from 'flavours/glitch/api_types/collections'; import { Column } from 'flavours/glitch/components/column'; import { ColumnHeader } from 'flavours/glitch/components/column_header'; import { Dropdown } from 'flavours/glitch/components/dropdown_menu'; import { Icon } from 'flavours/glitch/components/icon'; +import { RelativeTimestamp } from 'flavours/glitch/components/relative_timestamp'; import ScrollableList from 'flavours/glitch/components/scrollable_list'; import { fetchAccountCollections, @@ -22,6 +25,7 @@ import { import { useAppSelector, useAppDispatch } from 'flavours/glitch/store'; import { messages as editorMessages } from './editor'; +import classes from './styles.module.scss'; const messages = defineMessages({ heading: { id: 'column.collections', defaultMessage: 'My collections' }, @@ -36,13 +40,14 @@ const messages = defineMessages({ more: { id: 'status.more', defaultMessage: 'More' }, }); -const ListItem: React.FC<{ - id: string; - name: string; -}> = ({ id, name }) => { +const CollectionItem: React.FC<{ + collection: ApiCollectionJSON; +}> = ({ collection }) => { const dispatch = useAppDispatch(); const intl = useIntl(); + const { id, name } = collection; + const handleDeleteClick = useCallback(() => { dispatch( openModal({ @@ -81,14 +86,45 @@ const ListItem: React.FC<{ [intl, id, handleDeleteClick], ); + const linkId = useId(); + return ( -
- - {name} - +
+
+

+ + {name} + +

+
    + + + ), + }} + tagName='li' + /> +
+
-
+ ); }; @@ -166,7 +202,7 @@ export const Collections: React.FC<{ bindToDocument={!multiColumn} > {collections.map((item) => ( - + ))} diff --git a/app/javascript/flavours/glitch/features/collections/styles.module.scss b/app/javascript/flavours/glitch/features/collections/styles.module.scss new file mode 100644 index 0000000000..ebcab70d59 --- /dev/null +++ b/app/javascript/flavours/glitch/features/collections/styles.module.scss @@ -0,0 +1,48 @@ +.collectionItemWrapper { + display: flex; + align-items: center; + gap: 16px; + margin-inline: 10px; + padding-inline-end: 5px; + border-bottom: 1px solid var(--color-border-primary); +} + +.collectionItemContent { + position: relative; + flex-grow: 1; + padding: 15px 5px; +} + +.collectionItemLink { + display: block; + margin-bottom: 2px; + font-size: 15px; + font-weight: 500; + text-decoration: none; + color: var(--color-text-primary); + + &:hover { + color: var(--color-text-brand); + } + + &::after { + // Increase clickable area by extending link across parent + content: ''; + position: absolute; + inset: 0; + } +} + +.collectionItemInfo { + --gap: 0.75ch; + + display: flex; + gap: var(--gap); + font-size: 13px; + color: var(--color-text-secondary); + + & > li:not(:first-child)::before { + content: 'ยท'; + margin-inline-end: var(--gap); + } +}