2022-04-15 02:51:59 +00:00
|
|
|
import { IUnreadBadge } from '.';
|
|
|
|
import { themes } from '../../lib/constants/colors';
|
2022-04-12 16:27:05 +00:00
|
|
|
import { TSupportedThemes } from '../../theme';
|
2020-10-30 16:15:58 +00:00
|
|
|
|
2022-04-15 02:51:59 +00:00
|
|
|
interface IGetUnreadStyle extends Omit<IUnreadBadge, 'small' | 'style'> {
|
2022-04-12 16:27:05 +00:00
|
|
|
theme: TSupportedThemes;
|
|
|
|
}
|
|
|
|
|
|
|
|
export const getUnreadStyle = ({
|
|
|
|
unread,
|
|
|
|
userMentions,
|
|
|
|
groupMentions,
|
|
|
|
theme,
|
|
|
|
tunread,
|
|
|
|
tunreadUser,
|
|
|
|
tunreadGroup
|
|
|
|
}: IGetUnreadStyle) => {
|
2021-09-13 20:41:05 +00:00
|
|
|
if ((!unread || unread <= 0) && !tunread?.length) {
|
2020-10-30 16:15:58 +00:00
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
2024-04-18 10:19:54 +00:00
|
|
|
let backgroundColor = themes[theme].fontAnnotation;
|
|
|
|
const color = themes[theme].fontWhite;
|
2022-04-12 16:27:05 +00:00
|
|
|
if ((userMentions && userMentions > 0) || tunreadUser?.length) {
|
2024-04-18 10:19:54 +00:00
|
|
|
backgroundColor = themes[theme].badgeBackgroundLevel4;
|
2022-04-12 16:27:05 +00:00
|
|
|
} else if ((groupMentions && groupMentions > 0) || tunreadGroup?.length) {
|
2024-04-18 10:19:54 +00:00
|
|
|
backgroundColor = themes[theme].badgeBackgroundLevel3;
|
2022-04-12 16:27:05 +00:00
|
|
|
} else if (tunread && tunread?.length > 0) {
|
2024-04-18 10:19:54 +00:00
|
|
|
backgroundColor = theme === 'light' ? themes[theme].fontInfo : themes[theme].buttonBackgroundPrimaryPress;
|
2020-10-30 16:15:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
2021-09-13 20:41:05 +00:00
|
|
|
backgroundColor,
|
|
|
|
color
|
2020-10-30 16:15:58 +00:00
|
|
|
};
|
|
|
|
};
|