g-comments 0.1.0 → 0.2.1

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/dist/element.d.ts CHANGED
@@ -178,6 +178,54 @@ type CountRef = {
178
178
  } | {
179
179
  topicId: number;
180
180
  };
181
+ /** One palette of a theme (`ForumTheme#scheme_payload`). */
182
+ interface ForumColorScheme {
183
+ id: number;
184
+ name: string;
185
+ type: "light" | "dark";
186
+ /**
187
+ * Every custom property the forum's colour definitions emit, without the
188
+ * `--` prefix and with references already resolved: `primary`, `secondary`,
189
+ * `tertiary`, `primary-low`, `primary-medium`, `danger`, …
190
+ */
191
+ colors: Record<string, string>;
192
+ }
193
+ /** A `@font-face` source the forum serves. */
194
+ interface ForumFontFace {
195
+ family: string;
196
+ /** A CSS `src` value, e.g. `url("https://forum/fonts/x.woff2") format("woff2")`. */
197
+ src: string;
198
+ weight: number | string;
199
+ }
200
+ interface ForumFont {
201
+ key: string;
202
+ name: string;
203
+ /** A CSS `font-family` value. */
204
+ stack: string;
205
+ /** Empty for fonts the forum expects to be installed. */
206
+ faces: ForumFontFace[];
207
+ }
208
+ /** `GET /comments/theme`: the forum's look as data. */
209
+ interface ForumTheme {
210
+ theme: {
211
+ id: number;
212
+ name: string;
213
+ } | null;
214
+ schemes: {
215
+ light: ForumColorScheme;
216
+ /** Present when the theme has a dark palette. */
217
+ dark: ForumColorScheme | null;
218
+ };
219
+ fonts: {
220
+ body: ForumFont | null;
221
+ heading: ForumFont | null;
222
+ monospace: ForumFont | null;
223
+ };
224
+ /** The theme's "Embedded CSS" stylesheets, absolute URLs. */
225
+ stylesheets: string[];
226
+ /** Changes whenever any of the above changes. */
227
+ version: string;
228
+ }
181
229
 
182
230
  type CommentsErrorType = "invalid_key" | "not_logged_in" | "invalid_access" | "invalid_parameters" | "not_found" | "rate_limit" | "thread_conflict" | "page_not_allowed" | "invalid_url" | "no_category" | "thread_not_created" | "invalid_grant" | "user_not_allowed" | "submission_rejected" | "not_a_root_comment" | "pin_limit_reached" | "cancelled" | "storage_unavailable" | "unreachable" | "unknown";
183
231
  interface CommentsErrorOptions {
@@ -207,7 +255,7 @@ declare class CommentsError extends Error {
207
255
  }
208
256
 
209
257
  /** What the widget was doing when an `error` event fired. */
210
- type CommentsAction = "open" | "load" | "loadMore" | "loadReplies" | "context" | "post" | "edit" | "delete" | "like" | "flag" | "pin" | "upload" | "preview" | "signIn";
258
+ type CommentsAction = "open" | "load" | "loadMore" | "loadReplies" | "context" | "post" | "edit" | "delete" | "like" | "flag" | "pin" | "upload" | "preview" | "signIn" | "theme";
211
259
  /** Delivered to `<DiscourseComments onEvent>`. */
212
260
  type CommentsEvent = {
213
261
  type: "comment.posted";
@@ -428,6 +476,8 @@ interface CommentsClient {
428
476
  };
429
477
  /** Cached; refetched after sign-in and sign-out. */
430
478
  config(): Promise<Config>;
479
+ /** The forum's palettes, fonts and theme stylesheets; cached for the client's lifetime. */
480
+ theme(): Promise<ForumTheme>;
431
481
  /** Batched per tick, at most 50 refs per request. Keys are encoded refs (see `encodeRef`). */
432
482
  counts(refs: readonly CountRef[]): Promise<Counts>;
433
483
  count(ref: CountRef): Promise<number>;
@@ -439,8 +489,11 @@ interface CommentsClient {
439
489
  dispose(): void;
440
490
  }
441
491
 
442
- /** `auto` follows `prefers-color-scheme`; `inherit` leaves the colours to the page. */
443
- type Theme = "auto" | "light" | "dark" | "inherit";
492
+ /**
493
+ * `auto` follows `prefers-color-scheme`, `inherit` leaves the colours to the
494
+ * page, and `forum` applies the forum's own palettes, fonts and theme CSS.
495
+ */
496
+ type Theme = "auto" | "light" | "dark" | "inherit" | "forum";
444
497
 
445
498
  /**
446
499
  * Where signing in happens: `inline` shows a "Join the conversation" panel,
@@ -514,7 +567,7 @@ declare const COMMENTS_ATTRIBUTES: {
514
567
  };
515
568
  readonly theme: {
516
569
  readonly prop: "theme";
517
- readonly type: readonly ["auto", "light", "dark", "inherit"];
570
+ readonly type: readonly ["auto", "light", "dark", "inherit", "forum"];
518
571
  };
519
572
  readonly locale: {
520
573
  readonly prop: "locale";
@@ -598,7 +651,7 @@ declare class DiscourseCommentsElement extends ReactHostElement<DiscourseComment
598
651
  };
599
652
  readonly theme: {
600
653
  readonly prop: "theme";
601
- readonly type: readonly ["auto", "light", "dark", "inherit"];
654
+ readonly type: readonly ["auto", "light", "dark", "inherit", "forum"];
602
655
  };
603
656
  readonly locale: {
604
657
  readonly prop: "locale";