mirror of
https://github.com/owncast/owncast.git
synced 2024-11-29 11:39:08 +03:00
Break out name change message to own component + fix text color. Closes #2718
This commit is contained in:
parent
47b2d917d5
commit
05a06796e2
5 changed files with 75 additions and 44 deletions
|
@ -14,23 +14,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.nameChangeView {
|
|
||||||
display: flex;
|
|
||||||
font-size: 0.9rem;
|
|
||||||
border-radius: var(--theme-rounded-corners);
|
|
||||||
padding: 5px 15px;
|
|
||||||
color: var(--theme-color-components-text-on-light);
|
|
||||||
background-color: var(--color-owncast-background);
|
|
||||||
& .nameChangeText {
|
|
||||||
font-weight: bold;
|
|
||||||
font-family: var(--theme-text-display-font-family);
|
|
||||||
& .plain {
|
|
||||||
font-weight: normal;
|
|
||||||
font-family: var(--theme-text-body-font-family) !important;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.chatContainer {
|
.chatContainer {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import { Virtuoso } from 'react-virtuoso';
|
import { Virtuoso } from 'react-virtuoso';
|
||||||
import { useState, useMemo, useRef, CSSProperties, FC, useEffect } from 'react';
|
import { useState, useMemo, useRef, CSSProperties, FC, useEffect } from 'react';
|
||||||
import dynamic from 'next/dynamic';
|
|
||||||
import {
|
import {
|
||||||
ConnectedClientInfoEvent,
|
ConnectedClientInfoEvent,
|
||||||
FediverseEvent,
|
FediverseEvent,
|
||||||
|
@ -17,12 +16,7 @@ import { ChatJoinMessage } from '../ChatJoinMessage/ChatJoinMessage';
|
||||||
import { ScrollToBotBtn } from './ScrollToBotBtn';
|
import { ScrollToBotBtn } from './ScrollToBotBtn';
|
||||||
import { ChatActionMessage } from '../ChatActionMessage/ChatActionMessage';
|
import { ChatActionMessage } from '../ChatActionMessage/ChatActionMessage';
|
||||||
import { ChatSocialMessage } from '../ChatSocialMessage/ChatSocialMessage';
|
import { ChatSocialMessage } from '../ChatSocialMessage/ChatSocialMessage';
|
||||||
|
import { ChatNameChangeMessage } from '../ChatNameChangeMessage/ChatNameChangeMessage';
|
||||||
// Lazy loaded components
|
|
||||||
|
|
||||||
const EditFilled = dynamic(() => import('@ant-design/icons/EditFilled'), {
|
|
||||||
ssr: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
export type ChatContainerProps = {
|
export type ChatContainerProps = {
|
||||||
messages: ChatMessage[];
|
messages: ChatMessage[];
|
||||||
|
@ -108,25 +102,6 @@ export const ChatContainer: FC<ChatContainerProps> = ({
|
||||||
[],
|
[],
|
||||||
);
|
);
|
||||||
|
|
||||||
const getNameChangeViewForMessage = (message: NameChangeEvent) => {
|
|
||||||
const { oldName, user } = message;
|
|
||||||
const { displayName, displayColor } = user;
|
|
||||||
const color = `var(--theme-color-users-${displayColor})`;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className={styles.nameChangeView}>
|
|
||||||
<div style={{ marginRight: 5, height: 'max-content', margin: 'auto 5px auto 0' }}>
|
|
||||||
<EditFilled />
|
|
||||||
</div>
|
|
||||||
<div className={styles.nameChangeText}>
|
|
||||||
<span style={{ color }}>{oldName}</span>
|
|
||||||
<span className={styles.plain}> is now known as </span>
|
|
||||||
<span style={{ color }}>{displayName}</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const getFediverseMessage = (message: FediverseEvent) => <ChatSocialMessage message={message} />;
|
const getFediverseMessage = (message: FediverseEvent) => <ChatSocialMessage message={message} />;
|
||||||
|
|
||||||
const getUserJoinedMessage = (message: ChatMessage) => {
|
const getUserJoinedMessage = (message: ChatMessage) => {
|
||||||
|
@ -181,7 +156,7 @@ export const ChatContainer: FC<ChatContainerProps> = ({
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
case MessageType.NAME_CHANGE:
|
case MessageType.NAME_CHANGE:
|
||||||
return getNameChangeViewForMessage(message as NameChangeEvent);
|
return <ChatNameChangeMessage message={message as NameChangeEvent} />;
|
||||||
case MessageType.CONNECTED_USER_INFO:
|
case MessageType.CONNECTED_USER_INFO:
|
||||||
return getConnectedInfoMessage(message as ConnectedClientInfoEvent);
|
return getConnectedInfoMessage(message as ConnectedClientInfoEvent);
|
||||||
case MessageType.USER_JOINED:
|
case MessageType.USER_JOINED:
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
.nameChangeView {
|
||||||
|
display: flex;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
border-radius: var(--theme-rounded-corners);
|
||||||
|
padding: 5px 15px;
|
||||||
|
color: var(--theme-color-components-chat-text);
|
||||||
|
& .nameChangeText {
|
||||||
|
font-weight: bold;
|
||||||
|
font-family: var(--theme-text-display-font-family);
|
||||||
|
& .plain {
|
||||||
|
font-weight: normal;
|
||||||
|
font-family: var(--theme-text-body-font-family) !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
import React from 'react';
|
||||||
|
import { ComponentStory, ComponentMeta } from '@storybook/react';
|
||||||
|
import { ChatNameChangeMessage } from './ChatNameChangeMessage';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
title: 'owncast/Chat/Messages/Chat name change',
|
||||||
|
component: ChatNameChangeMessage,
|
||||||
|
} as ComponentMeta<typeof ChatNameChangeMessage>;
|
||||||
|
|
||||||
|
const Template: ComponentStory<typeof ChatNameChangeMessage> = args => (
|
||||||
|
<ChatNameChangeMessage {...args} />
|
||||||
|
);
|
||||||
|
|
||||||
|
export const Basic = Template.bind({});
|
||||||
|
Basic.args = {
|
||||||
|
message: {
|
||||||
|
oldName: 'JohnnyOldName',
|
||||||
|
user: {
|
||||||
|
displayName: 'JohnnyNewName',
|
||||||
|
displayColor: '3',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
|
@ -0,0 +1,35 @@
|
||||||
|
// export const ChatSocialMessage: FC<ChatSocialMessageProps> = ({ message }) => {
|
||||||
|
|
||||||
|
import dynamic from 'next/dynamic';
|
||||||
|
import { FC } from 'react';
|
||||||
|
import { NameChangeEvent } from '../../../interfaces/socket-events';
|
||||||
|
import styles from './ChatNameChangeMessage.module.scss';
|
||||||
|
|
||||||
|
export interface ChatNameChangeMessageProps {
|
||||||
|
message: NameChangeEvent;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lazy loaded components
|
||||||
|
|
||||||
|
const EditFilled = dynamic(() => import('@ant-design/icons/EditFilled'), {
|
||||||
|
ssr: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
export const ChatNameChangeMessage: FC<ChatNameChangeMessageProps> = ({ message }) => {
|
||||||
|
const { oldName, user } = message;
|
||||||
|
const { displayName, displayColor } = user;
|
||||||
|
const color = `var(--theme-color-users-${displayColor})`;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={styles.nameChangeView}>
|
||||||
|
<div style={{ marginRight: 5, height: 'max-content', margin: 'auto 5px auto 0' }}>
|
||||||
|
<EditFilled />
|
||||||
|
</div>
|
||||||
|
<div className={styles.nameChangeText}>
|
||||||
|
<span style={{ color }}>{oldName}</span>
|
||||||
|
<span className={styles.plain}> is now known as </span>
|
||||||
|
<span style={{ color }}>{displayName}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
Loading…
Reference in a new issue