Redesign the user badges (authed, mods)
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import { FC } from 'react';
|
import { FC } from 'react';
|
||||||
import dynamic from 'next/dynamic';
|
import dynamic from 'next/dynamic';
|
||||||
import { ChatUserBadge } from '../ChatUserBadge/ChatUserBadge';
|
|
||||||
import styles from './ChatJoinMessage.module.scss';
|
import styles from './ChatJoinMessage.module.scss';
|
||||||
|
import { ModerationBadge } from '../ChatUserBadge/ModerationBadge';
|
||||||
|
|
||||||
// Lazy loaded components
|
// Lazy loaded components
|
||||||
|
|
||||||
@@ -31,7 +31,7 @@ export const ChatJoinMessage: FC<ChatJoinMessageProps> = ({
|
|||||||
<span style={{ fontWeight: 'bold' }}>{displayName}</span>
|
<span style={{ fontWeight: 'bold' }}>{displayName}</span>
|
||||||
{isAuthorModerator && (
|
{isAuthorModerator && (
|
||||||
<span>
|
<span>
|
||||||
<ChatUserBadge badge="mod" userColor={userColor} />
|
<ModerationBadge userColor={userColor} />
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
</span>{' '}
|
</span>{' '}
|
||||||
|
|||||||
17
web/components/chat/ChatUserBadge/AuthedUserBadge.tsx
Normal file
17
web/components/chat/ChatUserBadge/AuthedUserBadge.tsx
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import dynamic from 'next/dynamic';
|
||||||
|
import React, { FC } from 'react';
|
||||||
|
import { ChatUserBadge } from './ChatUserBadge';
|
||||||
|
|
||||||
|
// Lazy loaded components
|
||||||
|
|
||||||
|
const SafetyCertificateFilled = dynamic(() => import('@ant-design/icons/SafetyCertificateFilled'), {
|
||||||
|
ssr: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
export type AuthedUserBadgeProps = {
|
||||||
|
userColor: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const AuthedUserBadge: FC<AuthedUserBadgeProps> = ({ userColor }) => (
|
||||||
|
<ChatUserBadge badge={<SafetyCertificateFilled />} userColor={userColor} title="Moderator" />
|
||||||
|
);
|
||||||
@@ -1,13 +1,15 @@
|
|||||||
.badge {
|
.badge {
|
||||||
font-family: var(--theme-text-display-font-family);
|
color: white;
|
||||||
font-weight: 500;
|
background-color: var(--color-owncast-palette-0);
|
||||||
font-size: 0.5rem;
|
height: 18px;
|
||||||
text-transform: uppercase;
|
width: 18px;
|
||||||
|
border-radius: 2px;
|
||||||
|
text-align: center;
|
||||||
padding: 2px;
|
padding: 2px;
|
||||||
padding-top: 0px;
|
display: flex;
|
||||||
padding-bottom: 0px;
|
justify-content: center;
|
||||||
border-radius: 3px;
|
align-items: center;
|
||||||
border-width: 1px;
|
overflow: hidden;
|
||||||
border-style: solid;
|
margin-left: 5px;
|
||||||
margin-left: 3px;
|
font-size: 0.75rem;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { ComponentStory, ComponentMeta } from '@storybook/react';
|
import { ComponentStory, ComponentMeta } from '@storybook/react';
|
||||||
import { ChatUserBadge } from './ChatUserBadge';
|
import { ChatUserBadge } from './ChatUserBadge';
|
||||||
|
import { ModerationBadge } from './ModerationBadge';
|
||||||
|
import { AuthedUserBadge } from './AuthedUserBadge';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
title: 'owncast/Chat/Messages/User Flag',
|
title: 'owncast/Chat/Messages/User Flag',
|
||||||
@@ -14,15 +16,26 @@ export default {
|
|||||||
} as ComponentMeta<typeof ChatUserBadge>;
|
} as ComponentMeta<typeof ChatUserBadge>;
|
||||||
|
|
||||||
const Template: ComponentStory<typeof ChatUserBadge> = args => <ChatUserBadge {...args} />;
|
const Template: ComponentStory<typeof ChatUserBadge> = args => <ChatUserBadge {...args} />;
|
||||||
|
const ModerationTemplate: ComponentStory<typeof ModerationBadge> = args => (
|
||||||
|
<ModerationBadge {...args} />
|
||||||
|
);
|
||||||
|
|
||||||
export const Moderator = Template.bind({});
|
const AuthedTemplate: ComponentStory<typeof ModerationBadge> = args => (
|
||||||
|
<AuthedUserBadge {...args} />
|
||||||
|
);
|
||||||
|
|
||||||
|
export const Authenticated = AuthedTemplate.bind({});
|
||||||
|
Authenticated.args = {
|
||||||
|
userColor: '3',
|
||||||
|
};
|
||||||
|
|
||||||
|
export const Moderator = ModerationTemplate.bind({});
|
||||||
Moderator.args = {
|
Moderator.args = {
|
||||||
badge: 'mod',
|
|
||||||
userColor: '5',
|
userColor: '5',
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Authenticated = Template.bind({});
|
export const Generic = Template.bind({});
|
||||||
Authenticated.args = {
|
Generic.args = {
|
||||||
badge: 'auth',
|
badge: '?',
|
||||||
userColor: '6',
|
userColor: '6',
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4,14 +4,15 @@ import styles from './ChatUserBadge.module.scss';
|
|||||||
export type ChatUserBadgeProps = {
|
export type ChatUserBadgeProps = {
|
||||||
badge: React.ReactNode;
|
badge: React.ReactNode;
|
||||||
userColor: number;
|
userColor: number;
|
||||||
|
title: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const ChatUserBadge: FC<ChatUserBadgeProps> = ({ badge, userColor }) => {
|
export const ChatUserBadge: FC<ChatUserBadgeProps> = ({ badge, userColor, title }) => {
|
||||||
const color = `var(--theme-user-colors-${userColor})`;
|
const color = `var(--theme-color-users-${userColor})`;
|
||||||
const style = { color, borderColor: color };
|
const style = { color };
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<span style={style} className={styles.badge}>
|
<span style={style} className={styles.badge} title={title}>
|
||||||
{badge}
|
{badge}
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
|
|||||||
17
web/components/chat/ChatUserBadge/ModerationBadge.tsx
Normal file
17
web/components/chat/ChatUserBadge/ModerationBadge.tsx
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import dynamic from 'next/dynamic';
|
||||||
|
import React, { FC } from 'react';
|
||||||
|
import { ChatUserBadge } from './ChatUserBadge';
|
||||||
|
|
||||||
|
// Lazy loaded components
|
||||||
|
|
||||||
|
const StarFilled = dynamic(() => import('@ant-design/icons/StarFilled'), {
|
||||||
|
ssr: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
export type ModerationBadgeProps = {
|
||||||
|
userColor: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const ModerationBadge: FC<ModerationBadgeProps> = ({ userColor }) => (
|
||||||
|
<ChatUserBadge badge={<StarFilled />} userColor={userColor} title="Moderator" />
|
||||||
|
);
|
||||||
@@ -9,16 +9,13 @@ import linkifyHtml from 'linkify-html';
|
|||||||
import styles from './ChatUserMessage.module.scss';
|
import styles from './ChatUserMessage.module.scss';
|
||||||
import { formatTimestamp } from './messageFmt';
|
import { formatTimestamp } from './messageFmt';
|
||||||
import { ChatMessage } from '../../../interfaces/chat-message.model';
|
import { ChatMessage } from '../../../interfaces/chat-message.model';
|
||||||
import { ChatUserBadge } from '../ChatUserBadge/ChatUserBadge';
|
|
||||||
import { accessTokenAtom } from '../../stores/ClientConfigStore';
|
import { accessTokenAtom } from '../../stores/ClientConfigStore';
|
||||||
import { User } from '../../../interfaces/user.model';
|
import { User } from '../../../interfaces/user.model';
|
||||||
|
import { AuthedUserBadge } from '../ChatUserBadge/AuthedUserBadge';
|
||||||
|
import { ModerationBadge } from '../ChatUserBadge/ModerationBadge';
|
||||||
|
|
||||||
// Lazy loaded components
|
// Lazy loaded components
|
||||||
|
|
||||||
const LinkOutlined = dynamic(() => import('@ant-design/icons/LinkOutlined'), {
|
|
||||||
ssr: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
const ChatModerationActionMenu = dynamic(
|
const ChatModerationActionMenu = dynamic(
|
||||||
() =>
|
() =>
|
||||||
import('../ChatModerationActionMenu/ChatModerationActionMenu').then(
|
import('../ChatModerationActionMenu/ChatModerationActionMenu').then(
|
||||||
@@ -78,16 +75,10 @@ export const ChatUserMessage: FC<ChatUserMessageProps> = ({
|
|||||||
|
|
||||||
const badgeNodes = [];
|
const badgeNodes = [];
|
||||||
if (isAuthorModerator) {
|
if (isAuthorModerator) {
|
||||||
badgeNodes.push(<ChatUserBadge key="mod" badge="mod" userColor={displayColor} />);
|
badgeNodes.push(<ModerationBadge key="mod" userColor={displayColor} />);
|
||||||
}
|
}
|
||||||
if (isAuthorAuthenticated) {
|
if (isAuthorAuthenticated) {
|
||||||
badgeNodes.push(
|
badgeNodes.push(<AuthedUserBadge key="auth" userColor={displayColor} />);
|
||||||
<ChatUserBadge
|
|
||||||
key="auth"
|
|
||||||
badge={<LinkOutlined title="authenticated" />}
|
|
||||||
userColor={displayColor}
|
|
||||||
/>,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user