Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/commentpin-core-blocks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@astryxdesign/cli': patch
---

[docs] `astryx template` lists CommentPin's blocks among Core's component blocks: the "Avatar-first annotations" showcase and the "Comment pin in a document margin" example.

@ernestt
7 changes: 7 additions & 0 deletions .changeset/promote-commentpin-to-core.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@astryxdesign/core': patch
---

[component] Promote `CommentPin` to Core, imported from `@astryxdesign/core/CommentPin` or the package root together with `CommentUser`, the person record its participants take. CommentPin is the avatar-first button that anchors a comment thread, or a group of threads, over content or in a content margin. A single pin shows its lead participant; a group shows up to three participant circles and the thread total. An accent dot marks unread threads. Three sizes follow the element-size scale. Activation flips the selection, which the pin keeps, or the host controls through `isSelected` and `onSelectedChange`. The host owns anchors, grouping, and which pins render.

@ernestt
2 changes: 2 additions & 0 deletions apps/sandbox/scripts/next-export-routes.json
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,8 @@
"/templates/CommandPalettePickerMode/",
"/templates/CommandPaletteRichItems/",
"/templates/CommandPaletteShowcase/",
"/templates/CommentPinInMargin/",
"/templates/CommentPinShowcase/",
"/templates/ComplexSelectorDeadlinePicker/",
"/templates/ComplexSelectorShowcase/",
"/templates/ComplexSelectorTreeSearch/",
Expand Down
4 changes: 2 additions & 2 deletions apps/storybook/rtl-audit/verified-not-applicable.json
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,8 @@
"reason": "EmojiPicker is a search field above CSS grids of emoji whose columns follow CSS direction, with sticky group headings and a footer preview in logical-property flex rows; its search glyph is radially symmetric. Its one direction-sensitive behavior, horizontal arrow keys, comes from core useGridFocus, which resolves direction per keydown with isRtlElement; that hook's RTL tests and EmojiPicker's own right-to-left keyboard test cover it, and no audit dimension measures keyboard direction."
},
{
"component": "lab/CommentPin",
"reason": "CommentPin sets its fixed 4px speech-bubble corner with the logical border-end-start-radius longhand (the other corners use logical longhands too), so it mirrors under RTL by construction, and switches transform origin from left-bottom to right-bottom. Absolute examples place the inline-start edge at the anchor and translate only on the block axis, so bottom-start placement mirrors without a physical inline offset. Its flex row, avatar overlap, and padding use logical properties; avatars and the numeric count have no directional glyph or keyboard semantics to reverse."
"component": "core/CommentPin",
"reason": "CommentPin sets its fixed 2px speech-bubble corner with the logical border-end-start-radius longhand (the other corners use logical longhands too), so it mirrors under RTL by construction, and switches transform origin from left-bottom to right-bottom. Absolute examples place the inline-start edge at the anchor and translate only on the block axis, so bottom-start placement mirrors without a physical inline offset. Its flex row, avatar overlap, and padding use logical properties; avatars and the numeric count have no directional glyph or keyboard semantics to reverse."
},
{
"component": "lab/CommentComposer",
Expand Down
4 changes: 2 additions & 2 deletions apps/storybook/stories/CommentPin.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import type {Meta, StoryObj} from '@storybook/react';
import {useEffect, useRef, useState} from 'react';
import * as stylex from '@stylexjs/stylex';
import {CommentPin} from '@astryxdesign/lab';
import {CommentPin} from '@astryxdesign/core/CommentPin';
import {Text} from '@astryxdesign/core/Text';
import {HStack, VStack} from '@astryxdesign/core/Stack';
import {
Expand Down Expand Up @@ -169,7 +169,7 @@ function FocusedSelectedPin() {
}

const meta: Meta<typeof CommentPin> = {
title: 'Lab/CommentPin',
title: 'Core/CommentPin',
component: CommentPin,
tags: ['autodocs'],
parameters: {layout: 'centered'},
Expand Down
64 changes: 39 additions & 25 deletions docs/specs/components/CommentPin/CommentPin.spec.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2268,16 +2268,6 @@
"DR2",
"design:bidirectionality"
],
"packages/lab/src/CommentPin/CommentPin.tsx": [
"FR1",
"FR2",
"FR2",
"FR2",
"FR4",
"FR6",
"ORD4",
"spec:AST-085"
],
"packages/lab/src/Comments/CommentActions.tsx": [
"architecture:react-component-runtime/INV2"
],
Expand Down
12 changes: 7 additions & 5 deletions internal/shadcn-registry/routes.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,13 @@
"path": "components/command-palette-list",
"aliases": []
},
{
"name": "component-comment-pin",
"path": "components/comment-pin",
"aliases": [
"components/lab/comment-pin"
]
},
{
"name": "component-complex-selector",
"path": "components/complex-selector",
Expand Down Expand Up @@ -597,11 +604,6 @@
"path": "components/lab/comment-composer",
"aliases": []
},
{
"name": "component-lab-comment-pin",
"path": "components/lab/comment-pin",
"aliases": []
},
{
"name": "component-lab-comment-thread",
"path": "components/lab/comment-thread",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright (c) Meta Platforms, Inc. and affiliates.

/** @type {import('@astryxdesign/cli/authoring').TemplateDoc} */
export const doc = {
type: 'block',
name: 'Host-owned placement',
displayName: 'Comment pin in a document margin',
description:
'A margin comment marker beside a document passage: a reader opens the discussion from a compact avatar button in the trailing margin. The host lays out the margin and keeps the pin level with the passage it annotates, and the pin keeps its own selection when the host does not control it. Also called a side comment, margin note, or annotation anchor.',
exampleFor: 'CommentPin',
isReady: true,
aspectRatio: 16 / 9,
componentsUsed: [
'Card',
'CommentPin',
'HStack',
'StackItem',
'Text',
'VStack',
],
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright (c) Meta Platforms, Inc. and affiliates.

/**
* @input One comment pin and its lead commenter
* @output A document passage with a comment pin in its trailing margin;
* activating the pin toggles its own selection and aria-pressed state
* @position Copyable CommentPin placement example
*/

import {Card} from '@astryxdesign/core/Card';
import {CommentPin} from '@astryxdesign/core/CommentPin';
Comment thread
astracat-bot[bot] marked this conversation as resolved.
Resolved
import {HStack, StackItem, VStack} from '@astryxdesign/core/Layout';
import {Text} from '@astryxdesign/core/Text';

export default function CommentPinInMargin() {
return (
<Card padding={5} width={520}>
<VStack gap={3}>
<Text as="h2" type="display-3" weight="bold">
Launch checklist
</Text>
<HStack gap={5} align="start">
<StackItem size="fill">
<Text type="body">
Move the pricing page to the new plans before Thursday, and keep
the old plans available to customers who are mid-renewal.
</Text>
</StackItem>
<CommentPin
label="Open comment from Maya Chen"
participants={[{id: 'maya', name: 'Maya Chen'}]}
/>
</HStack>
<Text type="supporting" color="secondary">
Last edited by Maya Chen on November 30
</Text>
</VStack>
</Card>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright (c) Meta Platforms, Inc. and affiliates.

/** @type {import('@astryxdesign/cli/authoring').TemplateDoc} */
export const doc = {
type: 'block',
name: 'Avatar-first annotations',
displayName: 'Avatar-first annotations',
description:
'Avatar-first annotation markers over an image: reviewers see who commented where and open a discussion from its pin. The host maps each anchor point to the pin’s logical bottom-start corner and keeps one pin selected through isSelected and onSelectedChange. A grouped pin caps its participants at three circles and adds its total and an unread dot. Also called comment pins, review markers, or image hotspots.',
exampleFor: 'CommentPin',
isReady: true,
isShowcase: true,
aspectRatio: 16 / 9,
componentsUsed: ['AspectRatio', 'Card', 'CommentPin', 'Text', 'VStack'],
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
// Copyright (c) Meta Platforms, Inc. and affiliates.

'use client';

/**
* @input Two caller-positioned comment pins over an image and one controlled
* selection that may be empty
* @output A grouped pin with a three-circle participant cap, its total and an
* unread dot, and a single pin; selecting a pin clears the other, and
* activating the selected pin clears the selection
* @position CommentPin docsite showcase and copyable CLI block
*/

import {useState} from 'react';
import {AspectRatio} from '@astryxdesign/core/AspectRatio';
import {Card} from '@astryxdesign/core/Card';
import {CommentPin} from '@astryxdesign/core/CommentPin';
Comment thread
astracat-bot[bot] marked this conversation as resolved.
Resolved
import {VStack} from '@astryxdesign/core/Layout';
import {Text} from '@astryxdesign/core/Text';

const AMI = {
id: 'ami',
name: 'Ami Pena',
src: '/template-assets/DATA-Ami-Pena.png',
};
const DREW = {
id: 'drew',
name: 'Drew Young',
src: '/template-assets/DATA-Drew-Young.png',
};
const NAM = {
id: 'nam',
name: 'Nam Tran',
src: '/template-assets/DATA-Nam-Tran.png',
};
const JIHOO = {
id: 'jihoo',
name: 'Jihoo Song',
src: '/template-assets/DATA-Jihoo-Song.png',
};

// The host maps each anchor point to the pin's bottom-start corner.
const pinAt = (x: string, y: string) =>
({
position: 'absolute',
insetInlineStart: x,
insetBlockStart: y,
transform: 'translateY(-100%)',
}) as const;

type PinId = 'group' | 'single';

export default function CommentPinShowcase() {
const [selected, setSelected] = useState<PinId | null>('group');
const select = (id: PinId) => (isSelected: boolean) =>
setSelected(isSelected ? id : null);

return (
<VStack gap={3} width="100%">
<Text as="h3" type="display-3" weight="bold">
Spring campaign photo
</Text>
<Card padding={0}>
<VStack style={{position: 'relative'}}>
<AspectRatio ratio={16 / 9} fit="cover">
<img
src="/template-assets/light-working-horizontal-1.png"
alt="A person writing on a tablet at a wooden table"
/>
</AspectRatio>
<CommentPin
label="Open 5 comments from Ami, Drew, and 2 others, 2 unread"
participants={[AMI, DREW, NAM, JIHOO]}
threadCount={5}
unreadCount={2}
isSelected={selected === 'group'}
onSelectedChange={select('group')}
style={pinAt('34%', '38%')}
/>
<CommentPin
label="Open comment from Nam"
participants={[NAM]}
isSelected={selected === 'single'}
onSelectedChange={select('single')}
style={pinAt('68%', '70%')}
/>
</VStack>
</Card>
</VStack>
);
}
12 changes: 6 additions & 6 deletions packages/cli/test/swizzle-proof/samples.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,12 @@ export const samples = {
},
});
},
core__CommentPin: ({C, React}) =>
React.createElement(C, {
label: 'Open annotation from Ada',
participants: [{id: 'ada', name: 'Ada Lovelace'}],
onClick: noop,
}),
core__Heading: ({C, React}) =>
React.createElement(C, {level: 2}, 'Section title'),
core__Kbd: ({C, React}) => React.createElement(C, {keys: 'mod+k'}),
Expand Down Expand Up @@ -360,12 +366,6 @@ export const samples = {
}),
lab__CommentComposer: ({C, React}) =>
React.createElement(C, {value: '', onChange: noop, onSubmit: noop}),
lab__CommentPin: ({C, React}) =>
React.createElement(C, {
label: 'Open annotation from Ada',
participants: [{id: 'ada', name: 'Ada Lovelace'}],
onClick: noop,
}),
lab__CommentThread: ({C, React}) =>
React.createElement(
'div',
Expand Down
5 changes: 5 additions & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,11 @@
"types": "./dist/CommandPalette/index.d.ts",
"default": "./dist/CommandPalette/index.js"
},
"./CommentPin": {
"source": "./src/CommentPin/index.ts",
"types": "./dist/CommentPin/index.d.ts",
"default": "./dist/CommentPin/index.js"
},
"./ComplexSelector": {
"source": "./src/ComplexSelector/index.ts",
"types": "./dist/ComplexSelector/index.d.ts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
/**
* @file CommentPin.doc.mjs
* @input CommentPin API, anatomy, ownership boundaries, and examples
* @output Consumer documentation for the Lab comment pin
* @position CLI and docsite metadata; the runnable showcase lives in packages/lab/blocks
* @output Consumer documentation for the comment pin
* @position CLI and docsite metadata; the runnable showcase lives in
* packages/cli/assets/templates/blocks/components/CommentPin
*/

/** @type {import('@astryxdesign/cli/authoring').ComponentAnatomyElement[]} */
Expand Down Expand Up @@ -45,6 +46,8 @@ const anatomy = [
export const docs = {
name: 'CommentPin',
displayName: 'Comment Pin',
// Keeps the registry route CommentPin had as a Lab component.
registry: {aliases: ['lab/comment-pin']},
group: 'Comments',
category: 'Chat',
keywords: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {describe, expect, it, vi} from 'vitest';
import {fireEvent, render, screen, waitFor} from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import * as stylex from '@stylexjs/stylex';
import {colorVars} from '@astryxdesign/core/theme/tokens.stylex';
import {colorVars} from '../theme/tokens.stylex';
import {CommentPin} from './CommentPin';

const ADA = {id: 'ada', name: 'Ada Lovelace'};
Expand Down
Loading