Add new kind of system message with red text
This commit is contained in:
parent
342373bdfe
commit
77e196279c
4 changed files with 89 additions and 7 deletions
|
@ -291,10 +291,31 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
&--error {
|
&--error {
|
||||||
|
.SystemMessage__contents::before {
|
||||||
|
@include light-theme {
|
||||||
|
background-color: $color-accent-red;
|
||||||
|
}
|
||||||
|
@include dark-theme {
|
||||||
|
background-color: $color-accent-red;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&--danger {
|
||||||
|
@include light-theme {
|
||||||
color: $color-accent-red;
|
color: $color-accent-red;
|
||||||
|
}
|
||||||
|
@include dark-theme {
|
||||||
|
color: $color-accent-red;
|
||||||
|
}
|
||||||
|
|
||||||
.SystemMessage__contents::before {
|
.SystemMessage__contents::before {
|
||||||
background: $color-accent-red;
|
@include light-theme {
|
||||||
|
background-color: $color-accent-red;
|
||||||
|
}
|
||||||
|
@include dark-theme {
|
||||||
|
background-color: $color-accent-red;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import type { ReactNode } from 'react';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { noop } from 'lodash';
|
import { noop } from 'lodash';
|
||||||
|
|
||||||
import { SystemMessage } from './SystemMessage';
|
import { SystemMessage, SystemMessageKind } from './SystemMessage';
|
||||||
import { Button, ButtonSize, ButtonVariant } from '../Button';
|
import { Button, ButtonSize, ButtonVariant } from '../Button';
|
||||||
import { MessageTimestamp } from './MessageTimestamp';
|
import { MessageTimestamp } from './MessageTimestamp';
|
||||||
import type { LocalizerType } from '../../types/Util';
|
import type { LocalizerType } from '../../types/Util';
|
||||||
|
@ -80,7 +80,7 @@ export const CallingNotification: React.FC<PropsType> = React.memo(
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
icon={icon}
|
icon={icon}
|
||||||
isError={wasMissed}
|
kind={wasMissed ? SystemMessageKind.Danger : SystemMessageKind.Normal}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
51
ts/components/conversation/SystemMessage.stories.tsx
Normal file
51
ts/components/conversation/SystemMessage.stories.tsx
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
// Copyright 2023 Signal Messenger, LLC
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
|
import * as React from 'react';
|
||||||
|
import { SystemMessage, SystemMessageKind } from './SystemMessage';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
title: 'Components/Conversation/SystemMessage',
|
||||||
|
};
|
||||||
|
|
||||||
|
export function PlainSystemMessage(): JSX.Element {
|
||||||
|
return (
|
||||||
|
<SystemMessage
|
||||||
|
icon="audio-incoming"
|
||||||
|
contents="Some nice text"
|
||||||
|
kind={SystemMessageKind.Normal}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
PlainSystemMessage.story = {
|
||||||
|
name: 'Plain',
|
||||||
|
};
|
||||||
|
|
||||||
|
export function DangerSystemMessage(): JSX.Element {
|
||||||
|
return (
|
||||||
|
<SystemMessage
|
||||||
|
icon="audio-missed"
|
||||||
|
contents="Some loud danger text"
|
||||||
|
kind={SystemMessageKind.Danger}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
DangerSystemMessage.story = {
|
||||||
|
name: 'Danger',
|
||||||
|
};
|
||||||
|
|
||||||
|
export function ErrorSystemMessage(): JSX.Element {
|
||||||
|
return (
|
||||||
|
<SystemMessage
|
||||||
|
icon="unsupported"
|
||||||
|
contents="Some error text"
|
||||||
|
kind={SystemMessageKind.Error}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
ErrorSystemMessage.story = {
|
||||||
|
name: 'Error',
|
||||||
|
};
|
|
@ -5,20 +5,30 @@ import type { ReactNode } from 'react';
|
||||||
import React, { forwardRef } from 'react';
|
import React, { forwardRef } from 'react';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
|
||||||
|
export enum SystemMessageKind {
|
||||||
|
Normal = 'Normal',
|
||||||
|
Danger = 'Danger',
|
||||||
|
Error = 'Error',
|
||||||
|
}
|
||||||
|
|
||||||
type PropsType = {
|
type PropsType = {
|
||||||
icon: string;
|
icon: string;
|
||||||
contents: ReactNode;
|
contents: ReactNode;
|
||||||
button?: ReactNode;
|
button?: ReactNode;
|
||||||
isError?: boolean;
|
kind?: SystemMessageKind;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const SystemMessage = forwardRef<HTMLDivElement, PropsType>(
|
export const SystemMessage = forwardRef<HTMLDivElement, PropsType>(
|
||||||
function SystemMessageInner({ icon, contents, button, isError }, ref) {
|
function SystemMessageInner(
|
||||||
|
{ icon, contents, button, kind = SystemMessageKind.Normal },
|
||||||
|
ref
|
||||||
|
) {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={classNames(
|
className={classNames(
|
||||||
'SystemMessage',
|
'SystemMessage',
|
||||||
isError && 'SystemMessage--error'
|
kind === SystemMessageKind.Danger && 'SystemMessage--danger',
|
||||||
|
kind === SystemMessageKind.Error && 'SystemMessage--error'
|
||||||
)}
|
)}
|
||||||
ref={ref}
|
ref={ref}
|
||||||
>
|
>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue