export const Mention = ({ children, self = false }) => (
@{children}
);
export const ChannelRef = ({ children }) => (
#{children}
);
export const SlackButton = ({ children, variant = "default" }) => (
{children}
);
export const SlackUnfurl = ({ color = "#8a94a6", footer, children }) => (
{children}
{footer ? (
{footer}
) : null}
);
export const SlackThread = ({
type = "channel",
channel = "general",
private: isPrivate = false,
members,
dmWith,
hasAvatar = false,
maxHeight = "70vh",
children,
}) => {
const childItems = Array.isArray(children) ? children : [children];
const dmAvatar = hasAvatar ? childItems[0] : null;
const threadMessages = hasAvatar ? childItems.slice(1) : children;
const composerLabel =
type === "dm"
? `Message ${dmWith?.name || "someone"}`
: type === "thread"
? "Reply..."
: `Message ${isPrivate ? "" : "#"}${channel.replace(/^#/, "")}`;
return (
{type === "thread" ? (
) : type === "dm" ? (
{dmAvatar}
{dmWith?.name || "Direct message"}
) : (
{isPrivate ? (
) : (
)}
{channel.replace(/^#/, "")}
{members ? (
) : null}
)}
{
if (!el || !maxHeight) return;
const wrapper = el.parentElement;
const aboveHint = wrapper?.querySelector('[data-hint="above"]');
const belowHint = wrapper?.querySelector('[data-hint="below"]');
const update = () => {
const hasAbove = el.scrollTop > 4;
const hasBelow = el.scrollHeight - el.scrollTop - el.clientHeight > 4;
if (aboveHint) aboveHint.style.opacity = hasAbove ? "1" : "0";
if (belowHint) belowHint.style.opacity = hasBelow ? "1" : "0";
};
update();
el.addEventListener("scroll", update);
requestAnimationFrame(update);
}}
className="overflow-y-auto bg-white dark:bg-[#1A1D21]"
style={maxHeight ? { maxHeight } : undefined}
>
{threadMessages}
{maxHeight ? (
) : null}
{maxHeight ? (
) : null}
);
};
export const SlackReplyDivider = ({ count = 1 }) => (
{count} {count === 1 ? "reply" : "replies"}
);
export const SlackMessage = ({
name,
self = false,
bot = false,
time,
color = "#611f69",
hasAvatar = false,
badges,
reactions,
highlighted = false,
subtitle,
children,
}) => {
const SELF_NAME = "Dhravya Shah";
const childItems = Array.isArray(children) ? children : [children];
const resolvedAvatar = hasAvatar ? childItems[0] : null;
const messageBody = hasAvatar ? childItems.slice(1) : children;
const resolvedName = bot ? "supermemory" : self ? SELF_NAME : name || SELF_NAME;
const resolvedBadges = badges || (bot ? ["AGENT"] : null);
return (
{["â
", "đ", "đ", "đ", "âŠī¸", "â¯"].map((icon, i) => (
{icon}
))}
{resolvedAvatar ? (
{resolvedAvatar}
) : (
{(resolvedName || "?").slice(0, 1).toUpperCase()}
)}
{resolvedName}
{subtitle ? (
({subtitle})
) : null}
{resolvedBadges
? resolvedBadges.map((b) => (
{b}
))
: null}
{time ? (
{time}
) : null}
{messageBody}
{reactions ? (
{reactions.map((r, i) => (
{r.emoji}
{r.count}
))}
) : null}
);
};
export const FileAttachment = ({ name, size }) => (
{name}
{size ? (
{size}
) : null}
);
export const AgentLink = ({ href, children }) => (
{children}
);