Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

chore(ChatMessage): give the avatar offset variable a private literal name (#9602)

Cindy Zhangd40b5b7a5672
diff --git a/.changeset/chat-avatar-offset-private-var.md b/.changeset/chat-avatar-offset-private-var.md
new file mode 100644
index 0000000000..3289b0e05d
--- /dev/null
+++ b/.changeset/chat-avatar-offset-private-var.md
@@ -0,0 +1,7 @@
+---
+'@astryxdesign/core': patch
+---
+
+[chore] Internal: ChatMessage's avatar offset variable now has the private literal name `--_chat-avatar-offset` instead of a hashed name, so the published stylesheet no longer declares an internal variable that looks public. The avatar's offset is unchanged. Not exported from the package entry point. (#9602)
+
+@cixzhang
diff --git a/packages/core/src/Chat/Chat.doc.mjs b/packages/core/src/Chat/Chat.doc.mjs
index 2ea4eee788..24d3008d97 100644
--- a/packages/core/src/Chat/Chat.doc.mjs
+++ b/packages/core/src/Chat/Chat.doc.mjs
@@ -35,6 +35,7 @@ export const docs = {
vars: [
{name: '--_chat-composer-radius', description: 'Border radius of the composer body. Inner elements derive their radius concentrically.', default: 'var(--radius-chat)', private: true},
{name: '--_chat-composer-padding', description: 'Padding of the composer body. Used in the concentric radius calculation.', default: 'var(--spacing-3)', private: true},
+ {name: '--_chat-avatar-offset', description: 'Top offset of a message avatar: the name row spacing when a bubble in the message shows a name, else 0px. Each message sets it from its own content. Not a theming lever.', default: '0px', private: true},
{name: '--_button-radius', description: 'Concentric button radius inside the composer.', default: 'max(var(--radius-element), calc(var(--_chat-composer-radius) - var(--_chat-composer-padding)))', private: true, derived: true, formula: 'max(var(--radius-element), calc(var(--_chat-composer-radius) - var(--_chat-composer-padding)))'},
],
derived: [
diff --git a/packages/core/src/Chat/ChatMessage.tsx b/packages/core/src/Chat/ChatMessage.tsx
index 56e7015a4e..27f90727c6 100644
--- a/packages/core/src/Chat/ChatMessage.tsx
+++ b/packages/core/src/Chat/ChatMessage.tsx
@@ -118,7 +118,7 @@ const styles = stylex.create({
// Judged from this article (parent-relative), never from siblings, so the
// global stylesheet keeps no sibling-relative :has().
avatarOffset: {
- [chatMessageVars.avatarOffset]: {
+ [chatMessageVars['--_chat-avatar-offset']]: {
default: '0px',
':has([data-chat-name])': spacingVars['--spacing-5'],
},
@@ -128,7 +128,7 @@ const styles = stylex.create({
flexShrink: 0,
// The avatar lines up with a bubble's name row when the message holds
// one; the article sets the offset (see chatMessageVars).
- marginBlockStart: chatMessageVars.avatarOffset,
+ marginBlockStart: chatMessageVars['--_chat-avatar-offset'],
},
contentColumn: {
display: 'flex',
diff --git a/packages/core/src/Chat/chatMessage.vars.stylex.ts b/packages/core/src/Chat/chatMessage.vars.stylex.ts
index 7c05af1a65..fa89a5e861 100644
--- a/packages/core/src/Chat/chatMessage.vars.stylex.ts
+++ b/packages/core/src/Chat/chatMessage.vars.stylex.ts
@@ -5,14 +5,14 @@ import * as stylex from '@stylexjs/stylex';
/**
* Per-message values ChatMessage sets on its article for its own slots.
*
- * `avatarOffset` is the avatar's top spacing: the name row's spacing when a
- * bubble in this message renders a name, else none. Each article sets it from
- * its own `:has([data-chat-name])`, a parent-relative rule: a sibling-relative
- * `:has(~ …)` in the global stylesheet makes WebKit re-check every earlier
- * sibling on each insertion into any container, so filling one grows
- * quadratically. A message nested in another sets its own value, so it never
- * inherits the outer message's.
+ * `--_chat-avatar-offset` is the avatar's top spacing: the name row's spacing
+ * when a bubble in this message renders a name, else none. Each article sets
+ * it from its own `:has([data-chat-name])`, a parent-relative rule: a
+ * sibling-relative `:has(~ …)` in the global stylesheet makes WebKit re-check
+ * every earlier sibling on each insertion into any container, so filling one
+ * grows quadratically. A message nested in another sets its own value, so it
+ * never inherits the outer message's.
*/
export const chatMessageVars = stylex.defineVars({
- avatarOffset: '0px',
+ '--_chat-avatar-offset': '0px',
});
diff --git a/packages/core/src/theme/derivedVarRegistry.test.ts b/packages/core/src/theme/derivedVarRegistry.test.ts
index 2c43dbfc10..2ad0893c5e 100644
--- a/packages/core/src/theme/derivedVarRegistry.test.ts
+++ b/packages/core/src/theme/derivedVarRegistry.test.ts
@@ -343,6 +343,10 @@ const VARS_WITHOUT_DERIVED_MAPPING = new Set([
'--_toast-swipe-exit-y',
'--_toast-swipe-opacity',
'--_toast-swipe-scale',
+ // Set by each ChatMessage article from its own content and read as its
+ // avatar's top margin, so the avatar lines up with a name row. Content
+ // state, not a value a theme author sets.
+ '--_chat-avatar-offset',
// Indentation and row-spacing metrics: --tree-list-indent is the authorable
// step, --_tree-indent the per-row distance TreeListItem computes from it.
// --tree-list-row-gap is applied as half a padding-block on each row wrapper,