forked from Archives/Athou_commafeed
add data attributes to tree elements (#1507)
This commit is contained in:
@@ -310,6 +310,7 @@ export function FeedEntries() {
|
|||||||
ref={el => {
|
ref={el => {
|
||||||
if (el) el.id = Constants.dom.entryId(entry)
|
if (el) el.id = Constants.dom.entryId(entry)
|
||||||
}}
|
}}
|
||||||
|
data-id={entry.id}
|
||||||
>
|
>
|
||||||
<FeedEntry
|
<FeedEntry
|
||||||
entry={entry}
|
entry={entry}
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ export function Tree() {
|
|||||||
const allCategoryNode = () => (
|
const allCategoryNode = () => (
|
||||||
<TreeNode
|
<TreeNode
|
||||||
id={Constants.categories.all.id}
|
id={Constants.categories.all.id}
|
||||||
|
type="category"
|
||||||
name={<Trans>All</Trans>}
|
name={<Trans>All</Trans>}
|
||||||
icon={allIcon}
|
icon={allIcon}
|
||||||
unread={categoryUnreadCount(root)}
|
unread={categoryUnreadCount(root)}
|
||||||
@@ -83,6 +84,7 @@ export function Tree() {
|
|||||||
const starredCategoryNode = () => (
|
const starredCategoryNode = () => (
|
||||||
<TreeNode
|
<TreeNode
|
||||||
id={Constants.categories.starred.id}
|
id={Constants.categories.starred.id}
|
||||||
|
type="category"
|
||||||
name={<Trans>Starred</Trans>}
|
name={<Trans>Starred</Trans>}
|
||||||
icon={starredIcon}
|
icon={starredIcon}
|
||||||
unread={0}
|
unread={0}
|
||||||
@@ -102,6 +104,7 @@ export function Tree() {
|
|||||||
return (
|
return (
|
||||||
<TreeNode
|
<TreeNode
|
||||||
id={category.id}
|
id={category.id}
|
||||||
|
type="category"
|
||||||
name={category.name}
|
name={category.name}
|
||||||
icon={category.expanded ? expandedIcon : collapsedIcon}
|
icon={category.expanded ? expandedIcon : collapsedIcon}
|
||||||
unread={unreadCount}
|
unread={unreadCount}
|
||||||
@@ -122,6 +125,7 @@ export function Tree() {
|
|||||||
return (
|
return (
|
||||||
<TreeNode
|
<TreeNode
|
||||||
id={String(feed.id)}
|
id={String(feed.id)}
|
||||||
|
type="feed"
|
||||||
name={feed.name}
|
name={feed.name}
|
||||||
icon={feed.iconUrl}
|
icon={feed.iconUrl}
|
||||||
unread={feed.unread}
|
unread={feed.unread}
|
||||||
@@ -137,6 +141,7 @@ export function Tree() {
|
|||||||
const tagNode = (tag: string) => (
|
const tagNode = (tag: string) => (
|
||||||
<TreeNode
|
<TreeNode
|
||||||
id={tag}
|
id={tag}
|
||||||
|
type="tag"
|
||||||
name={tag}
|
name={tag}
|
||||||
icon={tagIcon}
|
icon={tagIcon}
|
||||||
unread={0}
|
unread={0}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { Box, Center } from "@mantine/core"
|
import { Box, Center } from "@mantine/core"
|
||||||
|
import type { EntrySourceType } from "app/entries/slice"
|
||||||
import { FeedFavicon } from "components/content/FeedFavicon"
|
import { FeedFavicon } from "components/content/FeedFavicon"
|
||||||
import type React from "react"
|
import type React from "react"
|
||||||
import { tss } from "tss"
|
import { tss } from "tss"
|
||||||
@@ -6,6 +7,7 @@ import { UnreadCount } from "./UnreadCount"
|
|||||||
|
|
||||||
interface TreeNodeProps {
|
interface TreeNodeProps {
|
||||||
id: string
|
id: string
|
||||||
|
type: EntrySourceType
|
||||||
name: React.ReactNode
|
name: React.ReactNode
|
||||||
icon: React.ReactNode
|
icon: React.ReactNode
|
||||||
unread: number
|
unread: number
|
||||||
@@ -63,7 +65,15 @@ export function TreeNode(props: TreeNodeProps) {
|
|||||||
hasUnread: props.unread > 0,
|
hasUnread: props.unread > 0,
|
||||||
})
|
})
|
||||||
return (
|
return (
|
||||||
<Box py={1} pl={props.level * 20} className={classes.node} onClick={(e: React.MouseEvent) => props.onClick(e, props.id)}>
|
<Box
|
||||||
|
py={1}
|
||||||
|
pl={props.level * 20}
|
||||||
|
className={classes.node}
|
||||||
|
onClick={(e: React.MouseEvent) => props.onClick(e, props.id)}
|
||||||
|
data-id={props.id}
|
||||||
|
data-type={props.type}
|
||||||
|
data-unread-count={props.unread}
|
||||||
|
>
|
||||||
<Box mr={6} onClick={(e: React.MouseEvent) => props.onIconClick?.(e, props.id)}>
|
<Box mr={6} onClick={(e: React.MouseEvent) => props.onIconClick?.(e, props.id)}>
|
||||||
<Center>{typeof props.icon === "string" ? <FeedFavicon url={props.icon} /> : props.icon}</Center>
|
<Center>{typeof props.icon === "string" ? <FeedFavicon url={props.icon} /> : props.icon}</Center>
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
Reference in New Issue
Block a user