Skip to content

Commit deaaa51

Browse files
authored
Merge pull request #2897 from ably/hot-fix/example-explains-types
Add details of annotations types to example documentation
2 parents d6916a9 + 77e3102 commit deaaa51

File tree

2 files changed

+37
-3
lines changed

2 files changed

+37
-3
lines changed

examples/pub-sub-message-annotations/javascript/README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,17 @@ Use the following methods to work with message annotations in a pub/sub applicat
1818

1919
Find out more about [annotations](/docs/messages/annotations).
2020

21-
## Annotation Types
21+
## Annotation types
2222

23-
This example demonstrates five common annotation types, each suited to different use cases:
23+
This example demonstrates five common [annotation types](/docs/messages/annotations#annotation-types), each suited to different use cases:
2424

25-
<!-- TODO -->
25+
| Type | Description | Use cases |
26+
| ----- | ----------- | --------- |
27+
| Total | Tracks the cumulative count of annotations, regardless of value or user. | Use for aggregate counts, such as a simple “like” or “upvote” counter. |
28+
| Distinct | Allows multiple annotation values per user, but only one instance of each value. Multiple users can share the same value. | Works similar to Slack reactions - a user can add both 👍 and ❤️ to a message, but only once per reaction type. |
29+
| Unique | Restricts each user to one annotation value per message. | Works like WhatsApp reactions - a user can react with 👍 or ❤️, but not both. |
30+
| Multiple | Allows users to send the same annotation multiple times per value. | Ideal for repeated actions, like goal celebrations where users can send 🎉 multiple times. |
31+
| Flag | Represents a binary user state - flagged or unflagged. Each user can flag a message once, and multiple users can flag the same message. |Use for moderation workflows, e.g. flagging a message for review or follow-up. |
2632

2733
## Features
2834

src/templates/examples.tsx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,34 @@ const MarkdownOverrides = {
5151
</a>
5252
),
5353
},
54+
table: {
55+
component: ({ children }: PropsWithChildren) => (
56+
<div className="overflow-x-auto mb-2">
57+
<table className="border-0 border-collapse mb-1 border-spacing-0 ui-text-p2 text-left">{children}</table>
58+
</div>
59+
),
60+
},
61+
thead: {
62+
component: ({ children }: PropsWithChildren) => <thead className="bg-gray-50 border-b">{children}</thead>,
63+
},
64+
tbody: {
65+
component: ({ children }: PropsWithChildren) => <tbody className="border-b divide-neutral-300">{children}</tbody>,
66+
},
67+
tr: {
68+
component: ({ children }: PropsWithChildren) => (
69+
<tr className="hover:bg-gray-50 border-b divide-neutral-300">{children}</tr>
70+
),
71+
},
72+
th: {
73+
component: ({ children }: PropsWithChildren) => (
74+
<th className="px-3 py-2 text-left ui-text-p1 font-bold text-neutral-1100 tracking-wider whitespace-nowrap">
75+
{children}
76+
</th>
77+
),
78+
},
79+
td: {
80+
component: ({ children }: PropsWithChildren) => <td className="px-3 py-4 align-text-top text-sm">{children}</td>,
81+
},
5482
};
5583

5684
const Examples = ({ pageContext }: { pageContext: { example: ExampleWithContent } }) => {

0 commit comments

Comments
 (0)