Skip to content

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

TypeScript

feat(CommentPin): sizes, equal padding, ellipsis overflow, unread dot, hidden resolved pins (#8023)

Ernestc60f57133e81
diff --git a/apps/storybook/stories/CommentPin.stories.tsx b/apps/storybook/stories/CommentPin.stories.tsx
index 4605b63947..591f820bdc 100644
--- a/apps/storybook/stories/CommentPin.stories.tsx
+++ b/apps/storybook/stories/CommentPin.stories.tsx
@@ -52,6 +52,9 @@ const styles = stylex.create({
stateLabel: {
minWidth: 140,
},
+ sizeColumn: {
+ minWidth: 120,
+ },
canvas: {
position: 'relative',
width: 520,
@@ -91,6 +94,65 @@ const styles = stylex.create({
},
});
+const SIZES = ['sm', 'md', 'lg'] as const;
+
+const EVERYONE = [
+ PEOPLE.ada,
+ PEOPLE.lin,
+ PEOPLE.mira,
+ PEOPLE.noah,
+ PEOPLE.sam,
+] as const;
+
+const SIZE_ROWS = [
+ {
+ name: 'Single',
+ props: {label: 'Open annotation from Ada', participants: [PEOPLE.ada]},
+ },
+ {
+ name: 'Grouped',
+ props: {
+ label: 'Open 4 grouped annotations from Ada and Lin',
+ participants: [PEOPLE.ada, PEOPLE.lin],
+ threadCount: 4,
+ },
+ },
+ {
+ name: 'Group overflow',
+ props: {
+ label: 'Open 8 grouped annotations from Ada, Lin, and 3 others',
+ participants: EVERYONE,
+ threadCount: 8,
+ },
+ },
+ {
+ name: 'Unread single',
+ props: {
+ label: 'Open unread annotation from Mira',
+ participants: [PEOPLE.mira],
+ unreadCount: 1,
+ },
+ },
+ {
+ name: 'Unread group',
+ props: {
+ label: 'Open 8 grouped annotations from Ada, Lin, and 3 others, 3 unread',
+ participants: EVERYONE,
+ threadCount: 8,
+ unreadCount: 3,
+ },
+ },
+ {
+ name: 'Selected group',
+ props: {
+ label: 'Current group of 12 annotations from Ada, Lin, and 3 others',
+ participants: EVERYONE,
+ threadCount: 12,
+ isSelected: true,
+ },
+ },
+] as const;
+
function FocusedSelectedPin() {
const ref = useRef<HTMLButtonElement>(null);
useEffect(() => {
@@ -131,6 +193,35 @@ export const Grouped: Story = {
},
};
+export const Sizes: Story = {
+ render: () => (
+ <VStack gap={3} xstyle={styles.story}>
+ <HStack gap={4} xstyle={styles.row}>
+ <Text type="supporting" xstyle={styles.stateLabel}>
+ Size
+ </Text>
+ {SIZES.map(size => (
+ <Text key={size} type="supporting" xstyle={styles.sizeColumn}>
+ {size}
+ </Text>
+ ))}
+ </HStack>
+ {SIZE_ROWS.map(row => (
+ <HStack key={row.name} gap={4} xstyle={styles.row}>
+ <Text type="supporting" xstyle={styles.stateLabel}>
+ {row.name}
+ </Text>
+ {SIZES.map(size => (
+ <HStack key={size} xstyle={styles.sizeColumn}>
+ <CommentPin {...row.props} size={size} onClick={() => {}} />
+ </HStack>
+ ))}
+ </HStack>
+ ))}
+ </VStack>
+ ),
+};
+
export const StateMatrix: Story = {
render: () => (
<VStack gap={3} xstyle={styles.story}>
@@ -235,12 +326,14 @@ export const StateMatrix: Story = {
</HStack>
<HStack gap={4} xstyle={styles.row}>
<Text type="supporting" xstyle={styles.stateLabel}>
- Resolved
+ Resolved, selected
</Text>
+ {/* An unselected resolved pin renders nothing. */}
<CommentPin
- label="Open resolved annotation from Mira"
+ label="Current resolved annotation from Mira"
participants={[PEOPLE.mira]}
isResolved
+ isSelected
/>
</HStack>
<HStack gap={4} xstyle={styles.row}>
diff --git a/packages/lab/blocks/CommentPinShowcase.doc.mjs b/packages/lab/blocks/CommentPinShowcase.doc.mjs
index 30b3a442bb..513bfd9027 100644
--- a/packages/lab/blocks/CommentPinShowcase.doc.mjs
+++ b/packages/lab/blocks/CommentPinShowcase.doc.mjs
@@ -6,7 +6,7 @@ export default {
name: 'Avatar-first annotations',
displayName: 'Avatar-first annotations',
description:
- 'Caller-positioned comment pins over media and in a content margin. Every coordinate maps to the pin’s logical bottom-start corner. The selected group caps its participants at three circles (two Avatars plus +3) and shows its unread count in an accent badge instead of the total; the unread margin pin shows the badge too. Other pins dim without becoming disabled, activating the selected pin again clears the selection, and no pin dims while nothing is selected.',
+ 'Caller-positioned comment pins over media and in a content margin. Every coordinate maps to the pin’s logical bottom-start corner. The selected group caps its participants at three circles (two Avatars plus an ellipsis) and ends with its total and an accent unread dot; the unread margin pin shows the dot too. Other pins dim without becoming disabled, activating the selected pin again clears the selection, and no pin dims while nothing is selected.',
exampleFor: 'CommentPin',
isReady: true,
isShowcase: true,
diff --git a/packages/lab/blocks/CommentPinShowcase.tsx b/packages/lab/blocks/CommentPinShowcase.tsx
index 26cf7916fe..b9a883773c 100644
--- a/packages/lab/blocks/CommentPinShowcase.tsx
+++ b/packages/lab/blocks/CommentPinShowcase.tsx
@@ -7,7 +7,7 @@
* participant/thread/unread counts, and controlled selected/dimmed state
* that may be empty
* @output A grouped pin with a three-circle participant cap and an unread
- * badge, a resolved pin, and an unread margin pin; activating the selected
+ * dot, a single pin, and an unread margin pin; activating the selected
* pin clears the selection, and non-selected pins dim only while another pin
* is selected
* @position CommentPin docsite showcase and copyable Lab block
@@ -160,9 +160,8 @@ export default function CommentPinShowcase() {
xstyle={styles.groupedMarker}
/>
<CommentPin
- label="Open resolved annotation from Mira"
+ label="Open annotation from Mira"
participants={[PEOPLE.mira]}
- isResolved
isSelected={selected === 'resolved'}
isDimmed={selected != null && selected !== 'resolved'}
onClick={() => toggle('resolved')}
diff --git a/packages/lab/src/CommentPin/CommentPin.doc.mjs b/packages/lab/src/CommentPin/CommentPin.doc.mjs
index ce47a51f83..2d459bd1b3 100644
--- a/packages/lab/src/CommentPin/CommentPin.doc.mjs
+++ b/packages/lab/src/CommentPin/CommentPin.doc.mjs
@@ -13,7 +13,7 @@ const anatomy = [
name: 'Marker surface',
required: true,
description:
- 'The compact speech-bubble button surface, with a fixed 4px logical bottom-start corner. It owns selected, resolved, disabled, hover, press, focus-visible, and grouped presentation, but no coordinates.',
+ 'The compact speech-bubble button surface, with a fixed 2px logical bottom-start corner, 28, 32, or 36px tall by size and padded equally on every side. It owns selected, resolved, disabled, hover, press, focus-visible, and grouped presentation, but no coordinates.',
},
{
name: 'Representative avatars',
@@ -25,19 +25,19 @@ const anatomy = [
name: 'Overflow indicator',
required: false,
description:
- 'A +N AvatarGroupOverflow circle that takes the third position when a group has more than three distinct participants. Decorative and non-interactive inside the pin.',
+ 'An ellipsis AvatarGroupOverflow circle that takes the third position when a group has more than three distinct participants. It shows no number, so the group count stays the pin’s only number. Decorative and non-interactive inside the pin.',
},
{
name: 'Group count',
required: false,
description:
- 'Exact total number of represented threads. Appears when threadCount is greater than one and no represented thread is unread; it is a quantity, not ordinal identity.',
+ 'Exact total number of represented threads. Appears when threadCount is greater than one, before the unread dot when there is one; it is a quantity, not ordinal identity. Extra end padding keeps it clear of the pin’s edge.',
},
{
- name: 'Unread badge',
+ name: 'Unread dot',
required: false,
description:
- 'Accent badge with the number of unread represented threads. Whenever unreadCount is above zero it replaces the group count, and it also appears on single-thread pins.',
+ 'An accent StatusDot at the end of the pin that marks unread activity whenever unreadCount is above zero: after the group count, or after the participant on a single-thread pin. It adds no second number; decorative inside the pin.',
},
];
@@ -60,7 +60,7 @@ export const docs = {
'margin comment',
],
description:
- 'Avatar-first button for opening one anchored annotation thread or a caller-defined group. A single marker shows its lead participant; a grouped marker shows up to three participant circles (two plus +N beyond three) and the total thread count. Whenever any represented thread is unread, an accent badge shows the unread count instead. The host owns anchors, coordinates, grouping, collision handling, and the comments surface.',
+ 'Avatar-first button for opening one anchored annotation thread or a caller-defined group. A single marker shows its lead participant; a grouped marker shows up to three participant circles (two plus an ellipsis beyond three) and the total thread count. Whenever any represented thread is unread, an accent status dot appears after the count. Three sizes follow the element-size scale. The host owns anchors, coordinates, grouping, collision handling, and the comments surface.',
props: [
{
name: 'label',
@@ -73,9 +73,16 @@ export const docs = {
name: 'participants',
type: 'readonly [CommentPinParticipant, ...CommentPinParticipant[]]',
description:
- 'Non-empty ordered participants, lead first. A single pin renders the first. A grouped pin renders distinct IDs as an AvatarGroup of at most three circles: every participant when three or fewer are distinct, otherwise the first two plus a +N overflow circle. Pass every distinct participant so the overflow count is accurate. Each record has id, name, and optional avatarSrc.',
+ 'Non-empty ordered participants, lead first. A single pin renders the first. A grouped pin renders distinct IDs as an AvatarGroup of at most three circles: every participant when three or fewer are distinct, otherwise the first two plus an ellipsis overflow circle. Pass every distinct participant so the overflow appears exactly when more than three people participate. Each record has id, name, and optional avatarSrc.',
required: true,
},
+ {
+ name: 'size',
+ type: "'sm' | 'md' | 'lg'",
+ description:
+ 'Pin height on the element-size scale: sm 28px, md 32px, lg 36px, with 22px, 24px, and 28px participant circles. Padding is equal on every side, so the avatars and overflow sit the same distance from each edge; the trailing count or unread dot adds a little end padding so it never crowds the edge.',
+ default: "'sm'",
+ },
{
name: 'threadCount',
type: 'number',
@@ -87,7 +94,7 @@ export const docs = {
name: 'unreadCount',
type: 'number',
description:
- 'Represented threads with unread activity. When above zero, an accent badge shows this number in place of the thread total, on single and grouped pins alike. Invalid values are ignored and values above threadCount are capped. Repeat the unread context in label.',
+ 'Represented threads with unread activity. When above zero, an accent status dot appears at the end of the pin, after the thread total or the single participant; the number itself is not shown. Invalid values are ignored and values above threadCount are capped. Repeat the unread context in label.',
default: '0',
},
{
@@ -108,7 +115,7 @@ export const docs = {
name: 'isResolved',
type: 'boolean',
description:
- 'Whether every represented thread is resolved. Reduces marker prominence while keeping it available; selected treatment wins visually when both are true.',
+ 'Whether every represented thread is resolved. A resolved pin renders nothing unless it is selected: resolved discussion leaves the content, while a thread the reader opened (or resolved from its popover) keeps its anchor, with the selected treatment, until the host clears the selection.',
default: 'false',
},
{
@@ -135,7 +142,15 @@ export const docs = {
targets: [
{
className: 'astryx-comment-pin',
- visualProps: ['grouped', 'unread', 'selected', 'dimmed', 'resolved', 'disabled'],
+ visualProps: [
+ 'size',
+ 'grouped',
+ 'unread',
+ 'selected',
+ 'dimmed',
+ 'resolved',
+ 'disabled',
+ ],
},
],
},
@@ -156,7 +171,7 @@ export const docs = {
category: 'Semantics',
criterion: '4.1.2 Name, Role, Value',
description:
- 'The required label is the button name and tooltip. aria-pressed communicates controlled selection; participant Avatars, the overflow circle, the visible thread total, and the unread badge remain decorative, so repeat grouped and unread context in label.',
+ 'The required label is the button name and tooltip. aria-pressed communicates controlled selection; participant Avatars, the overflow circle, the visible thread total, and the unread dot remain decorative, so repeat grouped and unread context in label.',
},
{
name: 'Selection and focus',
@@ -170,7 +185,7 @@ export const docs = {
{
guidance: true,
description:
- 'Pass the lead commenter first. For a group, pass every distinct participant ordered by how well they help users recognize the cluster; the pin shows up to three circles and summarizes the rest as +N.',
+ 'Pass the lead commenter first. For a group, pass every distinct participant ordered by how well they help users recognize the cluster; the pin shows up to three circles and summarizes the rest with an ellipsis.',
},
{
guidance: true,
@@ -205,7 +220,7 @@ export const docs = {
{
guidance: true,
description:
- 'Pass unreadCount whenever represented threads have unread activity. Its accent badge replaces the thread total so unread work is always visible; repeat the unread count in label.',
+ 'Pass unreadCount whenever represented threads have unread activity. Its accent dot keeps unread work visible beside the total; repeat the unread count in label.',
},
{
guidance: false,
@@ -220,7 +235,7 @@ export const docs = {
{
guidance: false,
description:
- 'Slice participants yourself to control the overflow. Pass every distinct participant so the +N circle reports the real number of hidden people.',
+ 'Slice participants yourself to control the overflow. Pass every distinct participant so the ellipsis appears exactly when more than three people participate, and name the hidden people in label.',
},
],
},
@@ -248,8 +263,8 @@ export const docs = {
},
{
label: 'Unread threads with participant overflow',
- code: `// Five distinct people: two Avatars plus a +3 circle.
-// Two unread threads: the accent badge shows 2 instead of the total.
+ code: `// Five distinct people: two Avatars plus an ellipsis circle.
+// Two unread threads: an accent dot after the total.
<CommentPin
label="Open 6 grouped annotations from Ada, Lin, and 3 others, 2 unread"
participants={[ada, lin, mira, noah, sam]}
@@ -257,6 +272,14 @@ export const docs = {
unreadCount={2}
onClick={() => setSelectedCluster('cluster-2')}
/>`,
+ },
+ {
+ label: 'Sizes',
+ code: `<HStack gap={3}>
+ <CommentPin size="sm" label="Open annotation from Ada" participants={[ada]} />
+ <CommentPin size="md" label="Open annotation from Ada" participants={[ada]} />
+ <CommentPin size="lg" label="Open annotation from Ada" participants={[ada]} />
+</HStack>`,
},
{
label: 'Host-owned placement',
@@ -285,15 +308,21 @@ export const docs = {
/** @type {import('@astryxdesign/cli/authoring').ComponentTranslationDoc} */
export const docsZh = {
description:
- '用于打开单个锚定批注线程或调用方定义线程组的头像优先按钮。单线程显示主要参与者头像;分组标记最多显示三个圆形(超过三人时显示两个头像和 +N),并显示线程总数;有未读线程时以强调色徽章显示未读数。',
+ '用于打开单个锚定批注线程或调用方定义线程组的头像优先按钮。单线程显示主要参与者头像;分组标记最多显示三个圆形(超过三人时显示两个头像和省略号圆形),并显示线程总数;有未读线程时在末尾(总数或单个头像之后)显示强调色状态点。三种尺寸遵循元素尺寸刻度。',
propDescriptions: {
- label: '必填的无障碍操作名称及悬停/聚焦提示;包含分组、未读或已解决上下文。',
- participants: '有序参与者列表(主要参与者在前);单线程显示第一个;分组最多显示三个圆形,超过三位不同参与者时显示前两个头像和 +N 溢出圆形。',
+ label:
+ '必填的无障碍操作名称及悬停/聚焦提示;包含分组、未读或已解决上下文。',
+ participants:
+ '有序参与者列表(主要参与者在前);单线程显示第一个;分组最多显示三个圆形,超过三位不同参与者时显示前两个头像和省略号溢出圆形。',
+ size: '标记高度:sm 28px、md 32px、lg 36px,参与者头像分别为 22px、24px、28px;四边内边距相等。',
threadCount: '所代表的线程总数;大于 1 时使用分组样式并显示准确数量。',
- unreadCount: '有未读活动的线程数;大于 0 时以强调色徽章替代线程总数显示,单线程同样适用。',
- isSelected: '标记是否为当前批注目标;再次激活已选中的标记时,宿主应清除选择(aria-pressed 切换语义)。',
- isDimmed: '其他标记被选中时降低此标记的视觉突出度,但不禁用操作;未选中任何标记时不应降低。',
- isResolved: '所代表的线程是否都已解决。',
+ unreadCount:
+ '有未读活动的线程数;大于 0 时在总数之后(单线程时在头像之后)显示强调色状态点,不显示该数字。',
+ isSelected:
+ '标记是否为当前批注目标;再次激活已选中的标记时,宿主应清除选择(aria-pressed 切换语义)。',
+ isDimmed:
+ '其他标记被选中时降低此标记的视觉突出度,但不禁用操作;未选中任何标记时不应降低。',
+ isResolved: '所代表的线程是否都已解决;已解决的标记除非被选中否则不渲染。',
isDisabled: '使用原生按钮语义禁用激活。',
onClick: '由产品拥有的激活处理函数。',
xstyle: '根按钮的 StyleX 布局样式;由宿主决定内容上方或边距中的位置。',
@@ -303,24 +332,43 @@ export const docsZh = {
/** @type {import('@astryxdesign/cli/authoring').ComponentTranslationDoc} */
export const docsDense = {
description:
- 'avatar-first annotation anchor; 1 lead Avatar for one thread; groups show max 3 circles (2 Avatars + +N beyond 3) + exact total; accent unread badge replaces the total when unreadCount > 0; host owns placement/grouping',
+ 'avatar-first annotation anchor; 1 lead Avatar for one thread; groups show max 3 circles (2 Avatars + ellipsis beyond 3) + exact total; accent StatusDot after the total (or the avatar on a single pin) when unreadCount > 0; sm/md/lg = 28/32/36px; host owns placement/grouping',
usage: {
description:
'Interactive anchor for comments over content or in margins. Pass every distinct participant, the total thread count, and the unread thread count; keep coordinates, clustering, collisions, thread state, and opened UI in the host. Absolute coordinates map to the logical bottom-start corner, while another pin is selected its siblings use isDimmed and remain interactive, and activating the selected pin again clears the host selection.',
bestPractices: [
- {guidance: true, description: 'Pass the lead commenter first and write a complete action label, including unread context.'},
- {guidance: true, description: 'Use threadCount as quantity, never ordinal identity; pass unreadCount so unread work outranks the total.'},
- {guidance: false, description: 'Nest interactive Avatars, slice participants to fake the overflow, or pass coordinates/grouping logic into the marker.'},
+ {
+ guidance: true,
+ description:
+ 'Pass the lead commenter first and write a complete action label, including unread context.',
+ },
+ {
+ guidance: true,
+ description:
+ 'Use threadCount as quantity, never ordinal identity; pass unreadCount so an accent dot marks unread work.',
+ },
+ {
+ guidance: false,
+ description:
+ 'Nest interactive Avatars, slice participants to fake the overflow, or pass coordinates/grouping logic into the marker.',
+ },
],
},
propDescriptions: {
- label: 'required action name + hover/focus tooltip; include grouped/unread context',
- participants: 'non-empty ordered tuple of {id,name,avatarSrc?}; single renders 1; groups render ≤3 circles (2 + +N overflow beyond 3 distinct)',
- threadCount: 'positive integer total; >1 selects grouped presentation; default 1',
- unreadCount: 'unread represented threads; >0 shows accent badge instead of total (single and grouped); capped at threadCount; default 0',
- isSelected: 'controlled active pin; solid 2px accent outline outside the pin + aria-pressed; host clears it when the selected pin is activated again',
- isDimmed: 'controlled de-emphasis for non-selected siblings only while another pin is selected; remains interactive',
- isResolved: 'controlled lower-prominence resolved state',
+ label:
+ 'required action name + hover/focus tooltip; include grouped/unread context',
+ participants:
+ 'non-empty ordered tuple of {id,name,avatarSrc?}; single renders 1; groups render ≤3 circles (2 + ellipsis overflow beyond 3 distinct)',
+ size: "'sm' | 'md' | 'lg' = 28/32/36px height, 22/24/28px avatars, equal padding; default 'sm'",
+ threadCount:
+ 'positive integer total; >1 selects grouped presentation; default 1',
+ unreadCount:
+ 'unread represented threads; >0 shows an accent dot after the total (or the avatar on a single pin); capped at threadCount; default 0',
+ isSelected:
+ 'controlled active pin; solid 2px accent outline outside the pin + aria-pressed; host clears it when the selected pin is activated again',
+ isDimmed:
+ 'controlled de-emphasis for non-selected siblings only while another pin is selected; remains interactive',
+ isResolved: 'resolved pins render nothing unless selected',
isDisabled: 'native disabled marker',
onClick: 'host activation handler',
xstyle: 'root layout/positioning styles; marker owns no coordinates',
diff --git a/packages/lab/src/CommentPin/CommentPin.spec.md b/packages/lab/src/CommentPin/CommentPin.spec.md
index 40a6255f6f..96ad0e0b74 100644
--- a/packages/lab/src/CommentPin/CommentPin.spec.md
+++ b/packages/lab/src/CommentPin/CommentPin.spec.md
@@ -46,15 +46,15 @@ system_specs: [spec:AST-002]
## Contract at a glance
-| Area | Contract |
-| ----------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| Public contract | `@astryxdesign/lab` exports one `CommentPin` button, its props, and its participant data type. |
-| Behavior | A marker renders the first participant for one thread. A marker representing multiple threads renders its distinct participants as an AvatarGroup of at most three circles (two Avatars plus a +N overflow beyond three) and the total thread count. Whenever any represented thread is unread, an accent badge with the unread count replaces the total on single and grouped markers. |
-| End-user impact | Annotation anchors identify people rather than positions in an ordinal sequence. Grouped anchors keep a bounded set of participant identities while exposing the number of threads they open, and unread activity stays visible as a count. |
-| Builder impact | Callers provide every distinct participant in order, the total and unread thread counts, an accessible action label, activation behavior, and controlled selected/dimmed/resolved/disabled state. |
-| Compatibility/readiness | Additive experimental Lab component. Its API and visual treatment remain draft until product use and visual evidence settle them. |
-| Review checks | Reject ordinal identity, pin-owned clustering or coordinates, center-anchored placement, interactive descendant avatars, more than three participant circles, an unread count hidden behind the total, generated application copy, hidden thread-count semantics, dimming that disables sibling selection, or selected/resolved paint that obscures participant identity. |
-| Governing rules | `architecture:public-component-api`, `architecture:component-theming-surface`, `architecture:interaction-modality`, `architecture:component-test-sufficiency`, and `spec:AST-002`. |
+| Area | Contract |
+| ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| Public contract | `@astryxdesign/lab` exports one `CommentPin` button, its props, and its participant data type. |
+| Behavior | A marker renders the first participant for one thread. A marker representing multiple threads renders its distinct participants as an AvatarGroup of at most three circles (two Avatars plus an ellipsis overflow beyond three) and the total thread count. Whenever any represented thread is unread, an accent status dot follows the total, or the participant on a single marker. A resolved marker renders nothing unless it is selected. Three sizes follow the element-size scale with equal padding on every side. |
+| End-user impact | Annotation anchors identify people rather than positions in an ordinal sequence. Grouped anchors keep a bounded set of participant identities while exposing the number of threads they open, unread activity stays visible as a dot, and resolved discussion leaves the content. |
+| Builder impact | Callers provide every distinct participant in order, the total and unread thread counts, an accessible action label, activation behavior, an optional size, and controlled selected/dimmed/resolved/disabled state. |
+| Compatibility/readiness | Additive experimental Lab component. Its API and visual treatment remain draft until product use and visual evidence settle them. |
+| Review checks | Reject ordinal identity, pin-owned clustering or coordinates, center-anchored placement, interactive descendant avatars, more than three participant circles, a numeric overflow beside the count, unequal padding, an unread number beside or instead of the total, an unselected resolved marker that still renders, generated application copy, hidden thread-count semantics, dimming that disables sibling selection, or selected/resolved paint that obscures participant identity. |
+| Governing rules | `architecture:public-component-api`, `architecture:component-theming-surface`, `architecture:interaction-modality`, `architecture:component-test-sufficiency`, and `spec:AST-002`. |
This table is a review projection; the body below is authoritative.
@@ -81,15 +81,15 @@ Consumer migration instructions belong in consumer docs and release notes.
**Owns**
-- One button surface, its single/grouped visual transformation, and its
- selected, dimmed, resolved, disabled, hover, press, and focus-visible
- presentation.
+- One button surface, its single/grouped visual transformation, its three
+ sizes, and its selected, dimmed, resolved, disabled, hover, press, and
+ focus-visible presentation.
- Rendering ordered participant data through `Avatar`, or for a group through
`AvatarGroup` with a non-interactive `AvatarGroupOverflow`, without making
descendants interactive.
-- Showing the unread thread count in an accent badge whenever it is above
- zero, otherwise the total represented thread count when that total is
- greater than one.
+- Showing the total represented thread count when that total is greater than
+ one, then an accent `StatusDot` whenever the unread count is above zero.
+- Rendering nothing for a resolved marker that is not selected.
- The stable `comment-pin` theming target and state reflection.
**Does not own / non-goals**
@@ -109,35 +109,37 @@ Consumer migration instructions belong in consumer docs and release notes.
Consumer prop syntax and examples remain in `CommentPin.doc.mjs`.
-| Concept | Closed values or states | Meaning | Availability by variant/orientation/state | Default | Owner | Stability | Invalid-value behavior |
-| ------------------------ | ---------------------------------------------- | -------------------------------------------------------------------------------------------------- | ----------------------------------------- | ------------------------ | ----------------------------------- | ---------------- | --------------------------------------------------------------------------------------------------------------------------- |
-| participants | non-empty ordered participant tuple | every distinct identity in the thread or group, lead first; groups display at most three circles | every pin | required non-empty tuple | product supplies; component renders | experimental Lab | TypeScript rejects an empty tuple; untyped empty input falls back to a decorative anonymous Avatar and warns in development |
-| represented thread total | positive integer | number of threads opened by the marker; values above one select grouped presentation | every marker | `1` | product | experimental Lab | non-finite, fractional, or values below one resolve to one and warn in development |
-| unread thread total | non-negative integer no greater than the total | number of represented threads with unread activity; above zero, an accent badge replaces the total | every marker | `0` | product | experimental Lab | non-finite, fractional, or negative values are ignored; values above the total are capped; both warn in development |
-| selected state | selected, not selected | whether this pin is the active annotation target | enabled and disabled | not selected | product | experimental Lab | closed boolean |
-| dimmed state | dimmed, not dimmed | whether another pin is selected; lowers prominence without disabling activation | non-selected pins | not dimmed | product | experimental Lab | closed boolean; selected paint wins when both are true |
-| resolved state | resolved, unresolved | whether the represented thread set is considered resolved | every marker | unresolved | product | experimental Lab | closed boolean |
-| disabled state | disabled, enabled | whether the marker can activate | every marker | enabled | product | experimental Lab | closed boolean |
-| accessible action name | non-empty caller-authored string | names the action and supplies the marker tooltip without generating application-specific copy | every marker | required | product | experimental Lab | TypeScript requires a string; blank content remains a caller error |
-| DOM extension | supported button `BaseProps`, styling, and ref | positions the marker and wires product-owned interaction without giving the component coordinates | every marker | no additional inputs | `architecture:public-component-api` | experimental Lab | unsupported native props remain unavailable |
+| Concept | Closed values or states | Meaning | Availability by variant/orientation/state | Default | Owner | Stability | Invalid-value behavior |
+| ------------------------ | ---------------------------------------------- | ------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | ------------------------ | ----------------------------------- | ---------------- | --------------------------------------------------------------------------------------------------------------------------- |
+| participants | non-empty ordered participant tuple | every distinct identity in the thread or group, lead first; groups display at most three circles | every pin | required non-empty tuple | product supplies; component renders | experimental Lab | TypeScript rejects an empty tuple; untyped empty input falls back to a decorative anonymous Avatar and warns in development |
+| size | `sm`, `md`, `lg` | pin height on the element-size scale (28, 32, 36px) with 22, 24, and 28px participant circles | every pin; a standalone axis, not enrolled in `architecture:component-size-cascade` | `sm` | product | experimental Lab | an unknown runtime value resolves to `sm` |
+| represented thread total | positive integer | number of threads opened by the marker; values above one select grouped presentation | every marker | `1` | product | experimental Lab | non-finite, fractional, or values below one resolve to one and warn in development |
+| unread thread total | non-negative integer no greater than the total | number of represented threads with unread activity; above zero, an accent dot follows the total | every marker | `0` | product | experimental Lab | non-finite, fractional, or negative values are ignored; values above the total are capped; both warn in development |
+| selected state | selected, not selected | whether this pin is the active annotation target | enabled and disabled | not selected | product | experimental Lab | closed boolean |
+| dimmed state | dimmed, not dimmed | whether another pin is selected; lowers prominence without disabling activation | non-selected pins | not dimmed | product | experimental Lab | closed boolean; selected paint wins when both are true |
+| resolved state | resolved, unresolved | whether the represented thread set is resolved; an unselected resolved marker renders nothing | every marker | unresolved | product | experimental Lab | closed boolean |
+| disabled state | disabled, enabled | whether the marker can activate | every marker | enabled | product | experimental Lab | closed boolean |
+| accessible action name | non-empty caller-authored string | names the action and supplies the marker tooltip without generating application-specific copy | every marker | required | product | experimental Lab | TypeScript requires a string; blank content remains a caller error |
+| DOM extension | supported button `BaseProps`, styling, and ref | positions the marker and wires product-owned interaction without giving the component coordinates | every marker | no additional inputs | `architecture:public-component-api` | experimental Lab | unsupported native props remain unavailable |
## Behavioral and layout contract
Draft requirements identify their basis so observed code is not mistaken for an
intentional decision. A `current` contract contains no unresolved rows.
-| ID | Candidate invariant | Basis | Draft review state |
-| ---- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------- | ----------------------------------------------------------- |
-| FR1 | CommentPin MUST render one button and MUST NOT accept, derive, or mutate anchor coordinates, grouping membership, thread selection, or collision layout. | product ownership boundary | product direction; pending owner approval |
-| FR2 | With one represented thread, the marker MUST render only the first participant Avatar and MUST NOT use an ordinal number as identity. | product direction | product direction; pending owner approval |
-| FR3 | With more than one represented thread, the marker MUST render its distinct participants as an AvatarGroup of at most three circles — every participant when three or fewer are distinct, otherwise the first two followed by a non-interactive `+N` AvatarGroupOverflow circle counting the rest — followed by the exact represented thread total unless FR10 applies. | product direction | product direction; pending owner approval |
-| FR4 | Participant Avatars and the overflow circle MUST use their core components' fallback and paint, MUST suppress tooltips and interaction, and MUST remain decorative descendants of the marker button. | Avatar composition and valid interaction tree | candidate implementation |
-| FR5 | `isSelected`, `isDimmed`, `isResolved`, and `isDisabled` MUST remain independent caller-controlled states. Selected presentation MUST draw a solid 2px accent outline outside the pin as a box-shadow ring over a transparent border, with no accent fill and no layout shift, MUST preserve the resting medium elevation and Avatar legibility, MUST remain distinct from the shared focus outline positioned farther outside, MUST retain a visible forced-colors fallback, and MUST win over dimming; dimmed presentation MUST lower non-selected pins' prominence without disabling activation; resolved presentation MUST reduce prominence without hiding the pin. | migration use cases and visual direction | candidate implementation; rendered visual review pending |
-| FR6 | The marker root MUST combine `xstyle`, `className`, and `style`, forward neutral button DOM/event props and its ref, and keep component-owned type, label, selected semantics, disabled state, target, and reflected states authoritative. | public component API architecture | candidate implementation |
-| FR7 | Hover paint MUST be guarded by hover capability, touch press feedback MUST use the shared press model, and keyboard focus MUST use the shared focus-visible treatment. | interaction-modality architecture | candidate implementation |
-| FR8 | The root MUST keep a speech-bubble silhouette with a fixed 4px logical bottom-start corner and full-radius logical start-start, start-end, and end-end corners in every visual state, in LTR and RTL. The 4px corner MUST NOT follow a theme radius override. | product visual direction and logical-layout requirement | candidate implementation; rendered visual review pending |
-| FR9 | The root's transform origin and documented absolute-placement convention MUST use the logical bottom-start corner. A host maps its anchor point to that corner by translating the pin upward by its full height and MUST NOT center the pin over the point. | product placement direction | candidate implementation; rendered placement review pending |
-| FR10 | When `unreadCount` resolves above zero, the marker MUST show that number in an accent badge in place of the thread total, on single and grouped markers alike; the badge MUST keep a visible forced-colors treatment and MUST remain decorative. | product direction | product direction; rendered visual review pending |
+| ID | Candidate invariant | Basis | Draft review state |
+| ---- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------- | ----------------------------------------------------------- |
+| FR1 | CommentPin MUST render one button and MUST NOT accept, derive, or mutate anchor coordinates, grouping membership, thread selection, or collision layout. | product ownership boundary | product direction; pending owner approval |
+| FR2 | With one represented thread, the marker MUST render only the first participant Avatar and MUST NOT use an ordinal number as identity. | product direction | product direction; pending owner approval |
+| FR3 | With more than one represented thread, the marker MUST render its distinct participants as an AvatarGroup of at most three circles — every participant when three or fewer are distinct, otherwise the first two followed by a non-interactive AvatarGroupOverflow circle that shows an ellipsis and no number — followed by the exact represented thread total unless FR10 applies. | product direction | product direction; pending owner approval |
+| FR4 | Participant Avatars and the overflow circle MUST use their core components' fallback and paint, MUST suppress tooltips and interaction, and MUST remain decorative descendants of the marker button. | Avatar composition and valid interaction tree | candidate implementation |
+| FR5 | `isSelected`, `isDimmed`, `isResolved`, and `isDisabled` MUST remain independent caller-controlled states. Selected presentation MUST draw a solid 2px accent outline outside the pin as a box-shadow ring over a transparent border, with no accent fill and no layout shift, MUST preserve the resting medium elevation and Avatar legibility, MUST remain distinct from the shared focus outline positioned farther outside, MUST retain a visible forced-colors fallback, and MUST win over dimming; dimmed presentation MUST lower non-selected pins' prominence without disabling activation; an unselected resolved marker MUST render nothing, and a selected resolved marker MUST take the selected presentation. | migration use cases and visual direction | candidate implementation; rendered visual review pending |
+| FR6 | The marker root MUST combine `xstyle`, `className`, and `style`, forward neutral button DOM/event props and its ref, and keep component-owned type, label, selected semantics, disabled state, target, and reflected states authoritative. | public component API architecture | candidate implementation |
+| FR7 | Hover paint MUST be guarded by hover capability, touch press feedback MUST use the shared press model, and keyboard focus MUST use the shared focus-visible treatment. | interaction-modality architecture | candidate implementation |
+| FR8 | The root MUST keep a speech-bubble silhouette with a fixed 2px logical bottom-start corner and fully round logical start-start, start-end, and end-end corners of half the pin's height in every visual state, in LTR and RTL. The 2px corner MUST NOT follow a theme radius override, and no corner MAY be large enough to make the browser scale the corners to fit (the CSS corner-overlap rule), which would erase the 2px corner. | product visual direction and logical-layout requirement | candidate implementation; rendered visual review pending |
+| FR9 | The root's transform origin and documented absolute-placement convention MUST use the logical bottom-start corner. A host maps its anchor point to that corner by translating the pin upward by its full height and MUST NOT center the pin over the point. | product placement direction | candidate implementation; rendered placement review pending |
+| FR10 | When `unreadCount` resolves above zero, the marker MUST show an accent `StatusDot` after the thread total, or after the participant on a single marker, and MUST NOT show the unread number; the dot MUST keep a visible forced-colors treatment and MUST remain decorative. | product direction | product direction; rendered visual review pending |
+| FR11 | `size` MUST set the root height and minimum width to `--size-element-sm`, `--size-element-md`, or `--size-element-lg` and draw 22, 24, or 28px participant circles, and the reflected size MUST match. Padding MUST be equal on every side and equal to the inset that centers one participant circle in that height; a grouped marker MUST sit its first AvatarGroup ring inside the start padding, so participant circles keep that inset from the start edge. The trailing total or unread dot MUST add `--spacing-1` of end padding, so neither crowds the edge. | product visual direction | product direction; rendered visual review pending |
### Allowed variation
@@ -156,15 +158,16 @@ intentional decision. A `current` contract contains no unresolved rows.
| State | Required invariant | Allowed variation |
| ------------------------ | --------------------------------------------------------------------------------------- | ------------------------------------------------------------ |
-| Single | first participant Avatar; no visible count unless unread | identity, selected/dimmed/resolved/disabled state, placement |
+| Single | first participant Avatar; no visible count; an accent dot after it when unread | identity, selected/dimmed/resolved/disabled state, placement |
| Grouped, one identity | one Avatar plus total thread count | count and states |
| Grouped, two or three | every distinct participant Avatar plus total thread count | ordered identities, count, and states |
-| Grouped, more than three | first two distinct Avatars, a `+N` overflow circle, and total thread count | ordered identities, overflow count, and states |
-| Unread | accent badge with the unread count replaces the total on single and grouped markers | unread count and other states |
+| Grouped, more than three | first two distinct Avatars, an ellipsis overflow circle, and total thread count | ordered identities and states |
+| Unread | accent dot after the total, or after the participant on a single marker | other states |
+| Sizes | 28, 32, or 36px tall with 22, 24, or 28px circles and the same inset on every side | every other state |
| Selected | active accent treatment preserves Avatar and count legibility and wins over dimming | theme paint |
-| Dimmed | lower opacity identifies a non-selected sibling without disabling activation | resolved and disabled may also apply |
-| Resolved | lower-prominence treatment preserves activation and identity | selected, dimmed, and disabled may also apply |
-| Disabled | native disabled button does not activate and is removed from the sequential focus order | selected/resolved representation remains visible |
+| Dimmed | lower opacity identifies a non-selected sibling without disabling activation | disabled may also apply |
+| Resolved | renders nothing unless selected; selected, it takes the selected treatment | disabled may also apply |
+| Disabled | native disabled button does not activate and is removed from the sequential focus order | selected representation remains visible |
### Transformation and precedence order
@@ -175,18 +178,21 @@ intentional decision. A `current` contract contains no unresolved rows.
- **ORD2 — Participants.** Preserve caller order and remove duplicate IDs. A
single marker takes the first participant; a grouped marker shows every
distinct participant when three or fewer remain, otherwise the first two plus
- an overflow count of the rest.
-- **ORD3 — Count display.** A resolved unread count above zero replaces the
- thread total; otherwise a grouped marker shows the total.
-- **ORD4 — Paint.** Base surface, resolved treatment, dimmed treatment, selected
- treatment, then disabled treatment compose in that order. Selected identity
- remains fully prominent, and disabled interaction always wins.
+ an ellipsis overflow circle.
+- **ORD3 — Count display.** A grouped marker shows the total; a resolved unread
+ count above zero adds an accent dot after it, or after the participant on a
+ single marker.
+- **ORD4 — Paint.** An unselected resolved marker renders nothing. Otherwise
+ base surface, dimmed treatment, selected treatment, then disabled treatment
+ compose in that order. Selected identity remains fully prominent, and
+ disabled interaction always wins.
### Performance and resources
- **PR1 — Bounded anatomy.** Rendering work is bounded to at most three
- participant circles (Avatars plus overflow indicator) and one count element
- regardless of the number of represented threads or supplied participants.
+ participant circles (Avatars plus overflow indicator), one count element,
+ and one unread dot regardless of the number of represented threads or
+ supplied participants.
- **PR2 — Shared interaction resources.** Touch feedback uses the shared
document-level press controller and adds no marker-local listener, observer,
timer, or state.
@@ -204,7 +210,7 @@ durable constraints and their verification target.
outside, so the two states remain distinguishable.
Hosts clear the selection when the selected pin is activated again.
- **AR3 — Decorative descendants.** Participant Avatars, the overflow circle,
- the visible thread total, and the unread badge are hidden from assistive
+ the visible thread total, and the unread dot are hidden from assistive
technology because the caller-authored button label owns the complete action
name.
- **AR4 — Tooltip.** The action label is available visually on pointer hover and
@@ -218,30 +224,33 @@ durable constraints and their verification target.
## Design relationships
-| Anatomy or state | Design requirement | Representation authority | Hierarchy role | Component contract |
-| ------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------- | ----------------------- | ------------------ |
-| Marker surface | Compact floating surface distinguishes the action from underlying content | candidate implementation pending visual review | prominent anchor | FR1, FR5, FR7 |
-| Representative avatars | Human identity remains the primary recognition cue; groups cap at three circles | human-selected product direction | primary content | FR2–FR4 |
-| Overflow indicator | A `+N` circle summarizes participants beyond the first two without growing the pin past three circles | human-selected product direction | supporting content | FR3, FR4, AR3 |
-| Group count | Count communicates quantity without becoming ordinal identity | human-selected product direction | supporting content | FR3, AR3 |
-| Unread badge | Accent badge keeps unread activity visible and outranks the thread total | human-selected product direction | supporting state signal | FR10, AR3 |
-| Selected/dimmed/resolved states | Selected draws one solid 2px accent outline outside the pin with no fill, distinct from the farther-out focus outline; non-selected siblings dim without disabling; resolved lowers prominence | human-selected product direction | supporting state signal | FR5, AR2, AR6 |
-| Speech-bubble corner | Logical bottom-start stays fixed at 4px and mirrors in RTL; the other three logical corners stay fully rounded | human-selected product direction | silhouette cue | FR8 |
-| Placement origin | Absolute host coordinates map to logical bottom-start, never the center | human-selected product direction | spatial anchor | FR9 |
+| Anatomy or state | Design requirement | Representation authority | Hierarchy role | Component contract |
+| ------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------- | ----------------------- | ------------------ |
+| Marker surface | Compact floating surface distinguishes the action from underlying content | candidate implementation pending visual review | prominent anchor | FR1, FR5, FR7 |
+| Representative avatars | Human identity remains the primary recognition cue; groups cap at three circles | human-selected product direction | primary content | FR2–FR4 |
+| Overflow indicator | An ellipsis circle summarizes participants beyond the first two without a number, so it never competes with the thread count | human-selected product direction | supporting content | FR3, FR4, AR3 |
+| Group count | Count communicates quantity without becoming ordinal identity | human-selected product direction | supporting content | FR3, AR3 |
+| Unread dot | An accent dot after the total marks unread activity without a second number | human-selected product direction | supporting state signal | FR10, AR3 |
+| Selected/dimmed/resolved states | Selected draws one solid 2px accent outline outside the pin with no fill, distinct from the farther-out focus outline; non-selected siblings dim without disabling; resolved disappears unless selected | human-selected product direction | supporting state signal | FR5, AR2, AR6 |
+| Speech-bubble corner | Logical bottom-start stays fixed at 2px and mirrors in RTL; the other three logical corners stay fully rounded | human-selected product direction | silhouette cue | FR8 |
+| Placement origin | Absolute host coordinates map to logical bottom-start, never the center | human-selected product direction | spatial anchor | FR9 |
+| Sizes | Three heights on the element-size scale; participant circles, overflow, and count keep one inset from every edge | human-selected product direction | density | FR11 |
### Design decisions
<!-- design-decisions:v1 -->
-| ID | Decision | Intent or reason | Applies to | Allowed variation |
-| --- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------ | ----------------------------------------------------------------------------------------------- |
-| DD1 | Participant Avatars, not ordinal numbers, identify comment pins. | Ordinal identity becomes hard to scan and manage as annotation volume grows. | single and grouped markers | identity data and Avatar fallback may vary |
-| DD2 | A grouped marker shows at most three participant circles — two Avatars plus a `+N` overflow when more than three people participate — and separately shows the thread total. | Identity and quantity answer different questions; capping the facepile keeps grouped pins compact and scannable as participation grows. | grouped markers | caller chooses participant order and grouping policy |
-| DD3 | Selected paint is one solid 2px accent outline outside the pin, drawn as a box-shadow ring over a transparent border; it preserves the pin's medium elevation and adds no accent fill; the shared focus outline sits farther outside. | A single 2px outline reads as selection rather than input chrome, shifts no layout, preserves the Avatar area, and remains distinct from keyboard focus. | selected and selected-plus-focused states | theme accent and elevation tokens may vary; the outline width, placement, and separation do not |
-| DD4 | The logical bottom-start corner is a fixed 4px logical longhand; the other three logical corners use the full-radius token. | A theme may enlarge `--radius-inner`, so a literal keeps the speech-bubble cue exactly 4px, and explicit logical longhands avoid shorthand cascade collisions and mirror in RTL by construction. | every pin and visual state | the three rounded corners follow the theme; the 4px anchor corner does not vary |
-| DD5 | Absolute anchor coordinates map to the pin's logical bottom-start corner, not its center. | The speech-bubble corner stays attached to the annotated point while the body grows toward block-start and inline-end. | pins positioned over content or in margins | host coordinates and transforms may vary; the anchor corner does not |
-| DD6 | When a pin is selected, sibling pins use controlled dimming and remain enabled. | The active target gains visual focus without preventing a viewer from switching directly to another pin. | sets of pins with one active target | host chooses which siblings belong to the focused set; selected always wins over dimming |
-| DD7 | Unread threads show their count in an accent badge that replaces the thread total. | Unread activity is the actionable signal, so it outranks quantity whenever present, including on single-thread pins. | single and grouped markers | theme accent may vary; the replacement precedence does not |
+| ID | Decision | Intent or reason | Applies to | Allowed variation |
+| --- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------ | ----------------------------------------------------------------------------------------------- |
+| DD1 | Participant Avatars, not ordinal numbers, identify comment pins. | Ordinal identity becomes hard to scan and manage as annotation volume grows. | single and grouped markers | identity data and Avatar fallback may vary |
+| DD2 | A grouped marker shows at most three participant circles — two Avatars plus an ellipsis overflow circle when more than three people participate — and separately shows the thread total. | Identity and quantity answer different questions; capping the facepile keeps grouped pins compact and scannable as participation grows, and an ellipsis keeps the total the pin's only number. | grouped markers | caller chooses participant order and grouping policy; themes choose the ellipsis glyph |
+| DD3 | Selected paint is one solid 2px accent outline outside the pin, drawn as a box-shadow ring over a transparent border; it preserves the pin's medium elevation and adds no accent fill; the shared focus outline sits farther outside. | A single 2px outline reads as selection rather than input chrome, shifts no layout, preserves the Avatar area, and remains distinct from keyboard focus. | selected and selected-plus-focused states | theme accent and elevation tokens may vary; the outline width, placement, and separation do not |
+| DD4 | The logical bottom-start corner is a fixed 2px logical longhand; the other three logical corners are half the pin's height. | A theme may enlarge `--radius-inner`, so a literal keeps the speech-bubble cue exactly 2px. Half-height corners are fully round without the 9999px full-radius token, which makes the browser scale all four corners to fit and erases the small one. Explicit logical longhands avoid shorthand cascade collisions and mirror in RTL by construction. | every pin and visual state | the three rounded corners follow the element-size tokens; the 2px anchor corner does not vary |
+| DD5 | Absolute anchor coordinates map to the pin's logical bottom-start corner, not its center. | The speech-bubble corner stays attached to the annotated point while the body grows toward block-start and inline-end. | pins positioned over content or in margins | host coordinates and transforms may vary; the anchor corner does not |
+| DD6 | When a pin is selected, sibling pins use controlled dimming and remain enabled. | The active target gains visual focus without preventing a viewer from switching directly to another pin. | sets of pins with one active target | host chooses which siblings belong to the focused set; selected always wins over dimming |
+| DD7 | Unread threads add an accent `StatusDot` after the thread total, or after the participant on a single marker; the unread number is not shown. | A dot keeps unread activity visible on every pin without a second number that competes with the total. | single and grouped markers | theme accent may vary; the dot's place after the total does not |
+| DD8 | Sizes `sm`, `md`, and `lg` are 28, 32, and 36px tall on the element-size tokens with 22, 24, and 28px participant circles, padded equally on every side; a grouped marker's first ring sits in the start padding, and the trailing total or dot adds `--spacing-1` of end padding. | Hosts match the pin to the density of what it annotates; one inset on every edge keeps identity and count centered and gives single and grouped pins the same edge rhythm. | every pin | themes may change the element-size tokens; the circle diameters and the equal inset do not vary |
+| DD9 | A resolved marker renders nothing unless it is selected. | Resolved discussion leaves the content; a selected marker stays so a thread the reader opened, or resolved from its popover, keeps its anchor until the host clears the selection. | resolved markers | the host decides which threads are resolved and which is selected |
### Theming anatomy
@@ -260,7 +269,9 @@ durable constraints and their verification target.
}
},
"Group count": {"inherits": "comment-pin"},
- "Unread badge": {"inherits": "comment-pin"}
+ "Unread dot": {
+ "delegatesTo": {"owner": "component:StatusDot", "target": "status-dot"}
+ }
}
```
@@ -281,13 +292,13 @@ durable constraints and their verification target.
## Verification map
-| Contract | Verification | Representative states | Mutation or failure expectation | Audit section |
-| ---------------------------- | ---------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------ |
-| FR1–FR4, FR10, PR1, AR1, AR3 | `CommentPin.test.tsx` | single, grouped within three, grouped overflow, unread single and grouped, invalid unread, duplicate identities, empty participants | extra anatomy, more than three circles, a wrong overflow count, an unread count hidden behind the total, ordinal identity, lost count, or interactive/avatar semantics fail focused assertions | `audit:CommentPin/behavior` |
-| FR5, FR8, FR9, AR2, AR5, AR6 | focused tests plus Storybook state matrix, placement example, and docsite showcase | selected, selected+focused, dimmed, forced colors, resolved, disabled, LTR/RTL silhouette and placement | missing state reflection, disabled dimmed siblings, merged selection/focus cues, or centered/non-mirroring placement fails semantic/source assertions or rendered review | `audit:CommentPin/states` |
-| FR6 | focused passthrough, ref, stable-target, and state-reflection tests | custom DOM/style inputs and every state | dropped inputs/ref or overwritten component-owned semantics fail focused assertions | `audit:CommentPin/api-theming` |
-| FR7, PR2, AR4 | focus, hover-capability source inspection, tooltip test, build scan | pointer, keyboard, touch model | unguarded hover, missing focus treatment, or local press machinery fails source/test/build checks | `audit:CommentPin/interaction` |
-| Documentation and surface | component docs, block metadata, root export, Storybook, and knowledge check | public examples and component discovery | missing or stale discoverability, syntax, boundaries, or relationships fail repository checks | `audit:CommentPin/docs` |
+| Contract | Verification | Representative states | Mutation or failure expectation | Audit section |
+| ---------------------------------- | ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------ |
+| FR1–FR4, FR10, FR11, PR1, AR1, AR3 | `CommentPin.test.tsx` plus the Storybook size matrix | single, grouped within three, grouped overflow, unread single and grouped, invalid unread, duplicate identities, empty participants, each size | extra anatomy, more than three circles, a numeric overflow, an unread number or a missing unread dot, ordinal identity, lost count, a size whose circles or reflected value disagree, or interactive/avatar semantics fail focused assertions | `audit:CommentPin/behavior` |
+| FR5, FR8, FR9, AR2, AR5, AR6 | focused tests plus Storybook state matrix, placement example, and docsite showcase | selected, selected+focused, dimmed, forced colors, resolved hidden and resolved selected, disabled, LTR/RTL silhouette and placement | missing state reflection, disabled dimmed siblings, merged selection/focus cues, or centered/non-mirroring placement fails semantic/source assertions or rendered review | `audit:CommentPin/states` |
+| FR6 | focused passthrough, ref, stable-target, and state-reflection tests | custom DOM/style inputs and every state | dropped inputs/ref or overwritten component-owned semantics fail focused assertions | `audit:CommentPin/api-theming` |
+| FR7, PR2, AR4 | focus, hover-capability source inspection, tooltip test, build scan | pointer, keyboard, touch model | unguarded hover, missing focus treatment, or local press machinery fails source/test/build checks | `audit:CommentPin/interaction` |
+| Documentation and surface | component docs, block metadata, root export, Storybook, and knowledge check | public examples and component discovery | missing or stale discoverability, syntax, boundaries, or relationships fail repository checks | `audit:CommentPin/docs` |
## Decision log
@@ -296,7 +307,7 @@ intent await component-owner and visual review.
## Open questions
-- **OQ1 — Does the selected/resolved state treatment preserve enough contrast on
+- **OQ1 — Does the selected state treatment preserve enough contrast on
representative images and every theme while remaining distinct over both
image content and page margins?** (`human-design`)
diff --git a/packages/lab/src/CommentPin/CommentPin.test.tsx b/packages/lab/src/CommentPin/CommentPin.test.tsx
index 817777af24..eee5ba1e7c 100644
--- a/packages/lab/src/CommentPin/CommentPin.test.tsx
+++ b/packages/lab/src/CommentPin/CommentPin.test.tsx
@@ -43,7 +43,7 @@ describe('CommentPin', () => {
).toHaveAttribute('data-grouped', 'grouped');
});
- it('caps a group at three circles with a +N overflow beyond three people', () => {
+ it('caps a group at three circles with an ellipsis overflow beyond three people', () => {
const {container} = render(
<CommentPin
label="Open 6 grouped annotations from Ada, Lin, and 3 others"
@@ -54,12 +54,53 @@ describe('CommentPin', () => {
expect(container.querySelectorAll('.astryx-avatar')).toHaveLength(2);
const overflow = container.querySelector('.astryx-avatar-group-overflow');
- expect(overflow).toHaveTextContent('+3');
+ // An ellipsis, not `+3`: the thread total stays the pin's only number.
+ expect(overflow?.querySelector('svg')).not.toBeNull();
+ expect(overflow).toHaveTextContent(/^$/);
expect(overflow?.closest('[aria-hidden="true"]')).not.toBeNull();
expect(screen.getByText('6')).toBeInTheDocument();
});
- it('shows the unread count in an accent badge in place of the total', () => {
+ it.each([
+ [undefined, 'sm', '22px'],
+ ['sm', 'sm', '22px'],
+ ['md', 'md', '24px'],
+ ['lg', 'lg', '28px'],
+ ] as const)(
+ 'size %s reflects %s and draws %s participant circles',
+ (size, reflected, avatarPx) => {
+ const {container} = render(
+ <CommentPin
+ label="Open 6 grouped annotations"
+ participants={[ADA, LIN, MIRA, NOAH, SAM]}
+ threadCount={6}
+ size={size}
+ />,
+ );
+
+ const pin = screen.getByRole('button', {
+ name: 'Open 6 grouped annotations',
+ });
+ expect(pin).toHaveAttribute('data-size', reflected);
+ const avatars = container.querySelectorAll('.astryx-avatar');
+ expect(avatars).toHaveLength(2);
+ for (const avatar of avatars) {
+ expect(avatar.getAttribute('style') ?? '').toContain(avatarPx);
+ }
+ },
+ );
+
+ it('sizes a single participant with the pin', () => {
+ const {container} = render(
+ <CommentPin label="Open annotation" participants={[ADA]} size="lg" />,
+ );
+
+ expect(
+ container.querySelector('.astryx-avatar')?.getAttribute('style') ?? '',
+ ).toContain('28px');
+ });
+
+ it('marks unread threads with an accent dot after the total', () => {
const {container} = render(
<CommentPin
label="Open 4 grouped annotations, 2 unread"
@@ -73,13 +114,20 @@ describe('CommentPin', () => {
name: 'Open 4 grouped annotations, 2 unread',
});
expect(pin).toHaveAttribute('data-unread', 'unread');
- expect(screen.getByText('2')).toHaveAttribute('aria-hidden', 'true');
- expect(screen.queryByText('4')).not.toBeInTheDocument();
+ const dot = container.querySelector('.astryx-status-dot');
+ expect(dot).toHaveAttribute('data-variant', 'accent');
+ expect(dot?.closest('[aria-hidden="true"]')).not.toBeNull();
+ // The total stays; the unread count is the dot, not a second number.
+ expect(screen.getByText('4')).toBeInTheDocument();
+ expect(screen.queryByText('2')).not.toBeInTheDocument();
+ expect(dot?.compareDocumentPosition(screen.getByText('4')) ?? 0).toBe(
+ Node.DOCUMENT_POSITION_PRECEDING,
+ );
expect(container.querySelectorAll('.astryx-avatar')).toHaveLength(2);
});
- it('shows an unread badge on a single-thread pin', () => {
- render(
+ it('marks an unread single-thread pin with a dot and no number', () => {
+ const {container} = render(
<CommentPin
label="Open unread annotation from Ada"
participants={[ADA]}
@@ -92,17 +140,18 @@ describe('CommentPin', () => {
});
expect(pin).toHaveAttribute('data-unread', 'unread');
expect(pin).not.toHaveAttribute('data-grouped');
- expect(screen.getByText('1')).toBeInTheDocument();
+ expect(container.querySelector('.astryx-status-dot')).not.toBeNull();
+ expect(pin).toHaveTextContent(/^AL$/);
});
it.each([
- [-1, null],
- [1.5, null],
- [Number.NaN, null],
- [9, '3'],
+ [-1, false],
+ [1.5, false],
+ [Number.NaN, false],
+ [9, true],
])(
'normalizes unreadCount %s and warns in development',
- async (unreadCount, expectedBadge) => {
+ async (unreadCount, isUnread) => {
const warning = vi.spyOn(console, 'warn').mockImplementation(() => {});
const {container, unmount} = render(
<CommentPin
@@ -114,13 +163,14 @@ describe('CommentPin', () => {
);
const pin = container.querySelector('.astryx-comment-pin');
- if (expectedBadge == null) {
- expect(pin).not.toHaveAttribute('data-unread');
- expect(screen.getByText('3')).toBeInTheDocument();
- } else {
+ if (isUnread) {
expect(pin).toHaveAttribute('data-unread', 'unread');
- expect(screen.getByText(expectedBadge)).toBeInTheDocument();
+ expect(container.querySelector('.astryx-status-dot')).not.toBeNull();
+ } else {
+ expect(pin).not.toHaveAttribute('data-unread');
+ expect(container.querySelector('.astryx-status-dot')).toBeNull();
}
+ expect(screen.getByText('3')).toBeInTheDocument();
await waitFor(() =>
expect(warning).toHaveBeenCalledWith(
expect.stringContaining('unreadCount` must be a finite non-negative'),
@@ -148,7 +198,9 @@ describe('CommentPin', () => {
.querySelector('.astryx-avatar')
?.closest('[aria-hidden="true"]'),
).toHaveAttribute('aria-hidden', 'true');
- expect(screen.getByText('4')).toHaveAttribute('aria-hidden', 'true');
+ expect(
+ screen.getByText('4').closest('[aria-hidden="true"]'),
+ ).not.toBeNull();
});
it('keeps a single marker to one representative even when more are supplied', () => {
@@ -183,6 +235,33 @@ describe('CommentPin', () => {
expect(marker).toHaveAttribute('data-disabled', 'disabled');
});
+ it('renders nothing for a resolved pin unless it is selected', () => {
+ const {container, rerender} = render(
+ <CommentPin
+ label="Open resolved annotation from Ada"
+ participants={[ADA]}
+ isResolved
+ />,
+ );
+
+ expect(container.querySelector('.astryx-comment-pin')).toBeNull();
+ expect(screen.queryByRole('button')).not.toBeInTheDocument();
+
+ rerender(
+ <CommentPin
+ label="Open resolved annotation from Ada"
+ participants={[ADA]}
+ isResolved
+ isSelected
+ />,
+ );
+ const pin = screen.getByRole('button', {
+ name: 'Open resolved annotation from Ada',
+ });
+ expect(pin).toHaveAttribute('data-resolved', 'resolved');
+ expect(pin).toHaveAttribute('data-selected', 'selected');
+ });
+
it('dims non-selected pins without disabling selection changes', () => {
const onClick = vi.fn();
render(
diff --git a/packages/lab/src/CommentPin/CommentPin.tsx b/packages/lab/src/CommentPin/CommentPin.tsx
index 9861895c78..0c7166d786 100644
--- a/packages/lab/src/CommentPin/CommentPin.tsx
+++ b/packages/lab/src/CommentPin/CommentPin.tsx
@@ -5,8 +5,10 @@
/**
* @file CommentPin.tsx
* @input Ordered participants (grouped pins show at most three circles),
- * total and unread represented thread counts, controlled
- * selected/dimmed/resolved/disabled state, and button DOM props
+ * total and unread represented thread counts (unread shows as a dot), a
+ * size on the element-size
+ * scale, controlled selected/dimmed/resolved/disabled state, and button DOM
+ * props
* @output Exports the avatar-first CommentPin button and its public types
* @position Lab collaboration primitive for annotation anchors over content or
* in content margins; callers own grouping, coordinates, and opened content
@@ -22,18 +24,19 @@
import * as stylex from '@stylexjs/stylex';
import type {BaseProps} from '@astryxdesign/core';
-import {Avatar} from '@astryxdesign/core/Avatar';
+import {Avatar, type AvatarSize} from '@astryxdesign/core/Avatar';
import {AvatarGroup, AvatarGroupOverflow} from '@astryxdesign/core/AvatarGroup';
import {
useDevWarning,
useMergedRefs,
usePressFeedback,
} from '@astryxdesign/core/hooks';
+import {Icon, type IconSize} from '@astryxdesign/core/Icon';
+import {StatusDot} from '@astryxdesign/core/StatusDot';
import {
borderVars,
colorVars,
fontWeightVars,
- radiusVars,
shadowVars,
sizeVars,
spacingVars,
@@ -48,6 +51,9 @@ import {
themeProps,
} from '@astryxdesign/core/utils';
+/** Pin heights on the shared element-size scale: 28, 32, or 36px. */
+export type CommentPinSize = 'sm' | 'md' | 'lg';
+
/** Identity data for one representative shown inside a CommentPin. */
export interface CommentPinParticipant {
/** Stable identity used to remove duplicate representatives. */
@@ -74,10 +80,17 @@ export interface CommentPinProps extends Omit<
* Ordered participants, lead first. A single marker shows the first. A
* grouped marker shows distinct IDs as an AvatarGroup of at most three
* circles: every participant when three or fewer are distinct, otherwise the
- * first two plus a `+N` overflow circle. Pass every distinct participant so
- * the overflow count is accurate.
+ * first two plus an ellipsis overflow circle. Pass every distinct
+ * participant so the overflow appears only when more than three people
+ * participate.
*/
participants: readonly [CommentPinParticipant, ...CommentPinParticipant[]];
+ /**
+ * Pin height on the element-size scale: `sm` 28px, `md` 32px, `lg` 36px,
+ * with 22px, 24px, and 28px participant circles.
+ * @default 'sm'
+ */
+ size?: CommentPinSize;
/**
* Total number of threads represented by this marker. Values above one use
* the grouped presentation and show the exact total.
@@ -86,8 +99,9 @@ export interface CommentPinProps extends Omit<
threadCount?: number;
/**
* Number of represented threads with unread activity. When above zero, an
- * accent badge shows this number in place of the thread total, on single
- * and grouped pins alike. Values above `threadCount` are capped.
+ * accent status dot appears at the end of the pin: after the thread total,
+ * or after the participant on a single pin. Values above `threadCount` are
+ * capped.
* @default 0
*/
unreadCount?: number;
@@ -98,7 +112,11 @@ export interface CommentPinProps extends Omit<
* disabling it, so it remains available to switch selection.
*/
isDimmed?: boolean;
- /** Whether every thread represented by this pin is resolved. */
+ /**
+ * Whether every thread represented by this pin is resolved. A resolved pin
+ * renders nothing unless it is selected, so resolved discussion leaves the
+ * content while a thread the reader opened keeps its anchor.
+ */
isResolved?: boolean;
/** Whether activation is unavailable. */
isDisabled?: boolean;
@@ -118,21 +136,16 @@ const styles = stylex.create({
default: 'left bottom',
':is([dir="rtl"] *)': 'right bottom',
},
- minWidth: sizeVars['--size-element-sm'],
- height: sizeVars['--size-element-sm'],
margin: 0,
- padding: spacingVars['--spacing-0-5'],
borderWidth: borderVars['--border-width'],
borderStyle: 'solid',
borderColor: 'transparent',
- // Speech-bubble silhouette: three fully rounded logical corners and a
- // fixed 4px logical bottom-start corner. The literal is intentional:
- // themes may enlarge `--radius-inner`, which would soften the anchor cue.
- // Logical longhands mirror the corner in RTL by construction.
- borderStartStartRadius: radiusVars['--radius-full'],
- borderStartEndRadius: radiusVars['--radius-full'],
- borderEndEndRadius: radiusVars['--radius-full'],
- borderEndStartRadius: '4px',
+ // Speech-bubble silhouette: a fixed 2px logical bottom-start corner; the
+ // other three corners are half the pin's height (see `sizeStyles`). The
+ // literal is intentional: no radius token is 2px, and themes may change
+ // `--radius-inner`, which would soften the anchor cue. Logical longhands
+ // mirror the corner in RTL by construction.
+ borderEndStartRadius: '2px',
backgroundColor: colorVars['--color-background-popover'],
backgroundImage: 'none',
boxShadow: shadowVars['--shadow-med'],
@@ -151,8 +164,6 @@ const styles = stylex.create({
withCount: {
justifyContent: 'flex-start',
gap: spacingVars['--spacing-1'],
- paddingInlineStart: spacingVars['--spacing-0-5'],
- paddingInlineEnd: spacingVars['--spacing-2'],
},
selected: {
// Native buttons keep ButtonFace/ButtonText under forced colors unless the
@@ -182,28 +193,6 @@ const styles = stylex.create({
'@media (forced-colors: active)': 'HighlightText',
},
},
- resolved: {
- // This state authors Canvas colors in forced-colors mode, so opt the native
- // button out of ButtonFace/ButtonText remapping and author both sides.
- forcedColorAdjust: 'none',
- borderColor: {
- default: 'transparent',
- '@media (forced-colors: active)': 'CanvasText',
- },
- backgroundColor: {
- default: colorVars['--color-background-muted'],
- '@media (forced-colors: active)': 'Canvas',
- },
- boxShadow: 'none',
- color: {
- default: colorVars['--color-text-secondary'],
- '@media (forced-colors: active)': 'CanvasText',
- },
- opacity: {
- default: 0.72,
- '@media (forced-colors: active)': 1,
- },
- },
dimmed: {
opacity: {
default: 0.4,
@@ -222,43 +211,97 @@ const styles = stylex.create({
alignItems: 'center',
flexShrink: 0,
},
- // AvatarGroupOverflow pads its count for multi-digit pills; inside this
- // compact pin a short `+N` must stay a circle the size of its sibling
- // Avatars, while longer counts still grow from the shared minimum width.
+ // AvatarGroup draws every face inside a 2px surface ring. Sitting the first
+ // ring in the start padding keeps the faces themselves as far from the start
+ // edge as from the top and bottom, as on a single pin.
+ groupedRail: {
+ marginInlineStart: -2,
+ },
+ // AvatarGroupOverflow pads its content for multi-digit `+N` pills; the
+ // ellipsis inside this pin stays a circle the size of its sibling Avatars.
overflowCircle: {
paddingInline: 0,
},
+ // The thread total and then the unread dot follow the participants. The
+ // end padding gives whichever comes last room before the pin's edge, so a
+ // number or dot never crowds it.
+ trailing: {
+ display: 'inline-flex',
+ alignItems: 'center',
+ gap: spacingVars['--spacing-1'],
+ paddingInlineEnd: spacingVars['--spacing-1'],
+ },
count: {
- display: 'inline-block',
- minWidth: spacingVars['--spacing-3'],
color: 'inherit',
fontVariantNumeric: 'tabular-nums',
- textAlign: 'center',
},
- unreadBadge: {
- // Native buttons remap colors under forced colors; author the full pair.
+ // StatusDot paints its plate with a background, which forced colors would
+ // erase; there it takes the pin's own text color, so it shows in every state.
+ unreadDot: {
forcedColorAdjust: 'none',
- display: 'inline-flex',
- alignItems: 'center',
- justifyContent: 'center',
- boxSizing: 'border-box',
- minWidth: spacingVars['--spacing-5'],
- height: spacingVars['--spacing-5'],
- paddingInline: spacingVars['--spacing-1'],
- borderRadius: radiusVars['--radius-full'],
- backgroundColor: {
- default: colorVars['--color-accent'],
- '@media (forced-colors: active)': 'Highlight',
- },
color: {
default: colorVars['--color-on-accent'],
- '@media (forced-colors: active)': 'HighlightText',
+ '@media (forced-colors: active)': 'inherit',
},
- fontVariantNumeric: 'tabular-nums',
- lineHeight: 1,
+ backgroundColor: {
+ default: colorVars['--color-accent'],
+ '@media (forced-colors: active)': 'currentColor',
+ },
+ },
+});
+
+// Each size pairs an element-size height with a participant circle diameter
+// (see AVATAR_SIZE). The padding is the inset that centers that circle in the
+// height, applied on every side: the avatars and overflow sit the same
+// distance from all four edges. The three round corners are half the height,
+// which is fully round: the 9999px full-radius token would make the browser
+// scale every corner down to fit the box (the CSS corner-overlap rule) and
+// shrink the 2px anchor corner to nothing.
+const sizeStyles = stylex.create({
+ sm: {
+ minWidth: sizeVars['--size-element-sm'],
+ height: sizeVars['--size-element-sm'],
+ padding: `calc((${sizeVars['--size-element-sm']} - 22px) / 2 - ${borderVars['--border-width']})`,
+ borderStartStartRadius: `calc(${sizeVars['--size-element-sm']} / 2)`,
+ borderStartEndRadius: `calc(${sizeVars['--size-element-sm']} / 2)`,
+ borderEndEndRadius: `calc(${sizeVars['--size-element-sm']} / 2)`,
+ },
+ md: {
+ minWidth: sizeVars['--size-element-md'],
+ height: sizeVars['--size-element-md'],
+ padding: `calc((${sizeVars['--size-element-md']} - 24px) / 2 - ${borderVars['--border-width']})`,
+ borderStartStartRadius: `calc(${sizeVars['--size-element-md']} / 2)`,
+ borderStartEndRadius: `calc(${sizeVars['--size-element-md']} / 2)`,
+ borderEndEndRadius: `calc(${sizeVars['--size-element-md']} / 2)`,
+ },
+ lg: {
+ minWidth: sizeVars['--size-element-lg'],
+ height: sizeVars['--size-element-lg'],
+ padding: `calc((${sizeVars['--size-element-lg']} - 28px) / 2 - ${borderVars['--border-width']})`,
+ borderStartStartRadius: `calc(${sizeVars['--size-element-lg']} / 2)`,
+ borderStartEndRadius: `calc(${sizeVars['--size-element-lg']} / 2)`,
+ borderEndEndRadius: `calc(${sizeVars['--size-element-lg']} / 2)`,
},
});
+/**
+ * Participant circle diameter per pin size, matching the literals in
+ * `sizeStyles`. Avatar renders any pixel size; its typed scale lists neither
+ * 22 nor 28, hence the cast.
+ */
+const AVATAR_SIZE: Record<CommentPinSize, AvatarSize> = {
+ sm: 22 as AvatarSize,
+ md: 24,
+ lg: 28 as AvatarSize,
+};
+
+/** The overflow ellipsis per pin size. */
+const OVERFLOW_ICON_SIZE: Record<CommentPinSize, IconSize> = {
+ sm: 'xsm',
+ md: 'xsm',
+ lg: 'sm',
+};
+
function takeDistinctParticipants(
participants: readonly CommentPinParticipant[],
limit: number,
@@ -305,7 +348,8 @@ const MAX_GROUP_CIRCLES = 3;
* The caller owns grouping, representative selection, coordinates, collision
* handling, and the content opened by activation. Absolute placement maps the
* host anchor to the pin's logical bottom-start corner. The pin only owns its
- * compact button surface and controlled visual states.
+ * compact button surface and controlled visual states. `size` sets its height
+ * on the element-size scale.
*
* @example
* ```
@@ -331,6 +375,7 @@ const MAX_GROUP_CIRCLES = 3;
export function CommentPin({
label,
participants,
+ size = 'sm',
threadCount = 1,
unreadCount = 0,
isSelected = false,
@@ -343,6 +388,9 @@ export function CommentPin({
style,
...rest
}: CommentPinProps): React.ReactNode {
+ const resolvedSize: CommentPinSize =
+ size === 'md' || size === 'lg' ? size : 'sm';
+ const avatarSize = AVATAR_SIZE[resolvedSize];
const validThreadCount = isValidThreadCount(threadCount);
const resolvedThreadCount = validThreadCount ? threadCount : 1;
const isGrouped = resolvedThreadCount > 1;
@@ -353,7 +401,7 @@ export function CommentPin({
const hasUnread = resolvedUnreadCount > 0;
// Grouped pins cap at MAX_GROUP_CIRCLES circles: every distinct participant
- // when they fit, otherwise one fewer Avatar plus a `+N` overflow circle.
+ // when they fit, otherwise one fewer Avatar plus an ellipsis overflow circle.
const distinctParticipants = takeDistinctParticipants(
participants,
isGrouped ? Number.POSITIVE_INFINITY : 1,
@@ -395,6 +443,13 @@ export function CommentPin({
});
const mergedRef = useMergedRefs(ref, hasTooltip ? tooltip.ref : undefined);
+ // Resolved discussion leaves the content. A selected pin stays, so a thread
+ // the reader opened (or resolved from its popover) keeps its anchor until
+ // the host clears the selection.
+ if (isResolved && !isSelected) {
+ return null;
+ }
+
const avatarParticipants =
visibleParticipants.length > 0
? visibleParticipants
@@ -411,6 +466,7 @@ export function CommentPin({
disabled={isDisabled}
{...mergeProps(
themeProps('comment-pin', {
+ size: resolvedSize,
grouped: isGrouped ? 'grouped' : null,
unread: hasUnread ? 'unread' : null,
selected: isSelected ? 'selected' : null,
@@ -420,9 +476,9 @@ export function CommentPin({
}),
focusOutlineProps.focusVisible(
styles.root,
+ sizeStyles[resolvedSize],
interactionOverlayStyles.backgroundImage,
(isGrouped || hasUnread) && styles.withCount,
- isResolved && !isSelected && styles.resolved,
isDimmed && !isSelected && styles.dimmed,
isSelected && styles.selected,
isDisabled && styles.disabled,
@@ -431,9 +487,11 @@ export function CommentPin({
className,
style,
)}>
- <span aria-hidden="true" {...stylex.props(styles.avatarRail)}>
+ <span
+ aria-hidden="true"
+ {...stylex.props(styles.avatarRail, isGrouped && styles.groupedRail)}>
{isGrouped ? (
- <AvatarGroup size="xsm">
+ <AvatarGroup size={avatarSize}>
{avatarParticipants.map(participant => (
<Avatar
key={participant.id}
@@ -445,8 +503,12 @@ export function CommentPin({
{overflowCount > 0 ? (
<AvatarGroupOverflow
count={overflowCount}
- xstyle={styles.overflowCircle}
- />
+ xstyle={styles.overflowCircle}>
+ <Icon
+ icon="moreHorizontal"
+ size={OVERFLOW_ICON_SIZE[resolvedSize]}
+ />
+ </AvatarGroupOverflow>
) : null}
</AvatarGroup>
) : (
@@ -455,19 +517,21 @@ export function CommentPin({
key={participant.id}
name={participant.name}
src={participant.avatarSrc}
- size="xsm"
+ size={avatarSize}
tooltip={false}
/>
))
)}
</span>
- {hasUnread ? (
- <span aria-hidden="true" {...stylex.props(styles.unreadBadge)}>
- {resolvedUnreadCount}
- </span>
- ) : isGrouped ? (
- <span aria-hidden="true" {...stylex.props(styles.count)}>
- {resolvedThreadCount}
+ {hasUnread || isGrouped ? (
+ <span aria-hidden="true" {...stylex.props(styles.trailing)}>
+ {isGrouped ? (
+ <span {...stylex.props(styles.count)}>{resolvedThreadCount}</span>
+ ) : null}
+ {hasUnread ? (
+ // Decorative: the button's label carries the unread context.
+ <StatusDot variant="accent" label="" xstyle={styles.unreadDot} />
+ ) : null}
</span>
) : null}
</button>