Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32215054
D7823.1765157653.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D7823.1765157653.diff
View Options
diff --git a/web/chat/edit-text-message.css b/web/chat/edit-text-message.css
new file mode 100644
--- /dev/null
+++ b/web/chat/edit-text-message.css
@@ -0,0 +1,57 @@
+.editMessage {
+ padding: 10px;
+ background-color: var(--shades-black-90);
+ border-radius: 8px;
+}
+
+.bottomRow {
+ padding-top: 10px;
+ display: flex;
+ align-items: center;
+}
+
+.buttons {
+ margin-left: auto;
+ margin-right: 0;
+}
+
+.iconContainer {
+ color: var(--error);
+}
+
+.iconContainer > svg {
+ height: 16px;
+ display: flex;
+}
+
+.failedText {
+ font-size: 13px;
+ white-space: nowrap;
+ flex: 1;
+ align-items: center;
+}
+
+.errorColor {
+ color: var(--error);
+}
+
+.whiteColor {
+ color: var(--fg);
+ margin-left: 2px;
+}
+
+.failedText > div {
+ float: left;
+ margin-right: 2px;
+}
+
+.smallButton {
+ padding: 3px 8px;
+ border-radius: 4px;
+ font-size: 12px;
+ float: right;
+}
+
+.saveButton {
+ margin-left: 8px;
+}
diff --git a/web/chat/edit-text-message.react.js b/web/chat/edit-text-message.react.js
new file mode 100644
--- /dev/null
+++ b/web/chat/edit-text-message.react.js
@@ -0,0 +1,99 @@
+// @flow
+
+import * as React from 'react';
+import { XCircle as XCircleIcon } from 'react-feather';
+
+import type { ChatMessageInfoItem } from 'lib/selectors/chat-selectors.js';
+import { type ThreadInfo } from 'lib/types/thread-types.js';
+
+import cssInputBar from './chat-input-bar.css';
+import ChatInputTextArea from './chat-input-text-area.react.js';
+import ComposedMessage from './composed-message.react.js';
+import { useEditModalContext } from './edit-message-provider.js';
+import css from './edit-text-message.css';
+import type { ButtonColor } from '../components/button.react.js';
+import Button from '../components/button.react.js';
+
+type Props = {
+ +item: ChatMessageInfoItem,
+ +threadInfo: ThreadInfo,
+ +background: boolean,
+ +width: ?number,
+};
+
+const cancelButtonColor: ButtonColor = {
+ backgroundColor: '#00000000',
+};
+
+function EditTextMessage(props: Props): React.Node {
+ const { background, threadInfo } = props;
+ const { editState, clearEditModal } = useEditModalContext();
+
+ const editedMessageDraft = editState?.editedMessageDraft ?? '';
+ const threadColor = threadInfo.color;
+ const saveButtonColor: ButtonColor = React.useMemo(() => {
+ return {
+ backgroundColor: `#${threadColor}`,
+ };
+ }, [threadColor]);
+ let editFailed;
+ if (editState?.isError) {
+ editFailed = (
+ <div className={css.failedText}>
+ <div className={css.iconContainer}>
+ <XCircleIcon />
+ </div>
+ <div className={css.errorColor}>Edit failed.</div>
+ <div className={css.whiteColor}>Please try again.</div>
+ </div>
+ );
+ }
+
+ return (
+ <div className={css.editMessage} style={{ width: props.width }}>
+ <div className={cssInputBar.inputBarTextInput}>
+ <ChatInputTextArea
+ focus={!background}
+ currentText={editedMessageDraft}
+ />
+ </div>
+ <div className={css.bottomRow}>
+ {editFailed}
+ <div className={css.buttons}>
+ <Button
+ className={[css.saveButton, css.smallButton]}
+ variant="filled"
+ buttonColor={saveButtonColor}
+ >
+ Save (enter)
+ </Button>
+ <Button
+ className={css.smallButton}
+ variant="filled"
+ buttonColor={cancelButtonColor}
+ onClick={clearEditModal}
+ >
+ Cancel (esc)
+ </Button>
+ </div>
+ </div>
+ </div>
+ );
+}
+
+const ComposedEditTextMessage: React.ComponentType<Props> = React.memo<Props>(
+ function ComposedEditTextMessage(props) {
+ const { background, width, ...restProps } = props;
+ return (
+ <ComposedMessage
+ {...restProps}
+ sendFailed={false}
+ shouldDisplayPinIndicator={false}
+ >
+ <EditTextMessage {...props} />
+ </ComposedMessage>
+ );
+ },
+);
+
+export { EditTextMessage, ComposedEditTextMessage };
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Dec 8, 1:34 AM (10 h, 35 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5846447
Default Alt Text
D7823.1765157653.diff (3 KB)
Attached To
Mode
D7823: [web] Added EditTextMessage component
Attached
Detach File
Event Timeline
Log In to Comment