gitalk-react 1.0.0-beta.6 → 1.0.0-beta.7

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.
@@ -1,4 +1,170 @@
1
1
  import type { Endpoints } from "@octokit/types";
2
+ import type FlipMove from "react-flip-move";
3
+
4
+ import type { Lang } from "../i18n";
5
+ import type { IssueCommentsQLResponse } from "../services/graphql/comment";
6
+
7
+ export interface GitalkProps
8
+ extends Omit<
9
+ React.DetailedHTMLProps<
10
+ React.HTMLAttributes<HTMLDivElement>,
11
+ HTMLDivElement
12
+ >,
13
+ "id" | "title"
14
+ > {
15
+ /**
16
+ * GitHub Application Client ID.
17
+ */
18
+ clientID: string;
19
+ /**
20
+ * GitHub Application Client Secret.
21
+ */
22
+ clientSecret: string;
23
+ /**
24
+ * GitHub repository owner.
25
+ * Can be personal user or organization.
26
+ */
27
+ owner: string;
28
+ /**
29
+ * Name of Github repository.
30
+ */
31
+ repo: string;
32
+ /**
33
+ * GitHub repository owner and collaborators.
34
+ * (Users who having write access to this repository)
35
+ */
36
+ admin: string[];
37
+ /**
38
+ * The unique id of the page.
39
+ * Length must less than 50.
40
+ *
41
+ * @default location.host + location.pathname
42
+ */
43
+ id?: string;
44
+ /**
45
+ * The issue ID of the page.
46
+ * If the number attribute is not defined, issue will be located using id.
47
+ */
48
+ number?: number;
49
+ /**
50
+ * GitHub issue labels.
51
+ *
52
+ * @default ['Gitalk']
53
+ */
54
+ labels?: string[];
55
+ /**
56
+ * GitHub issue title.
57
+ *
58
+ * @default document.title
59
+ */
60
+ title?: string;
61
+ /**
62
+ * GitHub issue body.
63
+ *
64
+ * @default location.href + header.meta[description]
65
+ */
66
+ body?: string;
67
+ /**
68
+ * Localization language key.
69
+ *
70
+ * @default navigator.language
71
+ */
72
+ language?: Lang;
73
+ /**
74
+ * Pagination size, with maximum 100.
75
+ *
76
+ * @default 10
77
+ */
78
+ perPage?: number;
79
+ /**
80
+ * Comment sorting direction.
81
+ * Available values are `last` and `first`.
82
+ *
83
+ * @default "last"
84
+ */
85
+ pagerDirection?: "last" | "first";
86
+ /**
87
+ * By default, Gitalk will create a corresponding github issue for your every single page automatically when the logined user is belong to the admin users.
88
+ * You can create it manually by setting this option to true.
89
+ *
90
+ * @default false
91
+ */
92
+ createIssueManually?: boolean;
93
+ /**
94
+ * Enable hot key (cmd|ctrl + enter) submit comment.
95
+ *
96
+ * @default true
97
+ */
98
+ enableHotKey?: boolean;
99
+ /**
100
+ * Facebook-like distraction free mode.
101
+ *
102
+ * @default false
103
+ */
104
+ distractionFreeMode?: boolean;
105
+ /**
106
+ * Comment list animation.
107
+ *
108
+ * @default
109
+ * ```ts
110
+ * {
111
+ * staggerDelayBy: 150,
112
+ * appearAnimation: 'accordionVertical',
113
+ * enterAnimation: 'accordionVertical',
114
+ * leaveAnimation: 'accordionVertical',
115
+ * }
116
+ * ```
117
+ * @link https://github.com/joshwcomeau/react-flip-move/blob/master/documentation/enter_leave_animations.md
118
+ */
119
+ flipMoveOptions?: FlipMove.FlipMoveProps;
120
+ /**
121
+ * GitHub oauth request reverse proxy for CORS.
122
+ * [Why need this?](https://github.com/isaacs/github/issues/330)
123
+ *
124
+ * @default "https://cors-anywhere.azm.workers.dev/https://github.com/login/oauth/access_token"
125
+ */
126
+ proxy?: string;
127
+ /**
128
+ * Default user field if comments' author is not provided
129
+ *
130
+ * @default
131
+ * ```ts
132
+ * {
133
+ * avatar_url: "//avatars1.githubusercontent.com/u/29697133?s=50",
134
+ * login: "null",
135
+ * html_url: ""
136
+ * }
137
+ */
138
+ defaultUser?: Comment["user"];
139
+ /**
140
+ * Default user field if comments' author is not provided
141
+ *
142
+ * @deprecated use `defaultUser`
143
+ */
144
+ defaultAuthor?: IssueCommentsQLResponse["repository"]["issue"]["comments"]["nodes"][number]["author"];
145
+ /**
146
+ * Default collapse the comment if meets the height (px)
147
+ */
148
+ collapsedHeight?: number;
149
+ /**
150
+ * Callback method invoked when updating the number of comments.
151
+ *
152
+ * @param count comments number
153
+ */
154
+ updateCountCallback?: (count: number) => void;
155
+ /**
156
+ * Callback method invoked when a new issue is successfully created.
157
+ *
158
+ * @param issue created issue
159
+ */
160
+ onCreateIssue?: (issue: Issue) => void;
161
+ /**
162
+ * Callback method invoked when a new comment is successfully created.
163
+ *
164
+ * @param comment created comment
165
+ */
166
+ onCreateComment?: (comment: Comment) => void;
167
+ }
2
168
 
