Earlier today, I made a little plugin which lets me customize the author line of each forum post with some CSS based on some special site-specific logic. Example:
function initColorize(api)
{
api.includePostAttributes('colorized_groups');
// Hijacking post icons to sneak in CSS for forum posts
api.addPosterIcons((cfs, attrs) => {
// (A real icon could be specified by filling in the icon field.
// I removed the icon though since it was getting a bit cluttered.
// For now, with no icon specified, it's just for CSS highlighting of name.)
if (attrs.colorized_groups.indexOf("developer") > -1)
return { icon: '', className: 'developer', title: 'Developer' };
else if (attrs.colorized_groups.indexOf("wip_researcher") > -1)
return { icon: '', className: 'wip_researcher', title: 'WIP Researcher' };
else if (attrs.colorized_groups.indexOf("researcher") > -1)
return { icon: '', className: 'researcher', title: 'Researcher' };
});
Next, I want to do some similar customizations for real-time chat – but there is no api.addPosterIcons
equivalent for real-time chat messages. Maybe I could use the api.decorateWidget
, but the corresponding component for chat is ChatMessageInfo
which is a component, not a widget.
Sorry if it is obvious, but what would be a good strategy for customizing ChatMessageInfo
from a plugin?
(It is intentional that I am not relying on user primary group since there is some special logic for which one should take priority and I don’t want to have to rely on user/admin setting it properly manually.)
Thank you!