mirror of
https://github.com/billsonnn/nitro-react.git
synced 2024-11-30 08:50:51 +01:00
Update LayoutItemCount
This commit is contained in:
parent
8bef2096f1
commit
4bf146d4ab
@ -1,6 +1,6 @@
|
|||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { FC, MouseEventHandler } from 'react';
|
import { FC, MouseEventHandler } from 'react';
|
||||||
import { ItemCountView } from '../../../views/shared/item-count/ItemCountView';
|
import { LayoutItemCountView } from '../../layout';
|
||||||
|
|
||||||
interface NitroCardTabsItemViewProps
|
interface NitroCardTabsItemViewProps
|
||||||
{
|
{
|
||||||
@ -17,7 +17,7 @@ export const NitroCardTabsItemView: FC<NitroCardTabsItemViewProps> = props =>
|
|||||||
<li className={ 'nav-link cursor-pointer position-relative' + classNames({ ' active': isActive }) } onClick={ onClick }>
|
<li className={ 'nav-link cursor-pointer position-relative' + classNames({ ' active': isActive }) } onClick={ onClick }>
|
||||||
{ children }
|
{ children }
|
||||||
{ (count > 0) &&
|
{ (count > 0) &&
|
||||||
<ItemCountView count={ count } /> }
|
<LayoutItemCountView count={ count } /> }
|
||||||
</li>
|
</li>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -260,4 +260,12 @@
|
|||||||
height: 15px;
|
height: 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.nitro-item-count {
|
||||||
|
top: 2px;
|
||||||
|
right: 2px;
|
||||||
|
font-size: 8px;
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@import './card/NitroCardView';
|
@import './card/NitroCardView';
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { FC, useMemo } from 'react';
|
import { FC, useMemo } from 'react';
|
||||||
import { ItemCountView } from '../../views/shared/item-count/ItemCountView';
|
|
||||||
import { LimitedEditionStyledNumberView } from '../../views/shared/limited-edition/LimitedEditionStyledNumberView';
|
import { LimitedEditionStyledNumberView } from '../../views/shared/limited-edition/LimitedEditionStyledNumberView';
|
||||||
import { Base } from '../Base';
|
import { Base } from '../Base';
|
||||||
import { Column, ColumnProps } from '../Column';
|
import { Column, ColumnProps } from '../Column';
|
||||||
|
import { LayoutItemCountView } from './LayoutItemCountView';
|
||||||
|
|
||||||
export interface LayoutGridItemProps extends ColumnProps
|
export interface LayoutGridItemProps extends ColumnProps
|
||||||
{
|
{
|
||||||
@ -61,7 +61,7 @@ export const LayoutGridItem: FC<LayoutGridItemProps> = props =>
|
|||||||
return (
|
return (
|
||||||
<Column center={ center } pointer position={ position } overflow={ overflow } column={ column } classNames={ getClassNames } style={ getStyle } { ...rest }>
|
<Column center={ center } pointer position={ position } overflow={ overflow } column={ column } classNames={ getClassNames } style={ getStyle } { ...rest }>
|
||||||
{ (itemCount > itemCountMinimum) &&
|
{ (itemCount > itemCountMinimum) &&
|
||||||
<ItemCountView count={ itemCount } /> }
|
<LayoutItemCountView count={ itemCount } /> }
|
||||||
{ (itemUniqueNumber > 0) &&
|
{ (itemUniqueNumber > 0) &&
|
||||||
<>
|
<>
|
||||||
<Base fit className="unique-bg-override" style={ { backgroundImage: `url(${ itemImage })` } } />
|
<Base fit className="unique-bg-override" style={ { backgroundImage: `url(${ itemImage })` } } />
|
||||||
|
28
src/common/layout/LayoutItemCountView.tsx
Normal file
28
src/common/layout/LayoutItemCountView.tsx
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
import { FC, useMemo } from 'react';
|
||||||
|
import { Base, BaseProps } from '..';
|
||||||
|
|
||||||
|
interface LayoutItemCountViewProps extends BaseProps<HTMLDivElement>
|
||||||
|
{
|
||||||
|
count: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const LayoutItemCountView: FC<LayoutItemCountViewProps> = 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 (
|
||||||
|
<Base position="absolute" classNames={ getClassNames } { ...rest }>
|
||||||
|
{ count }
|
||||||
|
{ children }
|
||||||
|
</Base>
|
||||||
|
);
|
||||||
|
}
|
@ -2,6 +2,7 @@ export * from './LayoutCurrencyIcon';
|
|||||||
export * from './LayoutGiftTagView';
|
export * from './LayoutGiftTagView';
|
||||||
export * from './LayoutGridItem';
|
export * from './LayoutGridItem';
|
||||||
export * from './LayoutImage';
|
export * from './LayoutImage';
|
||||||
|
export * from './LayoutItemCountView';
|
||||||
export * from './LayoutLoadingSpinnerView';
|
export * from './LayoutLoadingSpinnerView';
|
||||||
export * from './LayoutMiniCameraView';
|
export * from './LayoutMiniCameraView';
|
||||||
export * from './LayoutNotificationAlertView';
|
export * from './LayoutNotificationAlertView';
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
import { RoomObjectCategory } from '@nitrots/nitro-renderer';
|
import { RoomObjectCategory } from '@nitrots/nitro-renderer';
|
||||||
import { FC, useEffect } from 'react';
|
import { FC, useEffect } from 'react';
|
||||||
import { GetRoomEngine, GetRoomSession } from '../../api';
|
import { GetRoomEngine, GetRoomSession } from '../../api';
|
||||||
import { Base, Flex } from '../../common';
|
import { Base, Flex, LayoutItemCountView } from '../../common';
|
||||||
import { ItemCountView } from '../../views/shared/item-count/ItemCountView';
|
|
||||||
import { ToolbarViewItems } from './common/ToolbarViewItems';
|
import { ToolbarViewItems } from './common/ToolbarViewItems';
|
||||||
|
|
||||||
export interface ToolbarMeViewProps
|
export interface ToolbarMeViewProps
|
||||||
@ -31,7 +30,7 @@ export const ToolbarMeView: FC<ToolbarMeViewProps> = props =>
|
|||||||
<Base pointer className="navigation-item icon icon-me-helper-tool" onClick={ () => handleToolbarItemClick(ToolbarViewItems.GUIDE_TOOL_ITEM) } /> }
|
<Base pointer className="navigation-item icon icon-me-helper-tool" onClick={ () => handleToolbarItemClick(ToolbarViewItems.GUIDE_TOOL_ITEM) } /> }
|
||||||
<Base pointer className="navigation-item icon icon-me-achievements" onClick={ () => handleToolbarItemClick(ToolbarViewItems.ACHIEVEMENTS_ITEM) }>
|
<Base pointer className="navigation-item icon icon-me-achievements" onClick={ () => handleToolbarItemClick(ToolbarViewItems.ACHIEVEMENTS_ITEM) }>
|
||||||
{ (unseenAchievementCount > 0) &&
|
{ (unseenAchievementCount > 0) &&
|
||||||
<ItemCountView count={ unseenAchievementCount } /> }
|
<LayoutItemCountView count={ unseenAchievementCount } /> }
|
||||||
</Base>
|
</Base>
|
||||||
<Base pointer className="navigation-item icon icon-me-profile" onClick={ () => handleToolbarItemClick(ToolbarViewItems.PROFILE_ITEM) } />
|
<Base pointer className="navigation-item icon icon-me-profile" onClick={ () => handleToolbarItemClick(ToolbarViewItems.PROFILE_ITEM) } />
|
||||||
<Base pointer className="navigation-item icon icon-me-rooms" />
|
<Base pointer className="navigation-item icon icon-me-rooms" />
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
import { Dispose, DropBounce, EaseOut, FigureUpdateEvent, JumpBy, Motions, NitroToolbarAnimateIconEvent, PerkAllowancesMessageEvent, PerkEnum, Queue, UserInfoDataParser, UserInfoEvent, Wait } from '@nitrots/nitro-renderer';
|
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 { FC, useCallback, useState } from 'react';
|
||||||
import { CreateLinkEvent, GetRoomSession, GetRoomSessionManager, GetSessionDataManager, GetUserProfile, GoToDesktop, OpenMessengerChat } from '../../api';
|
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 { AchievementsUIEvent, AchievementsUIUnseenCountEvent, FriendsEvent, FriendsMessengerIconEvent, FriendsRequestCountEvent, GuideToolEvent, InventoryEvent, ModToolsEvent, NavigatorEvent, UnseenItemTrackerUpdateEvent, UserSettingsUIEvent } from '../../events';
|
||||||
import { BatchUpdates, DispatchUiEvent, UseMessageEventHook, UseRoomEngineEvent, UseUiEvent } from '../../hooks';
|
import { BatchUpdates, DispatchUiEvent, UseMessageEventHook, UseRoomEngineEvent, UseUiEvent } from '../../hooks';
|
||||||
import { AvatarImageView } from '../../views/shared/avatar-image/AvatarImageView';
|
import { AvatarImageView } from '../../views/shared/avatar-image/AvatarImageView';
|
||||||
import { ItemCountView } from '../../views/shared/item-count/ItemCountView';
|
|
||||||
import { ToolbarViewItems } from './common/ToolbarViewItems';
|
import { ToolbarViewItems } from './common/ToolbarViewItems';
|
||||||
import { ToolbarMeView } from './ToolbarMeView';
|
import { ToolbarMeView } from './ToolbarMeView';
|
||||||
|
|
||||||
@ -199,7 +198,7 @@ export const ToolbarView: FC<ToolbarViewProps> = props =>
|
|||||||
<Flex center pointer className={ 'navigation-item item-avatar ' + (isMeExpanded ? 'active ' : '') } onClick={ event => setMeExpanded(!isMeExpanded) }>
|
<Flex center pointer className={ 'navigation-item item-avatar ' + (isMeExpanded ? 'active ' : '') } onClick={ event => setMeExpanded(!isMeExpanded) }>
|
||||||
<AvatarImageView figure={ userFigure } direction={ 2 } />
|
<AvatarImageView figure={ userFigure } direction={ 2 } />
|
||||||
{ (unseenAchievementCount > 0) &&
|
{ (unseenAchievementCount > 0) &&
|
||||||
<ItemCountView count={ unseenAchievementCount } /> }
|
<LayoutItemCountView count={ unseenAchievementCount } /> }
|
||||||
</Flex>
|
</Flex>
|
||||||
{ isInRoom &&
|
{ isInRoom &&
|
||||||
<Base pointer className="navigation-item icon icon-habbo" onClick={ visitDesktop } /> }
|
<Base pointer className="navigation-item icon icon-habbo" onClick={ visitDesktop } /> }
|
||||||
@ -209,7 +208,7 @@ export const ToolbarView: FC<ToolbarViewProps> = props =>
|
|||||||
<Base pointer className="navigation-item icon icon-catalog" onClick={ event => handleToolbarItemClick(ToolbarViewItems.CATALOG_ITEM) } />
|
<Base pointer className="navigation-item icon icon-catalog" onClick={ event => handleToolbarItemClick(ToolbarViewItems.CATALOG_ITEM) } />
|
||||||
<Base pointer className="navigation-item icon icon-inventory" onClick={ event => handleToolbarItemClick(ToolbarViewItems.INVENTORY_ITEM) }>
|
<Base pointer className="navigation-item icon icon-inventory" onClick={ event => handleToolbarItemClick(ToolbarViewItems.INVENTORY_ITEM) }>
|
||||||
{ (unseenInventoryCount > 0) &&
|
{ (unseenInventoryCount > 0) &&
|
||||||
<ItemCountView count={ unseenInventoryCount } /> }
|
<LayoutItemCountView count={ unseenInventoryCount } /> }
|
||||||
</Base>
|
</Base>
|
||||||
{ isInRoom &&
|
{ isInRoom &&
|
||||||
<Base pointer className="navigation-item icon icon-camera" onClick={ event => handleToolbarItemClick(ToolbarViewItems.CAMERA_ITEM) } /> }
|
<Base pointer className="navigation-item icon icon-camera" onClick={ event => handleToolbarItemClick(ToolbarViewItems.CAMERA_ITEM) } /> }
|
||||||
@ -222,7 +221,7 @@ export const ToolbarView: FC<ToolbarViewProps> = props =>
|
|||||||
<Flex gap={ 2 }>
|
<Flex gap={ 2 }>
|
||||||
<Base pointer className="navigation-item icon icon-friendall" onClick={ event => handleToolbarItemClick(ToolbarViewItems.FRIEND_LIST_ITEM) }>
|
<Base pointer className="navigation-item icon icon-friendall" onClick={ event => handleToolbarItemClick(ToolbarViewItems.FRIEND_LIST_ITEM) }>
|
||||||
{ (unseenFriendRequestCount > 0) &&
|
{ (unseenFriendRequestCount > 0) &&
|
||||||
<ItemCountView count={ unseenFriendRequestCount } /> }
|
<LayoutItemCountView count={ unseenFriendRequestCount } /> }
|
||||||
</Base>
|
</Base>
|
||||||
{ ((chatIconType === CHAT_ICON_SHOWING) || (chatIconType === CHAT_ICON_UNREAD)) &&
|
{ ((chatIconType === CHAT_ICON_SHOWING) || (chatIconType === CHAT_ICON_UNREAD)) &&
|
||||||
<Base pointer className={ `navigation-item icon icon-message ${ (chatIconType === CHAT_ICON_UNREAD) && 'is-unread' }` } onClick={ event => handleToolbarItemClick(ToolbarViewItems.FRIEND_CHAT_ITEM) } /> }
|
<Base pointer className={ `navigation-item icon icon-message ${ (chatIconType === CHAT_ICON_UNREAD) && 'is-unread' }` } onClick={ event => handleToolbarItemClick(ToolbarViewItems.FRIEND_CHAT_ITEM) } /> }
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
import { FollowFriendMessageComposer, ILinkEventTracker, NewConsoleMessageEvent, RoomInviteEvent, SendMessageComposer as SendMessageComposerPacket } from '@nitrots/nitro-renderer';
|
import { FollowFriendMessageComposer, ILinkEventTracker, NewConsoleMessageEvent, RoomInviteEvent, SendMessageComposer as SendMessageComposerPacket } from '@nitrots/nitro-renderer';
|
||||||
import { FC, KeyboardEvent, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
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 { 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 { FriendsMessengerIconEvent } from '../../../../events';
|
||||||
import { BatchUpdates, DispatchUiEvent, UseMessageEventHook } from '../../../../hooks';
|
import { BatchUpdates, DispatchUiEvent, UseMessageEventHook } from '../../../../hooks';
|
||||||
import { AvatarImageView } from '../../../shared/avatar-image/AvatarImageView';
|
import { AvatarImageView } from '../../../shared/avatar-image/AvatarImageView';
|
||||||
import { BadgeImageView } from '../../../shared/badge-image/BadgeImageView';
|
import { BadgeImageView } from '../../../shared/badge-image/BadgeImageView';
|
||||||
import { ItemCountView } from '../../../shared/item-count/ItemCountView';
|
|
||||||
import { MessengerThread } from '../../common/MessengerThread';
|
import { MessengerThread } from '../../common/MessengerThread';
|
||||||
import { MessengerThreadChat } from '../../common/MessengerThreadChat';
|
import { MessengerThreadChat } from '../../common/MessengerThreadChat';
|
||||||
import { useFriendsContext } from '../../FriendsContext';
|
import { useFriendsContext } from '../../FriendsContext';
|
||||||
@ -267,7 +266,7 @@ export const FriendsMessengerView: FC<{}> = props =>
|
|||||||
return (
|
return (
|
||||||
<Flex key={index} className={`open-chat-entry p-1 cursor-pointer rounded ${activeThreadIndex === messageThreadIndex ? 'active' : ''}`} onClick={event => setActiveThreadIndex(messageThreadIndex)}>
|
<Flex key={index} className={`open-chat-entry p-1 cursor-pointer rounded ${activeThreadIndex === messageThreadIndex ? 'active' : ''}`} onClick={event => setActiveThreadIndex(messageThreadIndex)}>
|
||||||
{thread.unread &&
|
{thread.unread &&
|
||||||
<ItemCountView count={ thread.unreadCount }/>
|
<LayoutItemCountView count={ thread.unreadCount }/>
|
||||||
}
|
}
|
||||||
<div className="friend-head rounded flex-shrink-0">
|
<div className="friend-head rounded flex-shrink-0">
|
||||||
|
|
||||||
|
@ -5,4 +5,3 @@
|
|||||||
@import "./pet-image/PetImage";
|
@import "./pet-image/PetImage";
|
||||||
@import "./rarity-level/RarityLevelView";
|
@import "./rarity-level/RarityLevelView";
|
||||||
@import "./room-previewer/RoomPreviewerView";
|
@import "./room-previewer/RoomPreviewerView";
|
||||||
@import "./item-count/ItemCountView";
|
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
.nitro-item-count {
|
|
||||||
top: 2px;
|
|
||||||
right: 2px;
|
|
||||||
font-size: 8px;
|
|
||||||
z-index: 1;
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
import { FC } from 'react';
|
|
||||||
|
|
||||||
interface ItemCountViewProps
|
|
||||||
{
|
|
||||||
count: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const ItemCountView: FC<ItemCountViewProps> = props =>
|
|
||||||
{
|
|
||||||
const { count = 0 } = props;
|
|
||||||
|
|
||||||
return <div className="position-absolute badge border bg-danger px-1 rounded-circle nitro-item-count">{ count }</div>
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user