mirror of
https://github.com/ManInDark/HabitTrove.git
synced 2026-01-20 22:24:28 +01:00
fix: only display 'show all' if there are more than 4 entries
This commit is contained in:
@@ -27,6 +27,7 @@ import ConfirmDialog from './ConfirmDialog'
|
|||||||
import { HabitContextMenuItems } from './HabitContextMenuItems'
|
import { HabitContextMenuItems } from './HabitContextMenuItems'
|
||||||
import Linkify from './linkify'
|
import Linkify from './linkify'
|
||||||
import { Button } from './ui/button'
|
import { Button } from './ui/button'
|
||||||
|
import { DESKTOP_DISPLAY_ITEM_COUNT } from '@/lib/constants'
|
||||||
|
|
||||||
interface UpcomingItemsProps {
|
interface UpcomingItemsProps {
|
||||||
habits: Habit[]
|
habits: Habit[]
|
||||||
@@ -165,7 +166,7 @@ const ItemSection = ({
|
|||||||
const bTarget = b.targetCompletions || 1;
|
const bTarget = b.targetCompletions || 1;
|
||||||
return bTarget - aTarget;
|
return bTarget - aTarget;
|
||||||
})
|
})
|
||||||
.slice(0, currentExpanded ? undefined : 5)
|
.slice(0, currentExpanded ? undefined : DESKTOP_DISPLAY_ITEM_COUNT)
|
||||||
.map((habit) => {
|
.map((habit) => {
|
||||||
const completionsToday = habit.completions.filter(completion =>
|
const completionsToday = habit.completions.filter(completion =>
|
||||||
isSameDate(t2d({ timestamp: completion, timezone: settings.system.timezone }), t2d({ timestamp: d2t({ dateTime: getNow({ timezone: settings.system.timezone }) }), timezone: settings.system.timezone }))
|
isSameDate(t2d({ timestamp: completion, timezone: settings.system.timezone }), t2d({ timestamp: d2t({ dateTime: getNow({ timezone: settings.system.timezone }) }), timezone: settings.system.timezone }))
|
||||||
@@ -295,7 +296,7 @@ const ItemSection = ({
|
|||||||
onClick={() => setCurrentExpanded(!currentExpanded)}
|
onClick={() => setCurrentExpanded(!currentExpanded)}
|
||||||
className="text-sm text-muted-foreground hover:text-primary flex items-center gap-1"
|
className="text-sm text-muted-foreground hover:text-primary flex items-center gap-1"
|
||||||
>
|
>
|
||||||
{currentExpanded ? (
|
{items.length > DESKTOP_DISPLAY_ITEM_COUNT && (currentExpanded ? (
|
||||||
<>
|
<>
|
||||||
{t('showLessButton')}
|
{t('showLessButton')}
|
||||||
<ChevronUp className="h-3 w-3" />
|
<ChevronUp className="h-3 w-3" />
|
||||||
@@ -305,7 +306,7 @@ const ItemSection = ({
|
|||||||
{t('showAllButton')}
|
{t('showAllButton')}
|
||||||
<ChevronDown className="h-3 w-3" />
|
<ChevronDown className="h-3 w-3" />
|
||||||
</>
|
</>
|
||||||
)}
|
))}
|
||||||
</button>
|
</button>
|
||||||
<Link
|
<Link
|
||||||
href={viewLink}
|
href={viewLink}
|
||||||
@@ -444,7 +445,7 @@ export default function DailyOverview({
|
|||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
{sortedWishlistItems
|
{sortedWishlistItems
|
||||||
.slice(0, browserSettings.expandedWishlist ? undefined : 5)
|
.slice(0, browserSettings.expandedWishlist ? undefined : DESKTOP_DISPLAY_ITEM_COUNT)
|
||||||
.map((item) => {
|
.map((item) => {
|
||||||
const isRedeemable = item.coinCost <= coinBalance
|
const isRedeemable = item.coinCost <= coinBalance
|
||||||
return (
|
return (
|
||||||
@@ -501,7 +502,7 @@ export default function DailyOverview({
|
|||||||
onClick={() => setBrowserSettings(prev => ({ ...prev, expandedWishlist: !prev.expandedWishlist }))}
|
onClick={() => setBrowserSettings(prev => ({ ...prev, expandedWishlist: !prev.expandedWishlist }))}
|
||||||
className="text-sm text-muted-foreground hover:text-primary flex items-center gap-1"
|
className="text-sm text-muted-foreground hover:text-primary flex items-center gap-1"
|
||||||
>
|
>
|
||||||
{browserSettings.expandedWishlist ? (
|
{wishlistItems.length > DESKTOP_DISPLAY_ITEM_COUNT && (browserSettings.expandedWishlist ? (
|
||||||
<>
|
<>
|
||||||
{t('showLessButton')}
|
{t('showLessButton')}
|
||||||
<ChevronUp className="h-3 w-3" />
|
<ChevronUp className="h-3 w-3" />
|
||||||
@@ -511,7 +512,7 @@ export default function DailyOverview({
|
|||||||
{t('showAllButton')}
|
{t('showAllButton')}
|
||||||
<ChevronDown className="h-3 w-3" />
|
<ChevronDown className="h-3 w-3" />
|
||||||
</>
|
</>
|
||||||
)}
|
))}
|
||||||
</button>
|
</button>
|
||||||
<Link
|
<Link
|
||||||
href="/wishlist"
|
href="/wishlist"
|
||||||
|
|||||||
@@ -31,4 +31,6 @@ export const QUICK_DATES = [
|
|||||||
{ label: 'Sunday', value: 'this sunday' },
|
{ label: 'Sunday', value: 'this sunday' },
|
||||||
] as const
|
] as const
|
||||||
|
|
||||||
export const MAX_COIN_LIMIT = 9999
|
export const MAX_COIN_LIMIT = 9999
|
||||||
|
|
||||||
|
export const DESKTOP_DISPLAY_ITEM_COUNT = 4
|
||||||
Reference in New Issue
Block a user