Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added search instruction to Search Messages sidebar #910

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import NoMessagesIndicator from './NoMessageIndicator';
import FileDisplay from '../../FileMessage/FileMessage';
import useSetExclusiveState from '../../../hooks/useSetExclusiveState';
import { useRCContext } from '../../../context/RCInstance';
import searchNote from '../data/searchMessageNote';
import { Markdown } from '../../Markdown';

export const MessageAggregator = ({
title,
Expand All @@ -33,7 +35,8 @@ export const MessageAggregator = ({
viewType = 'Sidebar',
}) => {
const { theme } = useTheme();
const styles = getMessageAggregatorStyles(theme);
const { mode } = useTheme();
const styles = getMessageAggregatorStyles(theme, mode);
const setExclusiveState = useSetExclusiveState();
const { ECOptions } = useRCContext();
const showRoles = ECOptions?.showRoles;
Expand Down Expand Up @@ -109,6 +112,8 @@ export const MessageAggregator = ({
const noMessages = messageList?.length === 0 || !messageRendered;
const ViewComponent = viewType === 'Popup' ? Popup : Sidebar;

const showSearchNote = title === 'Search Messages';

return (
<ViewComponent
title={title}
Expand All @@ -127,6 +132,16 @@ export const MessageAggregator = ({
}
: {})}
>
{showSearchNote && (
<Box css={styles.noteStyle}>
<Markdown
body={searchNote.msg}
md={searchNote.md}
isReaction={false}
/>
</Box>
)}

{fetching || loading ? (
<LoadingIndicator />
) : (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { css } from '@emotion/react';
import { lighten, darken } from '@embeddedchat/ui-elements';

const getMessageAggregatorStyles = () => {
const getMessageAggregatorStyles = (theme, mode) => {
const styles = {
listContainerStyles: css`
flex: 1;
Expand All @@ -21,6 +22,15 @@ const getMessageAggregatorStyles = () => {
flex-direction: column;
align-items: center;
`,

noteStyle: css`
margin-left: 16px;
margin-right: 16px;
font-size: 0.875rem;
color: ${mode === 'light'
? lighten(theme?.colors.foreground, 8)
: darken(theme?.colors.foreground, 0.3)};
`,
};

return styles;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const searchNote = {
msg: 'You can search using [Regular Expression](https://en.wikipedia.org/wiki/Regular_expression). e.g. `/^text$/i`',
md: [
{
type: 'PARAGRAPH',
value: [
{
type: 'PLAIN_TEXT',
value: 'You can search using ',
},
{
type: 'LINK',
value: {
src: {
type: 'PLAIN_TEXT',
value: 'https://en.wikipedia.org/wiki/Regular_expression',
},
label: [
{
type: 'PLAIN_TEXT',
value: 'Regular Expression',
},
],
},
},
{
type: 'PLAIN_TEXT',
value: '. e.g. ',
},
{
type: 'INLINE_CODE',
value: {
type: 'PLAIN_TEXT',
value: '/^text$/i',
},
},
],
},
],
};

export default searchNote;
Loading