g-comments 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/README.md +24 -13
- package/dist/{chunk-WACVXJHD.js → chunk-EWWBVJ2B.js} +5 -5
- package/dist/chunk-EWWBVJ2B.js.map +1 -0
- package/dist/{chunk-IBNNENCZ.cjs → chunk-I2L3IAXL.cjs} +5 -4
- package/dist/chunk-I2L3IAXL.cjs.map +1 -0
- package/dist/element.js +985 -962
- package/dist/element.js.map +1 -1
- package/dist/index.cjs +16 -16
- package/dist/index.js +1 -1
- package/dist/react.cjs +71 -45
- package/dist/react.cjs.map +1 -1
- package/dist/react.js +40 -14
- package/dist/react.js.map +1 -1
- package/package.json +1 -1
- package/styles/styles.css +964 -945
- package/dist/chunk-IBNNENCZ.cjs.map +0 -1
- package/dist/chunk-WACVXJHD.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,25 @@ All notable changes to `g-comments` are listed here. The format follows
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.2.2] - 2026-10-20
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
|
|
13
|
+
- Classic topics (no nested replies) read the way the forum shows them: one
|
|
14
|
+
linear list, with a "Replying to @user" link on comments that answer another
|
|
15
|
+
one. New replies land in the list instead of under their parent. Needs
|
|
16
|
+
discourse-comments f6312bf or later for the server side.
|
|
17
|
+
|
|
18
|
+
## [0.2.1] - 2026-10-20
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
|
|
22
|
+
- The default stylesheet lives in the `gc-defaults` cascade layer and a forum
|
|
23
|
+
theme's CSS is imported into `gc-forum`, so site CSS beats the forum's and the
|
|
24
|
+
forum's beats the defaults regardless of load order or specificity. The forum
|
|
25
|
+
stylesheet is no longer a `<link>`: it is an `@import … layer(gc-forum)` in
|
|
26
|
+
the installed `<style>`.
|
|
27
|
+
|
|
9
28
|
## [0.2.0] - 2026-10-20
|
|
10
29
|
|
|
11
30
|
### Added
|
package/README.md
CHANGED
|
@@ -128,15 +128,22 @@ Also available: `Comments.Meta` (author, badges, permalink time),
|
|
|
128
128
|
`Comments.DevPanel`. The `List` render function is reused for replies at every
|
|
129
129
|
depth, and `Item` keeps the inline reply, edit, report and delete panels.
|
|
130
130
|
|
|
131
|
+
## Classic topics
|
|
132
|
+
|
|
133
|
+
A forum without nested replies (or a topic switched to classic mode) reads as
|
|
134
|
+
one linear list in posting order, like the forum itself: a comment that answers
|
|
135
|
+
another carries a "Replying to @user" link instead of being nested under it,
|
|
136
|
+
and `thread.nested` is `false`.
|
|
137
|
+
|
|
131
138
|
## Styling
|
|
132
139
|
|
|
133
140
|
`g-comments/styles.css` styles everything under the widget root
|
|
134
141
|
(`.gc-root.gc-root--styled`); nothing outside it is touched. Class names follow
|
|
135
142
|
BEM (`gc-comment`, `gc-comment__body`, `gc-composer--replying`,
|
|
136
143
|
`gc-button--primary`, …) and stay in place with `unstyled`, which only drops
|
|
137
|
-
`gc-root--styled`.
|
|
138
|
-
|
|
139
|
-
`.gc-prose`.
|
|
144
|
+
`gc-root--styled`. The rules live in the `gc-defaults` cascade layer, so your
|
|
145
|
+
own (unlayered) CSS wins whatever its order or specificity. Cooked comment HTML
|
|
146
|
+
is wrapped in `.gc-prose`.
|
|
140
147
|
|
|
141
148
|
`appearance.elements` adds class names: `root`, `header`, `count`, `sort`,
|
|
142
149
|
`signIn`, `composer`, `textarea`, `toolbar`, `list`, `comment`, `avatar`,
|
|
@@ -191,14 +198,15 @@ element's shadow root. Three things arrive:
|
|
|
191
198
|
`--gc-forum-font-monospace` carry the stacks, and `@font-face` rules are
|
|
192
199
|
added to the page for fonts the forum serves.
|
|
193
200
|
- **Theme CSS.** The default theme's "Embedded CSS" (Admin → Customize →
|
|
194
|
-
Themes → Edit CSS/HTML → Embedded) is
|
|
195
|
-
admins can style the `gc-*` classes without touching the
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
forum's
|
|
201
|
-
|
|
201
|
+
Themes → Edit CSS/HTML → Embedded) is imported into the `gc-forum` cascade
|
|
202
|
+
layer, so forum admins can style the `gc-*` classes without touching the
|
|
203
|
+
site.
|
|
204
|
+
|
|
205
|
+
Precedence, for tokens and for plain CSS alike: what a component sets
|
|
206
|
+
(`appearance`) beats the site's own CSS and `--gc-*` values, which beat the
|
|
207
|
+
forum's, which beat the defaults. Site CSS is unlayered and the forum's sits in
|
|
208
|
+
`gc-forum` above `gc-defaults`, so no ordering or specificity tricks are
|
|
209
|
+
needed. `useForumTheme()` returns the same data for sites that style their own
|
|
202
210
|
UI after the forum.
|
|
203
211
|
|
|
204
212
|
## Custom elements (no framework)
|
|
@@ -280,8 +288,11 @@ discourse-comments::part(gc-comment--pinned) {
|
|
|
280
288
|
`unstyled` drops the default stylesheet's effect (the classes and parts stay),
|
|
281
289
|
`theme="inherit"` derives the neutral colours from the page's text colour, and
|
|
282
290
|
`theme="forum"` loads the forum's palettes, fonts and theme CSS into the shadow
|
|
283
|
-
root (see "Use the forum's look").
|
|
284
|
-
|
|
291
|
+
root (see "Use the forum's look"). Tokens set on the element or an ancestor
|
|
292
|
+
reach the widget by inheritance, which a forum stylesheet that sets `--gc-*`
|
|
293
|
+
on `.gc-root` would override; with `theme="forum"`, set your tokens on
|
|
294
|
+
`discourse-comments::part(gc-root)` instead, which always wins. The count
|
|
295
|
+
element has no styles of its own and inherits the page's font.
|
|
285
296
|
|
|
286
297
|
`defineElements({ comments: "my-comments", count: "my-count" })` registers the
|
|
287
298
|
same elements under other names; names that are already defined are left
|
|
@@ -2392,7 +2392,7 @@ var CommentThread = class {
|
|
|
2392
2392
|
if (!insertable(comment) || this.#deletedAt.has(comment.id)) {
|
|
2393
2393
|
continue;
|
|
2394
2394
|
}
|
|
2395
|
-
const parentNumber = comment.reply_to?.number;
|
|
2395
|
+
const parentNumber = this.#state.thread.nested ? comment.reply_to?.number : void 0;
|
|
2396
2396
|
if (parentNumber === void 0) {
|
|
2397
2397
|
if (me !== null && comment.author?.id === me) {
|
|
2398
2398
|
tree = insertRoot(tree, comment, rootPosition(sort));
|
|
@@ -2470,7 +2470,7 @@ var CommentThread = class {
|
|
|
2470
2470
|
this.#record({ kind: "comments", comments: [comment], insertable: /* @__PURE__ */ new Set([comment.id]), ticket });
|
|
2471
2471
|
const sort = this.#state.sort;
|
|
2472
2472
|
let comments = this.#state.comments;
|
|
2473
|
-
if (replyTo !== void 0) {
|
|
2473
|
+
if (replyTo !== void 0 && this.#state.thread.nested) {
|
|
2474
2474
|
comments = insertReply(comments, replyTo, comment, replyPosition(sort), { bumpCounts: true }) ?? comments;
|
|
2475
2475
|
} else {
|
|
2476
2476
|
comments = insertRoot(comments, comment, rootPosition(sort));
|
|
@@ -3063,6 +3063,6 @@ function createTranslator(locale, overrides = {}) {
|
|
|
3063
3063
|
};
|
|
3064
3064
|
}
|
|
3065
3065
|
|
|
3066
|
-
export { CommentsError, PACKAGE_NAME, STORAGE_PREFIX, clientRegistry, createClient, createClientRegistry, createComposerTimer, createTranslator, currentUrlWithoutHash, defaultPageUrl, en, encodeRef, findComment, isCommentsError, isVirtualThread, locales, memoryStorage, normalizeForum, ptBR, resolveLocale };
|
|
3067
|
-
//# sourceMappingURL=chunk-
|
|
3068
|
-
//# sourceMappingURL=chunk-
|
|
3066
|
+
export { CommentsError, PACKAGE_NAME, STORAGE_PREFIX, clientRegistry, createClient, createClientRegistry, createComposerTimer, createTranslator, currentUrlWithoutHash, defaultPageUrl, en, encodeRef, findByNumber, findComment, isCommentsError, isVirtualThread, locales, memoryStorage, normalizeForum, ptBR, resolveLocale };
|
|
3067
|
+
//# sourceMappingURL=chunk-EWWBVJ2B.js.map
|
|
3068
|
+
//# sourceMappingURL=chunk-EWWBVJ2B.js.map
|