Skip to main content

LMMessage

LMMessage renders the message UI. It internally segregates the UI depending of the conversation state.

CSS Classnames

ClassnameDescription
undo-dm-blocked lm-cursor-pointerContainer or element for undo dm blocked lm cursor pointer
lm-chat-cardContainer or element for lm chat card
data-pillContainer or element for data pill
lmUserDataContainer or element for lmUserData
nameContainer or element for name
lm-delete-msgContainer or element for lm delete msg
timeContainer or element for time
lm-chat-message-reactions-holder-plateContainer or element for lm chat message reactions holder plate
lm-mediaContainer or element for lm media
lm-og-tagsContainer or element for lm og tags
lm-og-imgContainer or element for lm og img
lm-og-contentContainer or element for lm og content
lm-og-titleContainer or element for lm og title
lm-og-descContainer or element for lm og desc
lm-reply-wrapperContainer or element for lm reply wrapper
lm-reply-wrapper-contentContainer or element for lm reply wrapper content
lm-reply-wrapper-content-nameContainer or element for lm reply wrapper content name
lm-reply-wrapper-content-msgContainer or element for lm reply wrapper content msg
msgContainer or element for msg
error-messageContainer or element for error message
edited-bulletContainer or element for edited bullet
actionsContainer or element for actions
lm-cursor-pointerContainer or element for lm cursor pointer
lm-add-emojiContainer or element for lm add emoji
lm-date-dataContainer or element for lm date data
conversation senderContainer or element for conversation sender
dmReqBlockContainer or element for dmReqBlock
dmActionsContainer or element for dmActions

Example

To customise the component with their classnames, Open your base css file and override the styles using the classname

.msg {
font-size: 18px;
color: "red";
}

Advance Customisations

Hooks Used

Contexts Used

You can customise different component for different types of conversation, infact you can provide your own customisation of each of the conversation types. Internally we use contexts such as LMMessageContext, UserProviderContext and many to get the message and other vitals informations which you might need to display the information. You can take a look at the reference file below to know more. Also you can checkout the Hooks and Contexts sections to know the information returned by them.

Customising LMMessage is a fair 2 simple step process.

  • First you create your own custom component using the hooks and contexts made available by LikeMinds. The will be responsible for fetching data, you might want to process. For example you can get the conversation details using the context LMMessageContext. Here you will get the conversation object which you will need to create your view.

  • Then you just have to pass it as a prop to LMClientOverlayProvider.

Here is a sample custom component implementation

Customising LMMessage

With this customisation you will be taking direct control over all the different conversation object rendered by the SDK. You will be responsible for rendering the views for all the conversation state. This might be usefull if you want to limit your views or would want to customise many different types of conversation in a single go.

  • Step 1: First create your own custom LMMessageComponent.
// Custom Component for LMMessage

const CustomLMMessage = () => {

// Getting the message object
const { message } = useContext(LMMessageContext);
// Getting the current user object
const { currentUser } = useContext(UserProviderContext);

return (
// Your Custom View. You can use the information fethed from above to render your views
);
};
  • Step 2: Pass your Custom View to LMClientOverlayProvider
Customising LMMessage component
import {
LMClientOverlayProvider,
LMChannel,
initiateLMClient,
LMChatTheme,
} from "@likeminds.community/likeminds-chat-reactjs";

// Custom Component for LMMessage
const CustomLMMessage = () => {

// Getting the message object
const { message } = useContext(LMMessageContext);
// Getting the current user object
const { currentUser } = useContext(UserProviderContext);

return (
// Your Custom View. You can use the information fethed from above to render your views
);
};

const App = () => {
const lmChatClient = initiateLMClient();
return (
<LMClientOverlayProvider
client={lmChatClient}
userDetails={userDetails}
lmChatTheme={LMChatTheme.COMMUNITY_CHAT}
customComponents={{
groupChatChannelList: <CustomLMMessage />,
}}
>
<LMChannel />
</LMClientOverlayProvider>
);
};
export default App;

You can also provide custom component for other different conversation types. Check out the full list of customisations available from here. Use different props available under messageBubbles to customise that particular conversation view.

Reference

For reference checkout this file