mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
add an even more compact entry layout
This commit is contained in:
1
commafeed-client/package-lock.json
generated
1
commafeed-client/package-lock.json
generated
@@ -20,6 +20,7 @@
|
|||||||
"@mantine/modals": "^5.10.3",
|
"@mantine/modals": "^5.10.3",
|
||||||
"@mantine/notifications": "^5.10.3",
|
"@mantine/notifications": "^5.10.3",
|
||||||
"@mantine/spotlight": "^5.10.3",
|
"@mantine/spotlight": "^5.10.3",
|
||||||
|
"@mantine/styles": "^5.10.3",
|
||||||
"@reduxjs/toolkit": "^1.9.2",
|
"@reduxjs/toolkit": "^1.9.2",
|
||||||
"axios": "^1.3.2",
|
"axios": "^1.3.2",
|
||||||
"dayjs": "^1.11.7",
|
"dayjs": "^1.11.7",
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
"@mantine/modals": "^5.10.3",
|
"@mantine/modals": "^5.10.3",
|
||||||
"@mantine/notifications": "^5.10.3",
|
"@mantine/notifications": "^5.10.3",
|
||||||
"@mantine/spotlight": "^5.10.3",
|
"@mantine/spotlight": "^5.10.3",
|
||||||
|
"@mantine/styles": "^5.10.3",
|
||||||
"@reduxjs/toolkit": "^1.9.2",
|
"@reduxjs/toolkit": "^1.9.2",
|
||||||
"axios": "^1.3.2",
|
"axios": "^1.3.2",
|
||||||
"dayjs": "^1.11.7",
|
"dayjs": "^1.11.7",
|
||||||
|
|||||||
@@ -306,4 +306,4 @@ export type ReadingMode = "all" | "unread"
|
|||||||
|
|
||||||
export type ReadingOrder = "asc" | "desc"
|
export type ReadingOrder = "asc" | "desc"
|
||||||
|
|
||||||
export type ViewMode = "title" | "cozy" | "expanded"
|
export type ViewMode = "title" | "cozy" | "detailed" | "expanded"
|
||||||
|
|||||||
@@ -2,9 +2,10 @@ import { Anchor, Box, createStyles, Divider, Paper } from "@mantine/core"
|
|||||||
import { Constants } from "app/constants"
|
import { Constants } from "app/constants"
|
||||||
import { markEntry } from "app/slices/entries"
|
import { markEntry } from "app/slices/entries"
|
||||||
import { useAppDispatch, useAppSelector } from "app/store"
|
import { useAppDispatch, useAppSelector } from "app/store"
|
||||||
import { Entry } from "app/types"
|
import { Entry, ViewMode } from "app/types"
|
||||||
import React from "react"
|
import React from "react"
|
||||||
import { useSwipeable } from "react-swipeable"
|
import { useSwipeable } from "react-swipeable"
|
||||||
|
import { MantineNumberSize } from "@mantine/styles"
|
||||||
import { FeedEntryBody } from "./FeedEntryBody"
|
import { FeedEntryBody } from "./FeedEntryBody"
|
||||||
import { FeedEntryCompactHeader } from "./FeedEntryCompactHeader"
|
import { FeedEntryCompactHeader } from "./FeedEntryCompactHeader"
|
||||||
import { FeedEntryContextMenu, useFeedEntryContextMenu } from "./FeedEntryContextMenu"
|
import { FeedEntryContextMenu, useFeedEntryContextMenu } from "./FeedEntryContextMenu"
|
||||||
@@ -18,16 +19,18 @@ interface FeedEntryProps {
|
|||||||
onHeaderClick: (e: React.MouseEvent) => void
|
onHeaderClick: (e: React.MouseEvent) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
const useStyles = createStyles((theme, props: FeedEntryProps & { compact: boolean }) => {
|
const useStyles = createStyles((theme, props: FeedEntryProps & { viewMode?: ViewMode }) => {
|
||||||
let backgroundColor
|
let backgroundColor
|
||||||
if (theme.colorScheme === "dark") backgroundColor = props.entry.read ? "inherit" : theme.colors.dark[5]
|
if (theme.colorScheme === "dark") backgroundColor = props.entry.read ? "inherit" : theme.colors.dark[5]
|
||||||
else backgroundColor = props.entry.read && !props.expanded ? theme.colors.gray[0] : "inherit"
|
else backgroundColor = props.entry.read && !props.expanded ? theme.colors.gray[0] : "inherit"
|
||||||
|
|
||||||
let marginY = theme.spacing.xs
|
let marginY = theme.spacing.xs
|
||||||
if (props.compact) marginY = 6
|
if (props.viewMode === "title") marginY = 2
|
||||||
|
else if (props.viewMode === "cozy") marginY = 6
|
||||||
|
|
||||||
let mobileMarginY = 6
|
let mobileMarginY = 6
|
||||||
if (props.compact) mobileMarginY = 4
|
if (props.viewMode === "title") mobileMarginY = 2
|
||||||
|
else if (props.viewMode === "cozy") mobileMarginY = 4
|
||||||
|
|
||||||
const styles = {
|
const styles = {
|
||||||
paper: {
|
paper: {
|
||||||
@@ -53,10 +56,7 @@ const useStyles = createStyles((theme, props: FeedEntryProps & { compact: boolea
|
|||||||
|
|
||||||
export function FeedEntry(props: FeedEntryProps) {
|
export function FeedEntry(props: FeedEntryProps) {
|
||||||
const viewMode = useAppSelector(state => state.user.settings?.viewMode)
|
const viewMode = useAppSelector(state => state.user.settings?.viewMode)
|
||||||
const compact = viewMode === "title"
|
const { classes } = useStyles({ ...props, viewMode })
|
||||||
const compactHeader = compact && !props.expanded
|
|
||||||
|
|
||||||
const { classes } = useStyles({ ...props, compact })
|
|
||||||
|
|
||||||
const dispatch = useAppDispatch()
|
const dispatch = useAppDispatch()
|
||||||
|
|
||||||
@@ -66,9 +66,15 @@ export function FeedEntry(props: FeedEntryProps) {
|
|||||||
|
|
||||||
const { onContextMenu } = useFeedEntryContextMenu(props.entry)
|
const { onContextMenu } = useFeedEntryContextMenu(props.entry)
|
||||||
|
|
||||||
const spacing = compact ? 8 : "xs"
|
let padding: MantineNumberSize = "xs"
|
||||||
const borderRadius = compact ? "xs" : "sm"
|
if (viewMode === "title") padding = 4
|
||||||
|
else if (viewMode === "cozy") padding = 8
|
||||||
|
|
||||||
|
let borderRadius: MantineNumberSize = "sm"
|
||||||
|
if (viewMode === "title") borderRadius = 0
|
||||||
|
else if (viewMode === "cozy") borderRadius = "xs"
|
||||||
|
|
||||||
|
const compactHeader = !props.expanded && (viewMode === "title" || viewMode === "cozy")
|
||||||
return (
|
return (
|
||||||
<Paper withBorder radius={borderRadius} className={classes.paper}>
|
<Paper withBorder radius={borderRadius} className={classes.paper}>
|
||||||
<Anchor
|
<Anchor
|
||||||
@@ -80,17 +86,17 @@ export function FeedEntry(props: FeedEntryProps) {
|
|||||||
onAuxClick={props.onHeaderClick}
|
onAuxClick={props.onHeaderClick}
|
||||||
onContextMenu={onContextMenu}
|
onContextMenu={onContextMenu}
|
||||||
>
|
>
|
||||||
<Box p={spacing} {...swipeHandlers}>
|
<Box p={padding} {...swipeHandlers}>
|
||||||
{compactHeader && <FeedEntryCompactHeader entry={props.entry} />}
|
{compactHeader && <FeedEntryCompactHeader entry={props.entry} />}
|
||||||
{!compactHeader && <FeedEntryHeader entry={props.entry} expanded={props.expanded} />}
|
{!compactHeader && <FeedEntryHeader entry={props.entry} expanded={props.expanded} />}
|
||||||
</Box>
|
</Box>
|
||||||
</Anchor>
|
</Anchor>
|
||||||
{props.expanded && (
|
{props.expanded && (
|
||||||
<Box px={spacing} pb={spacing}>
|
<Box px={padding} pb={padding}>
|
||||||
<Box className={classes.body} sx={{ direction: props.entry.rtl ? "rtl" : "ltr" }}>
|
<Box className={classes.body} sx={{ direction: props.entry.rtl ? "rtl" : "ltr" }}>
|
||||||
<FeedEntryBody entry={props.entry} />
|
<FeedEntryBody entry={props.entry} />
|
||||||
</Box>
|
</Box>
|
||||||
<Divider variant="dashed" my={spacing} />
|
<Divider variant="dashed" my={padding} />
|
||||||
<FeedEntryFooter entry={props.entry} />
|
<FeedEntryFooter entry={props.entry} />
|
||||||
</Box>
|
</Box>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import {
|
|||||||
TbHelp,
|
TbHelp,
|
||||||
TbLayoutList,
|
TbLayoutList,
|
||||||
TbList,
|
TbList,
|
||||||
|
TbListDetails,
|
||||||
TbMoon,
|
TbMoon,
|
||||||
TbNotes,
|
TbNotes,
|
||||||
TbPower,
|
TbPower,
|
||||||
@@ -54,6 +55,17 @@ const viewModeData: ViewModeControlItem[] = [
|
|||||||
</Group>
|
</Group>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
value: "detailed",
|
||||||
|
label: (
|
||||||
|
<Group>
|
||||||
|
<TbListDetails size={iconSize} />
|
||||||
|
<Box ml={6}>
|
||||||
|
<Trans>Detailed</Trans>
|
||||||
|
</Box>
|
||||||
|
</Group>
|
||||||
|
),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
value: "expanded",
|
value: "expanded",
|
||||||
label: (
|
label: (
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ public class UserSettings extends AbstractModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public enum ViewMode {
|
public enum ViewMode {
|
||||||
title, cozy, expanded
|
title, cozy, detailed, expanded
|
||||||
}
|
}
|
||||||
|
|
||||||
@OneToOne(fetch = FetchType.LAZY)
|
@OneToOne(fetch = FetchType.LAZY)
|
||||||
|
|||||||
Reference in New Issue
Block a user