mirror of
https://github.com/billsonnn/nitro-react.git
synced 2025-01-31 18:32:36 +01:00
different notifications n sizes
This commit is contained in:
parent
250a373824
commit
03d176b53a
@ -35,6 +35,11 @@ export class NotificationAlertItem
|
|||||||
return this._messages;
|
return this._messages;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public set alertType(alertType: string)
|
||||||
|
{
|
||||||
|
this._alertType = alertType;
|
||||||
|
}
|
||||||
|
|
||||||
public get alertType(): string
|
public get alertType(): string
|
||||||
{
|
{
|
||||||
return this._alertType;
|
return this._alertType;
|
||||||
|
@ -6,4 +6,5 @@ export class NotificationAlertType
|
|||||||
public static EVENT: string = 'event';
|
public static EVENT: string = 'event';
|
||||||
public static NITRO: string = 'nitro';
|
public static NITRO: string = 'nitro';
|
||||||
public static SEARCH: string = 'search';
|
public static SEARCH: string = 'search';
|
||||||
|
public static ALERT: string = 'alert';
|
||||||
}
|
}
|
||||||
|
@ -137,7 +137,7 @@ export class NotificationUtilities
|
|||||||
|
|
||||||
public static showModeratorMessage(message: string, url: string = null, showHabboWay: boolean = true): void
|
public static showModeratorMessage(message: string, url: string = null, showHabboWay: boolean = true): void
|
||||||
{
|
{
|
||||||
this.simpleAlert(message, NotificationAlertType.MODERATION, url, LocalizeText('mod.alert.link'), LocalizeText('mod.alert.title'));
|
this.simpleAlert(message, NotificationAlertType.DEFAULT, url, LocalizeText('mod.alert.link'), LocalizeText('mod.alert.title'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static handleModeratorCaution(message: string, url: string = null): void
|
public static handleModeratorCaution(message: string, url: string = null): void
|
||||||
|
@ -190,25 +190,6 @@
|
|||||||
background-color: rgba($black, .125);
|
background-color: rgba($black, .125);
|
||||||
}
|
}
|
||||||
|
|
||||||
.nitro-alert {
|
|
||||||
min-width: 350px;
|
|
||||||
min-height: 150px;
|
|
||||||
max-height: 350px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.nitro-notification-bubble {
|
|
||||||
pointer-events: all;
|
|
||||||
padding: 6px 5px;
|
|
||||||
background-color: rgba($dark,.95);
|
|
||||||
box-shadow: inset 0px 5px lighten(rgba($dark,.6),2.5), inset 0 -4px darken(rgba($dark,.6),4);
|
|
||||||
font-size: $font-size-sm;
|
|
||||||
|
|
||||||
.bubble-image-container {
|
|
||||||
width: 50px;
|
|
||||||
height: 50px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#draggable-windows-container {
|
#draggable-windows-container {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
|
@ -1,24 +1,28 @@
|
|||||||
import { FC, useMemo } from 'react';
|
import { FC, useMemo } from 'react';
|
||||||
|
import { NotificationAlertType } from '../../api';
|
||||||
import { NitroCardContentView, NitroCardHeaderView, NitroCardView, NitroCardViewProps } from '../card';
|
import { NitroCardContentView, NitroCardHeaderView, NitroCardView, NitroCardViewProps } from '../card';
|
||||||
|
|
||||||
export interface LayoutNotificationAlertViewProps extends NitroCardViewProps
|
export interface LayoutNotificationAlertViewProps extends NitroCardViewProps
|
||||||
{
|
{
|
||||||
title?: string;
|
title?: string;
|
||||||
|
type?: string;
|
||||||
close: () => void;
|
close: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const LayoutNotificationAlertView: FC<LayoutNotificationAlertViewProps> = props =>
|
export const LayoutNotificationAlertView: FC<LayoutNotificationAlertViewProps> = props =>
|
||||||
{
|
{
|
||||||
const { title = '', close = null, classNames = [], children = null, ...rest } = props;
|
const { title = '', close = null, classNames = [], children = null,type = NotificationAlertType.DEFAULT, ...rest } = props;
|
||||||
|
|
||||||
const getClassNames = useMemo(() =>
|
const getClassNames = useMemo(() =>
|
||||||
{
|
{
|
||||||
const newClassNames: string[] = [ 'nitro-alert' ];
|
const newClassNames: string[] = ['nitro-alert'];
|
||||||
|
|
||||||
|
newClassNames.push('nitro-alert-' + type);
|
||||||
|
|
||||||
if(classNames.length) newClassNames.push(...classNames);
|
if(classNames.length) newClassNames.push(...classNames);
|
||||||
|
|
||||||
return newClassNames;
|
return newClassNames;
|
||||||
}, [ classNames ]);
|
}, [ classNames, type ]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<NitroCardView classNames={ getClassNames } theme="primary-slim" { ...rest }>
|
<NitroCardView classNames={ getClassNames } theme="primary-slim" { ...rest }>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { CatalogPublishedMessageEvent, FrontPageItem, GetCatalogIndexComposer, GetCatalogPageComposer, GetClubGiftInfo, GetGiftWrappingConfigurationComposer, ILinkEventTracker, RoomPreviewer } from '@nitrots/nitro-renderer';
|
import { CatalogPublishedMessageEvent, FrontPageItem, GetCatalogIndexComposer, GetCatalogPageComposer, GetClubGiftInfo, GetGiftWrappingConfigurationComposer, ILinkEventTracker, RoomPreviewer } from '@nitrots/nitro-renderer';
|
||||||
import { FC, useCallback, useEffect, useState } from 'react';
|
import { FC, useCallback, useEffect, useState } from 'react';
|
||||||
import { AddEventLinkTracker, GetRoomEngine, LocalizeText, NotificationUtilities, PlaySound, RemoveLinkEventTracker, SendMessageComposer, SoundNames } from '../../api';
|
import { AddEventLinkTracker, GetRoomEngine, LocalizeText, NotificationAlertType, NotificationUtilities, PlaySound, RemoveLinkEventTracker, SendMessageComposer, SoundNames } from '../../api';
|
||||||
import { Column, Grid, NitroCardContentView, NitroCardHeaderView, NitroCardTabsItemView, NitroCardTabsView, NitroCardView } from '../../common';
|
import { Column, Grid, NitroCardContentView, NitroCardHeaderView, NitroCardTabsItemView, NitroCardTabsView, NitroCardView } from '../../common';
|
||||||
import { CatalogPurchasedEvent } from '../../events';
|
import { CatalogPurchasedEvent } from '../../events';
|
||||||
import { BatchUpdates, UseMessageEventHook, UseUiEvent } from '../../hooks';
|
import { BatchUpdates, UseMessageEventHook, UseUiEvent } from '../../hooks';
|
||||||
@ -65,7 +65,7 @@ export const CatalogView: FC<{}> = props =>
|
|||||||
|
|
||||||
resetState();
|
resetState();
|
||||||
|
|
||||||
if(wasVisible) NotificationUtilities.simpleAlert(LocalizeText('catalog.alert.published.description'), null, null, null, LocalizeText('catalog.alert.published.title'));
|
if(wasVisible) NotificationUtilities.simpleAlert(LocalizeText('catalog.alert.published.description'), NotificationAlertType.ALERT, null, null, LocalizeText('catalog.alert.published.title'));
|
||||||
}, [ isVisible, resetState ]);
|
}, [ isVisible, resetState ]);
|
||||||
|
|
||||||
UseMessageEventHook(CatalogPublishedMessageEvent, onCatalogPublishedMessageEvent);
|
UseMessageEventHook(CatalogPublishedMessageEvent, onCatalogPublishedMessageEvent);
|
||||||
|
@ -14,8 +14,46 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.notification-frank {
|
.nitro-alert {
|
||||||
background-image: url('../../assets/images/notifications/frank.gif');
|
min-height: 150px;
|
||||||
width:47px;
|
max-height: 350px;
|
||||||
height: 85px;
|
|
||||||
|
.notification-frank {
|
||||||
|
background-image: url('../../assets/images/notifications/frank.gif');
|
||||||
|
width:47px;
|
||||||
|
height: 85px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.notification-text {
|
||||||
|
min-width: 250px;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.nitro-alert-default,
|
||||||
|
&.nitro-alert-motd {
|
||||||
|
width: 350px;
|
||||||
|
.notification-text {
|
||||||
|
min-width: auto;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&.nitro-alert-moderation,
|
||||||
|
&.nitro-alert-alert {
|
||||||
|
width: 250px;
|
||||||
|
.notification-text {
|
||||||
|
min-width: 225px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.nitro-notification-bubble {
|
||||||
|
pointer-events: all;
|
||||||
|
padding: 6px 5px;
|
||||||
|
background-color: rgba($dark,.95);
|
||||||
|
box-shadow: inset 0px 5px lighten(rgba($dark,.6),2.5), inset 0 -4px darken(rgba($dark,.6),4);
|
||||||
|
font-size: $font-size-sm;
|
||||||
|
|
||||||
|
.bubble-image-container {
|
||||||
|
width: 50px;
|
||||||
|
height: 50px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ export const GetAlertLayout = (item: NotificationAlertItem, close: () => void) =
|
|||||||
case NotificationAlertType.NITRO:
|
case NotificationAlertType.NITRO:
|
||||||
return <NitroSystemAlertView {...props} />
|
return <NitroSystemAlertView {...props} />
|
||||||
case NotificationAlertType.SEARCH:
|
case NotificationAlertType.SEARCH:
|
||||||
return <NotificationSeachAlertView { ...props } />
|
return <NotificationSeachAlertView {...props} />
|
||||||
default:
|
default:
|
||||||
return <NotificationDefaultAlertView { ...props } />
|
return <NotificationDefaultAlertView { ...props } />
|
||||||
}
|
}
|
||||||
|
@ -18,32 +18,37 @@ export const NotificationDefaultAlertView: FC<NotificationDefaultAlertViewProps>
|
|||||||
NotificationUtilities.openUrl(item.clickUrl);
|
NotificationUtilities.openUrl(item.clickUrl);
|
||||||
|
|
||||||
close();
|
close();
|
||||||
}, [ item, close ]);
|
}, [item, close]);
|
||||||
|
|
||||||
|
const hasFrank = item.alertType === NotificationAlertType.DEFAULT;
|
||||||
const isAction = (item.clickUrl && item.clickUrl.startsWith('event:'));
|
|
||||||
|
|
||||||
const hasFrank = item.alertType === NotificationAlertType.DEFAULT || item.alertType === NotificationAlertType.MODERATION;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<LayoutNotificationAlertView title={title} close={close} {...rest}>
|
<LayoutNotificationAlertView title={title} close={close} {...rest} type={ hasFrank ? NotificationAlertType.DEFAULT : item.alertType }>
|
||||||
<Flex fullHeight overflow="auto" gap={2}>
|
<Flex fullHeight overflow="auto" gap={ hasFrank || (item.imageUrl && !imageFailed) ? 2 : 0 }>
|
||||||
{hasFrank && !item.imageUrl && <Base className="notification-frank flex-shrink-0" /> }
|
{hasFrank && !item.imageUrl && <Base className="notification-frank flex-shrink-0" /> }
|
||||||
{item.imageUrl && !imageFailed && <img src={item.imageUrl} alt={ item.title } onError={() => { setImageFailed(true) } } /> }
|
{item.imageUrl && !imageFailed && <img src={item.imageUrl} alt={item.title} onError={() => { setImageFailed(true) }} className="align-self-baseline" />}
|
||||||
|
<Base classNames={['notification-text overflow-y-auto d-flex flex-column w-100', (item.clickUrl && !hasFrank) ? 'justify-content-center' : '']}>
|
||||||
{ (item.messages.length > 0) && item.messages.map((message, index) =>
|
{ (item.messages.length > 0) && item.messages.map((message, index) =>
|
||||||
{
|
{
|
||||||
const htmlText = message.replace(/\r\n|\r|\n/g, '<br />');
|
const htmlText = message.replace(/\r\n|\r|\n/g, '<br />');
|
||||||
|
|
||||||
return <Base grow fullHeight overflow="auto" key={ index } dangerouslySetInnerHTML={ { __html: htmlText } } />;
|
return <Base key={ index } dangerouslySetInnerHTML={ { __html: htmlText } } />;
|
||||||
})}
|
})}
|
||||||
|
{item.clickUrl && (item.clickUrl.length > 0) && (item.imageUrl && !imageFailed) && <>
|
||||||
|
<hr className="my-2 w-100" />
|
||||||
|
<Button onClick={visitUrl} className="align-self-center px-3">{LocalizeText(item.clickUrlText)}</Button>
|
||||||
|
</>}
|
||||||
|
</Base>
|
||||||
</Flex>
|
</Flex>
|
||||||
<hr className="my-2"/>
|
{ (!item.imageUrl || (item.imageUrl && imageFailed)) && <>
|
||||||
<Column alignItems="center" center gap={ 1 }>
|
<Column alignItems="center" center gap={0}>
|
||||||
{ !isAction && !item.clickUrl &&
|
<hr className="my-2 w-100" />
|
||||||
<Button onClick={ close }>{ LocalizeText('generic.close') }</Button> }
|
{ !item.clickUrl &&
|
||||||
{ item.clickUrl && (item.clickUrl.length > 0) &&
|
<Button onClick={close}>{LocalizeText('generic.close')}</Button>}
|
||||||
<Button onClick={ visitUrl }>{ LocalizeText(item.clickUrlText) }</Button> }
|
{ item.clickUrl && (item.clickUrl.length > 0) && <Button onClick={visitUrl}>{LocalizeText(item.clickUrlText)}</Button> }
|
||||||
</Column>
|
</Column>
|
||||||
|
</> }
|
||||||
</LayoutNotificationAlertView>
|
</LayoutNotificationAlertView>
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { FC } from 'react';
|
import { FC } from 'react';
|
||||||
import { NotificationConfirmItem } from '../../../../api';
|
import { NotificationAlertType, NotificationConfirmItem } from '../../../../api';
|
||||||
import { Button, Flex, LayoutNotificationAlertView, LayoutNotificationAlertViewProps, Text } from '../../../../common';
|
import { Button, Flex, LayoutNotificationAlertView, LayoutNotificationAlertViewProps, Text } from '../../../../common';
|
||||||
|
|
||||||
export interface NotificationDefaultConfirmViewProps extends LayoutNotificationAlertViewProps
|
export interface NotificationDefaultConfirmViewProps extends LayoutNotificationAlertViewProps
|
||||||
@ -27,7 +27,7 @@ export const NotificationDefaultConfirmView: FC<NotificationDefaultConfirmViewPr
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<LayoutNotificationAlertView title={ title } close={ close } { ...rest }>
|
<LayoutNotificationAlertView title={title} close={close} {...rest} type={ NotificationAlertType.ALERT }>
|
||||||
<Flex grow center>
|
<Flex grow center>
|
||||||
<Text>{ message }</Text>
|
<Text>{ message }</Text>
|
||||||
</Flex>
|
</Flex>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user