From 4bf146d4ab19adb03342163601b1105aeceac6a6 Mon Sep 17 00:00:00 2001 From: Bill Date: Thu, 3 Mar 2022 12:09:41 -0500 Subject: [PATCH] Update LayoutItemCount --- .../card/tabs/NitroCardTabsItemView.tsx | 4 +-- src/common/index.scss | 8 ++++++ src/common/layout/LayoutGridItem.tsx | 4 +-- src/common/layout/LayoutItemCountView.tsx | 28 +++++++++++++++++++ src/common/layout/index.ts | 1 + src/components/toolbar/ToolbarMeView.tsx | 5 ++-- src/components/toolbar/ToolbarView.tsx | 9 +++--- .../views/messenger/FriendsMessengerView.tsx | 5 ++-- src/views/shared/Shared.scss | 1 - .../shared/item-count/ItemCountView.scss | 6 ---- src/views/shared/item-count/ItemCountView.tsx | 13 --------- 11 files changed, 49 insertions(+), 35 deletions(-) create mode 100644 src/common/layout/LayoutItemCountView.tsx delete mode 100644 src/views/shared/item-count/ItemCountView.scss delete mode 100644 src/views/shared/item-count/ItemCountView.tsx diff --git a/src/common/card/tabs/NitroCardTabsItemView.tsx b/src/common/card/tabs/NitroCardTabsItemView.tsx index 62b8555f..6d883449 100644 --- a/src/common/card/tabs/NitroCardTabsItemView.tsx +++ b/src/common/card/tabs/NitroCardTabsItemView.tsx @@ -1,6 +1,6 @@ import classNames from 'classnames'; import { FC, MouseEventHandler } from 'react'; -import { ItemCountView } from '../../../views/shared/item-count/ItemCountView'; +import { LayoutItemCountView } from '../../layout'; interface NitroCardTabsItemViewProps { @@ -17,7 +17,7 @@ export const NitroCardTabsItemView: FC = props =>
  • { children } { (count > 0) && - } + }
  • ); } diff --git a/src/common/index.scss b/src/common/index.scss index 3b8e0e69..524b39b6 100644 --- a/src/common/index.scss +++ b/src/common/index.scss @@ -260,4 +260,12 @@ height: 15px; } +.nitro-item-count { + top: 2px; + right: 2px; + font-size: 8px; + z-index: 1; +} + + @import './card/NitroCardView'; diff --git a/src/common/layout/LayoutGridItem.tsx b/src/common/layout/LayoutGridItem.tsx index 531ac483..b2af1fc8 100644 --- a/src/common/layout/LayoutGridItem.tsx +++ b/src/common/layout/LayoutGridItem.tsx @@ -1,8 +1,8 @@ import { FC, useMemo } from 'react'; -import { ItemCountView } from '../../views/shared/item-count/ItemCountView'; import { LimitedEditionStyledNumberView } from '../../views/shared/limited-edition/LimitedEditionStyledNumberView'; import { Base } from '../Base'; import { Column, ColumnProps } from '../Column'; +import { LayoutItemCountView } from './LayoutItemCountView'; export interface LayoutGridItemProps extends ColumnProps { @@ -61,7 +61,7 @@ export const LayoutGridItem: FC = props => return ( { (itemCount > itemCountMinimum) && - } + } { (itemUniqueNumber > 0) && <> diff --git a/src/common/layout/LayoutItemCountView.tsx b/src/common/layout/LayoutItemCountView.tsx new file mode 100644 index 00000000..03877bdb --- /dev/null +++ b/src/common/layout/LayoutItemCountView.tsx @@ -0,0 +1,28 @@ +import { FC, useMemo } from 'react'; +import { Base, BaseProps } from '..'; + +interface LayoutItemCountViewProps extends BaseProps +{ + count: number; +} + +export const LayoutItemCountView: FC = props => +{ + const { count = 0, position = 'aboslute', classNames = [], children = null, ...rest } = props; + + const getClassNames = useMemo(() => + { + const newClassNames: string[] = [ 'badge', 'border', 'bg-danger', 'px-1', 'rounded-circle', 'nitro-item-count' ]; + + if(classNames.length) newClassNames.push(...classNames); + + return newClassNames; + }, [ classNames ]); + + return ( + + { count } + { children } + + ); +} diff --git a/src/common/layout/index.ts b/src/common/layout/index.ts index 98229b12..0fa5bbb2 100644 --- a/src/common/layout/index.ts +++ b/src/common/layout/index.ts @@ -2,6 +2,7 @@ export * from './LayoutCurrencyIcon'; export * from './LayoutGiftTagView'; export * from './LayoutGridItem'; export * from './LayoutImage'; +export * from './LayoutItemCountView'; export * from './LayoutLoadingSpinnerView'; export * from './LayoutMiniCameraView'; export * from './LayoutNotificationAlertView'; diff --git a/src/components/toolbar/ToolbarMeView.tsx b/src/components/toolbar/ToolbarMeView.tsx index d0196ca2..85cff7b7 100644 --- a/src/components/toolbar/ToolbarMeView.tsx +++ b/src/components/toolbar/ToolbarMeView.tsx @@ -1,8 +1,7 @@ import { RoomObjectCategory } from '@nitrots/nitro-renderer'; import { FC, useEffect } from 'react'; import { GetRoomEngine, GetRoomSession } from '../../api'; -import { Base, Flex } from '../../common'; -import { ItemCountView } from '../../views/shared/item-count/ItemCountView'; +import { Base, Flex, LayoutItemCountView } from '../../common'; import { ToolbarViewItems } from './common/ToolbarViewItems'; export interface ToolbarMeViewProps @@ -31,7 +30,7 @@ export const ToolbarMeView: FC = props => handleToolbarItemClick(ToolbarViewItems.GUIDE_TOOL_ITEM) } /> } handleToolbarItemClick(ToolbarViewItems.ACHIEVEMENTS_ITEM) }> { (unseenAchievementCount > 0) && - } + } handleToolbarItemClick(ToolbarViewItems.PROFILE_ITEM) } /> diff --git a/src/components/toolbar/ToolbarView.tsx b/src/components/toolbar/ToolbarView.tsx index 5b01310f..1fb93624 100644 --- a/src/components/toolbar/ToolbarView.tsx +++ b/src/components/toolbar/ToolbarView.tsx @@ -1,11 +1,10 @@ import { Dispose, DropBounce, EaseOut, FigureUpdateEvent, JumpBy, Motions, NitroToolbarAnimateIconEvent, PerkAllowancesMessageEvent, PerkEnum, Queue, UserInfoDataParser, UserInfoEvent, Wait } from '@nitrots/nitro-renderer'; import { FC, useCallback, useState } from 'react'; import { CreateLinkEvent, GetRoomSession, GetRoomSessionManager, GetSessionDataManager, GetUserProfile, GoToDesktop, OpenMessengerChat } from '../../api'; -import { Base, Flex, TransitionAnimation, TransitionAnimationTypes } from '../../common'; +import { Base, Flex, LayoutItemCountView, TransitionAnimation, TransitionAnimationTypes } from '../../common'; import { AchievementsUIEvent, AchievementsUIUnseenCountEvent, FriendsEvent, FriendsMessengerIconEvent, FriendsRequestCountEvent, GuideToolEvent, InventoryEvent, ModToolsEvent, NavigatorEvent, UnseenItemTrackerUpdateEvent, UserSettingsUIEvent } from '../../events'; import { BatchUpdates, DispatchUiEvent, UseMessageEventHook, UseRoomEngineEvent, UseUiEvent } from '../../hooks'; import { AvatarImageView } from '../../views/shared/avatar-image/AvatarImageView'; -import { ItemCountView } from '../../views/shared/item-count/ItemCountView'; import { ToolbarViewItems } from './common/ToolbarViewItems'; import { ToolbarMeView } from './ToolbarMeView'; @@ -199,7 +198,7 @@ export const ToolbarView: FC = props => setMeExpanded(!isMeExpanded) }> { (unseenAchievementCount > 0) && - } + } { isInRoom && } @@ -209,7 +208,7 @@ export const ToolbarView: FC = props => handleToolbarItemClick(ToolbarViewItems.CATALOG_ITEM) } /> handleToolbarItemClick(ToolbarViewItems.INVENTORY_ITEM) }> { (unseenInventoryCount > 0) && - } + } { isInRoom && handleToolbarItemClick(ToolbarViewItems.CAMERA_ITEM) } /> } @@ -222,7 +221,7 @@ export const ToolbarView: FC = props => handleToolbarItemClick(ToolbarViewItems.FRIEND_LIST_ITEM) }> { (unseenFriendRequestCount > 0) && - } + } { ((chatIconType === CHAT_ICON_SHOWING) || (chatIconType === CHAT_ICON_UNREAD)) && handleToolbarItemClick(ToolbarViewItems.FRIEND_CHAT_ITEM) } /> } diff --git a/src/views/friends/views/messenger/FriendsMessengerView.tsx b/src/views/friends/views/messenger/FriendsMessengerView.tsx index edd45820..3d586dfa 100644 --- a/src/views/friends/views/messenger/FriendsMessengerView.tsx +++ b/src/views/friends/views/messenger/FriendsMessengerView.tsx @@ -1,12 +1,11 @@ import { FollowFriendMessageComposer, ILinkEventTracker, NewConsoleMessageEvent, RoomInviteEvent, SendMessageComposer as SendMessageComposerPacket } from '@nitrots/nitro-renderer'; import { FC, KeyboardEvent, useCallback, useEffect, useMemo, useRef, useState } from 'react'; import { AddEventLinkTracker, GetSessionDataManager, GetUserProfile, LocalizeText, MESSENGER_MESSAGE_RECEIVED, MESSENGER_NEW_THREAD, PlaySound, RemoveLinkEventTracker, SendMessageComposer } from '../../../../api'; -import { Base, Button, ButtonGroup, Column, Flex, Grid, NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../../../common'; +import { Base, Button, ButtonGroup, Column, Flex, Grid, LayoutItemCountView, NitroCardContentView, NitroCardHeaderView, NitroCardView } from '../../../../common'; import { FriendsMessengerIconEvent } from '../../../../events'; import { BatchUpdates, DispatchUiEvent, UseMessageEventHook } from '../../../../hooks'; import { AvatarImageView } from '../../../shared/avatar-image/AvatarImageView'; import { BadgeImageView } from '../../../shared/badge-image/BadgeImageView'; -import { ItemCountView } from '../../../shared/item-count/ItemCountView'; import { MessengerThread } from '../../common/MessengerThread'; import { MessengerThreadChat } from '../../common/MessengerThreadChat'; import { useFriendsContext } from '../../FriendsContext'; @@ -267,7 +266,7 @@ export const FriendsMessengerView: FC<{}> = props => return ( setActiveThreadIndex(messageThreadIndex)}> {thread.unread && - + }
    diff --git a/src/views/shared/Shared.scss b/src/views/shared/Shared.scss index d805f5d6..8823f9c3 100644 --- a/src/views/shared/Shared.scss +++ b/src/views/shared/Shared.scss @@ -5,4 +5,3 @@ @import "./pet-image/PetImage"; @import "./rarity-level/RarityLevelView"; @import "./room-previewer/RoomPreviewerView"; -@import "./item-count/ItemCountView"; diff --git a/src/views/shared/item-count/ItemCountView.scss b/src/views/shared/item-count/ItemCountView.scss deleted file mode 100644 index 9db41f2b..00000000 --- a/src/views/shared/item-count/ItemCountView.scss +++ /dev/null @@ -1,6 +0,0 @@ -.nitro-item-count { - top: 2px; - right: 2px; - font-size: 8px; - z-index: 1; -} diff --git a/src/views/shared/item-count/ItemCountView.tsx b/src/views/shared/item-count/ItemCountView.tsx deleted file mode 100644 index 80ea3f65..00000000 --- a/src/views/shared/item-count/ItemCountView.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import { FC } from 'react'; - -interface ItemCountViewProps -{ - count: number; -} - -export const ItemCountView: FC = props => -{ - const { count = 0 } = props; - - return
    { count }
    -}