Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

💄 style(mention): render @-mentions in blue-violet instead of link blue (#23556)

Lobehub Coder6659826c1ad5
diff --git a/src/features/AgentTasks/AgentTaskDetail/commentMarkdown.tsx b/src/features/AgentTasks/AgentTaskDetail/commentMarkdown.tsx
index a62cf854ed5..63f17ec65b8 100644
--- a/src/features/AgentTasks/AgentTaskDetail/commentMarkdown.tsx
+++ b/src/features/AgentTasks/AgentTaskDetail/commentMarkdown.tsx
@@ -1,5 +1,4 @@
import { type MarkdownProps } from '@lobehub/ui';
-import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
import * as stylex from '@stylexjs/stylex';
import { memo } from 'react';
@@ -8,12 +7,13 @@ import { MENTION_TAG } from '@/const/plugin';
import { createRemarkSelfClosingTagPlugin } from '@/features/Conversation/Markdown/plugins/remarkPlugins/createRemarkSelfClosingTagPlugin';
import { useUserStore } from '@/store/user';
import { userProfileSelectors } from '@/store/user/selectors';
+import { mentionTokens } from '@/styles/mention.stylex';
import { resolveCommentMentionName } from './commentMentionName';
const styles = stylex.create({
mention: {
- color: cssVar.colorInfo,
+ color: mentionTokens.color,
wordBreak: 'break-word',
},
});
diff --git a/src/features/Channels/styles.ts b/src/features/Channels/styles.ts
index 1730d2484e7..2142eedf4d7 100644
--- a/src/features/Channels/styles.ts
+++ b/src/features/Channels/styles.ts
@@ -2,6 +2,7 @@ import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
import * as stylex from '@stylexjs/stylex';
import { densityTokens } from '@/styles/density.stylex';
+import { mentionTokens } from '@/styles/mention.stylex';
const HOVER = '@media (hover: hover)';
@@ -204,23 +205,23 @@ export const styles = stylex.create({
minWidth: 0,
overflowWrap: 'anywhere',
},
- /** A mentioned member inside message text. */
+ /** A mentioned member inside message text; blue-violet so it never reads as a link. */
mention: {
paddingBlock: 1,
paddingInline: 4,
borderRadius: 4,
fontWeight: 500,
- color: cssVar.colorInfo,
- backgroundColor: cssVar.colorInfoBg,
+ color: mentionTokens.color,
+ backgroundColor: mentionTokens.bg,
},
/** A mention inside the composer: highlighted text, no tag; tinted like selected text while selected. */
composerMention: {
userSelect: 'none',
fontWeight: 500,
- color: cssVar.colorInfo,
+ color: mentionTokens.color,
// `.selected` is added by the editor's selection observer, not by React.
borderRadius: { 'default': null, ':is(.selected)': cssVar.borderRadiusXS },
- backgroundColor: { 'default': null, ':is(.selected)': cssVar.colorInfoBgHover },
+ backgroundColor: { 'default': null, ':is(.selected)': mentionTokens.bg },
},
composer: {
'position': 'relative',
diff --git a/src/features/Conversation/Markdown/plugins/Mention/Render.tsx b/src/features/Conversation/Markdown/plugins/Mention/Render.tsx
index 5edcd386210..492a4be3a81 100644
--- a/src/features/Conversation/Markdown/plugins/Mention/Render.tsx
+++ b/src/features/Conversation/Markdown/plugins/Mention/Render.tsx
@@ -1,6 +1,5 @@
'use client';
-import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';
import * as stylex from '@stylexjs/stylex';
import isEqual from 'fast-deep-equal';
import { memo } from 'react';
@@ -9,6 +8,7 @@ import { useTranslation } from 'react-i18next';
import MentionProfileTrigger from '@/features/MemberProfileCard/MentionProfileTrigger';
import { useSessionStore } from '@/store/session';
import { sessionSelectors } from '@/store/session/selectors';
+import { mentionTokens } from '@/styles/mention.stylex';
import { type MarkdownElementProps } from '../type';
@@ -23,13 +23,10 @@ const styles = stylex.create({
borderRadius: '0.25em',
fontSize: '0.875em',
lineHeight: 1,
- color: cssVar.colorInfo,
+ color: mentionTokens.color,
wordBreak: 'break-word',
whiteSpace: 'break-spaces',
- backgroundColor: {
- 'default': cssVar.colorInfoBg,
- ':hover': `color-mix(in srgb, ${cssVar.colorInfo} 15%, ${cssVar.colorBgContainer})`,
- },
+ backgroundColor: { 'default': mentionTokens.bg, ':hover': mentionTokens.bgHover },
backgroundImage: { 'default': 'none', ':hover': 'none' },
},
});
diff --git a/src/styles/global.css b/src/styles/global.css
index 536a88512cb..92501a52bbc 100644
--- a/src/styles/global.css
+++ b/src/styles/global.css
@@ -78,6 +78,21 @@ html.desktop[data-theme='light'] body {
background-color: color-mix(in srgb, var(--lobe-color-bg-layout) 70%, transparent);
}
+/* @-mention blue-violet (src/styles/mention.stylex.ts). The geekblue/purple scale vars keep one
+ value across themes, so dark mode lifts the text toward colorText and deepens the tint. */
+html {
+ --lobe-mention-base: color-mix(in srgb, var(--lobe-geekblue) 50%, var(--lobe-purple));
+ --lobe-mention-color: var(--lobe-mention-base);
+ --lobe-mention-bg: color-mix(in srgb, var(--lobe-mention-base) 14%, transparent);
+ --lobe-mention-bg-hover: color-mix(in srgb, var(--lobe-mention-base) 22%, transparent);
+}
+
+html[data-theme='dark'] {
+ --lobe-mention-color: color-mix(in srgb, var(--lobe-mention-base) 55%, var(--lobe-color-text));
+ --lobe-mention-bg: color-mix(in srgb, var(--lobe-mention-base) 26%, transparent);
+ --lobe-mention-bg-hover: color-mix(in srgb, var(--lobe-mention-base) 36%, transparent);
+}
+
/* MAC_WINDOW_FULLSCREEN_SELECTOR / MAC_PANEL_BG_VAR from
@/features/Electron/system/macWindowFullscreen */
html.desktop[data-window-fullscreen] {
diff --git a/src/styles/mention.stylex.ts b/src/styles/mention.stylex.ts
new file mode 100644
index 00000000000..500fc63a736
--- /dev/null
+++ b/src/styles/mention.stylex.ts
@@ -0,0 +1,14 @@
+import * as stylex from '@stylexjs/stylex';
+
+/**
+ * Colors for an @-mention of a member: a blue-violet mixed from the theme's geekblue and purple
+ * scales, so a mention never reads as the link blue next to it. The vars and their dark-mode
+ * values live in `global.css`; the fallbacks are the light values.
+ */
+const BASE = 'color-mix(in srgb, var(--lobe-geekblue) 50%, var(--lobe-purple))';
+
+export const mentionTokens = stylex.defineConsts({
+ color: `var(--lobe-mention-color, ${BASE})`,
+ bg: `var(--lobe-mention-bg, color-mix(in srgb, ${BASE} 14%, transparent))`,
+ bgHover: `var(--lobe-mention-bg-hover, color-mix(in srgb, ${BASE} 22%, transparent))`,
+});