3
169
  export type User = Endpoints["GET /user"]["response"]["data"];
4
170
 
@@ -1,5 +1,4 @@
1
- import { type GitalkProps } from "../../gitalk";
2
- import type { Comment } from "../../interfaces";
1
+ import type { Comment, GitalkProps } from "../../interfaces";
3
2
 
4
3
  export interface IssueCommentsQLResponse {
5
4
  repository: {
@@ -37,8 +37,9 @@ $gt-size-loader: em(28px);
37
37
  $gt-size-avatar: em(50px);
38
38
  $gt-size-avatar-mobi: em(32px);
39
39
  $gt-size-textarea-min-height: em(82px);
40
+ $gt-size-textarea-max-height: em(240px);
40
41
  $gt-mask-z-index: 9999;
41
- $gt-breakpoint-mobile: 479px;
42
+ $gt-breakpoint-mobile: 480px;
42
43
 
43
44
  .gt-container {
44
45
  box-sizing: border-box;
@@ -383,17 +384,17 @@ $gt-breakpoint-mobile: 479px;
383
384
  display: block;
384
385
  width: 100%;
385
386
  min-height: $gt-size-textarea-min-height;
386
- max-height: em(240px);
387
+ max-height: $gt-size-textarea-max-height;
387
388
  padding: em(12px);
388
389
  font-size: em(14px);
389
390
  color: inherit;
390
391
  word-wrap: break-word;
391
- resize: vertical;
392
+ resize: none;
392
393
  outline: none;
393
394
  background-color: var(--gt-color-input-bg);
394
395
  border: 1px solid var(--gt-color-input-border);
395
396
  border-radius: $gt-size-border-radius;
396
- transition: all ease 0.25s;
397
+ transition: background-color ease 0.25s;
397
398
 
398
399
  &:hover,
399
400
  &:focus {
@@ -459,6 +460,7 @@ $gt-breakpoint-mobile: 479px;
459
460
  padding: em(10px) 0;
460
461
 
461
462
  &-content {
463
+ position: relative;
462
464
  flex: 1;
463
465
  padding: em(12px) em(16px);
464
466
  margin-left: em(20px);
@@ -476,6 +478,28 @@ $gt-breakpoint-mobile: 479px;
476
478
  }
477
479
  }
478
480
 
481
+ &-collapse {
482
+ position: absolute;
483
+ right: 0;
484
+ bottom: 0;
485
+ left: 0;
486
+ display: flex;
487
+ align-items: center;
488
+ justify-content: center;
489
+ padding: em(6px);
490
+ cursor: pointer;
491
+ background: var(--gt-color-comment-collapse-bg);
492
+
493
+ .gt-ico-collapse {
494
+ .gt-svg {
495
+ svg {
496
+ fill: var(--gt-color-text);
497
+ scale: 1.2;
498
+ }
499
+ }
500
+ }
501
+ }
502
+
479
503
  &-header {
480
504
  position: relative;
481
505
  display: flex;
@@ -496,6 +520,20 @@ $gt-breakpoint-mobile: 479px;
496
520
  &-date {
497
521
  margin-left: em(8px);
498
522
  color: var(--gt-color-sub);
523
+
524
+ &__prefix {
525
+ margin-right: em(4px);
526
+
527
+ @include mobile {
528
+ display: none;
529
+ }
530
+ }
531
+
532
+ &__time {
533
+ @include mobile {
534
+ font-size: $gt-size-base * 0.7;
535
+ }
536
+ }
499
537
  }
500
538
 
501
539
  &-actions {
@@ -18,6 +18,10 @@
18
18
  --gt-color-comment-shadow: #{color.adjust(#212121, $lightness: 18%)};
19
19
  --gt-color-comment-shadow-admin: #{color.adjust(#212121, $lightness: 24%)};
20
20
  --gt-color-comment-txt: #fafafa;
21
+ --gt-color-comment-collapse-bg: linear-gradient(
22
+ rgb(20 20 20 / 10%),
23
+ rgb(20 20 20 / 90%)
24
+ );
21
25
  --gt-color-link-active: #fafafa;
22
26
  --gt-color-btn: #eee;
23
27
  --gt-color-popbg: #171717;
@@ -18,6 +18,10 @@
18
18
  --gt-color-comment-shadow: #{color.adjust(#f9f9f9, $lightness: -12%)};
19
19
  --gt-color-comment-shadow-admin: #{color.adjust(#f9f9f9, $lightness: -18%)};
20
20
  --gt-color-comment-txt: #333;
21
+ --gt-color-comment-collapse-bg: linear-gradient(
22
+ rgb(245 245 245 / 10%),
23
+ rgb(245 245 245 / 90%)
24
+ );
21
25
  --gt-color-link-active: #333;
22
26
  --gt-color-btn: #fff;
23
27
  --gt-color-popbg: #fff;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gitalk-react",
3
- "version": "1.0.0-beta.6",
3
+ "version": "1.0.0-beta.7",
4
4
  "private": false,
5
5
  "author": {
6
6
  "name": "LolipopJ",