mirror of
https://github.com/zhigang1992/devhub.git
synced 2026-06-10 06:50:12 +08:00
Fix separator color on read items
This commit is contained in:
@@ -1,26 +1,33 @@
|
||||
import { getLuminance } from 'polished'
|
||||
import React from 'react'
|
||||
|
||||
import { ThemeColors } from '@devhub/core'
|
||||
import { isItemRead, ThemeColors } from '@devhub/core'
|
||||
import { Separator } from '../../common/Separator'
|
||||
import { useTheme } from '../../context/ThemeContext'
|
||||
|
||||
export function getCardItemSeparatorThemeColor(
|
||||
backgroundColor: string,
|
||||
isRead?: boolean,
|
||||
): keyof ThemeColors {
|
||||
const luminance = getLuminance(backgroundColor)
|
||||
|
||||
if (luminance <= 0.02) return 'backgroundColorLess2'
|
||||
return 'backgroundColorDarker1'
|
||||
|
||||
return isRead ? 'backgroundColorDarker2' : 'backgroundColorDarker1'
|
||||
}
|
||||
|
||||
export function CardItemSeparator() {
|
||||
export function CardItemSeparator(props: any) {
|
||||
const { leadingItem } = props
|
||||
|
||||
const theme = useTheme()
|
||||
|
||||
const isRead = leadingItem ? isItemRead(leadingItem) : false
|
||||
|
||||
return (
|
||||
<Separator
|
||||
backgroundThemeColor={getCardItemSeparatorThemeColor(
|
||||
theme.backgroundColor,
|
||||
isRead,
|
||||
)}
|
||||
horizontal
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user