Repository navigation
feat(core): CommentPin moves to Core #13735
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ernestt
wants to merge
3
commits into
feat/commentpin-api-pass
Choose a base branch
from
feat/commentpin-core
base: feat/commentpin-api-pass
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+398
−405
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
packages/cli/assets/templates/blocks/components/CommentPin/CommentPinInMargin.doc.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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', | ||
| ], | ||
| }; |
40 changes: 40 additions & 0 deletions
40
packages/cli/assets/templates/blocks/components/CommentPin/CommentPinInMargin.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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'; | ||
| 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> | ||
| ); | ||
| } | ||
15 changes: 15 additions & 0 deletions
15
packages/cli/assets/templates/blocks/components/CommentPin/CommentPinShowcase.doc.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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'], | ||
| }; |
91 changes: 91 additions & 0 deletions
91
packages/cli/assets/templates/blocks/components/CommentPin/CommentPinShowcase.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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'; | ||
|
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> | ||
| ); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.