File tree 4 files changed +45
-14
lines changed
components/discord-reaction
4 files changed +45
-14
lines changed Original file line number Diff line number Diff line change @@ -213,12 +213,20 @@ export namespace Components {
213
213
* The reaction emoji image URL.
214
214
*/
215
215
"emoji" : string ;
216
+ /**
217
+ * Whether the reaction should be reactive.
218
+ * @remark When the reaction is interactive left clicking it will add 1 to the counter. Whereas when holding the Shift key and left clicking it will decrease the counter. The counter cannot go below 1.
219
+ * @default false
220
+ */
221
+ "interactive" : boolean ;
216
222
/**
217
223
* The name of the emoji to use as alternative image text.
224
+ * @default ':emoji'
218
225
*/
219
226
"name" : string ;
220
227
/**
221
228
* Whether the reaction should show as reacted by the user.
229
+ * @default false
222
230
*/
223
231
"reacted" : boolean ;
224
232
}
@@ -513,12 +521,20 @@ declare namespace LocalJSX {
513
521
* The reaction emoji image URL.
514
522
*/
515
523
"emoji" ?: string ;
524
+ /**
525
+ * Whether the reaction should be reactive.
526
+ * @remark When the reaction is interactive left clicking it will add 1 to the counter. Whereas when holding the Shift key and left clicking it will decrease the counter. The counter cannot go below 1.
527
+ * @default false
528
+ */
529
+ "interactive" ?: boolean ;
516
530
/**
517
531
* The name of the emoji to use as alternative image text.
532
+ * @default ':emoji'
518
533
*/
519
534
"name" ?: string ;
520
535
/**
521
536
* Whether the reaction should show as reacted by the user.
537
+ * @default false
522
538
*/
523
539
"reacted" ?: boolean ;
524
540
}
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ export class DiscordReaction implements ComponentInterface {
20
20
21
21
/**
22
22
* The name of the emoji to use as alternative image text.
23
+ * @default ':emoji'
23
24
*/
24
25
@Prop ( )
25
26
public name = ':emoji:' ;
@@ -33,10 +34,21 @@ export class DiscordReaction implements ComponentInterface {
33
34
34
35
/**
35
36
* Whether the reaction should show as reacted by the user.
37
+ * @default false
36
38
*/
37
39
@Prop ( )
38
40
public reacted = false ;
39
41
42
+ /**
43
+ * Whether the reaction should be reactive.
44
+ * @remark When the reaction is interactive left clicking it will add 1 to the counter.
45
+ * Whereas when holding the Shift key and left clicking it will decrease the counter.
46
+ * The counter cannot go below 1.
47
+ * @default false
48
+ */
49
+ @Prop ( )
50
+ public interactive = false ;
51
+
40
52
public render ( ) {
41
53
return (
42
54
< div class = { clsx ( 'discord-reaction' , { 'discord-reaction-reacted' : this . reacted } ) } onClick = { this . handleReactionClick . bind ( this ) } >
@@ -49,14 +61,16 @@ export class DiscordReaction implements ComponentInterface {
49
61
}
50
62
51
63
private handleReactionClick ( event : MouseEvent ) {
52
- if ( event . shiftKey ) {
53
- this . count -- ;
54
- } else {
55
- this . count ++ ;
56
- }
64
+ if ( this . interactive ) {
65
+ if ( event . shiftKey ) {
66
+ this . count -- ;
67
+ } else {
68
+ this . count ++ ;
69
+ }
57
70
58
- if ( this . count <= 0 ) {
59
- this . count = 1 ;
71
+ if ( this . count <= 0 ) {
72
+ this . count = 1 ;
73
+ }
60
74
}
61
75
}
62
76
}
Original file line number Diff line number Diff line change 4
4
5
5
## Properties
6
6
7
- | Property | Attribute | Description | Type | Default |
8
- | --------- | --------- | -------------------------------------------------------- | --------- | ----------- |
9
- | ` count ` | ` count ` | The number of people who reacted. | ` number ` | ` 1 ` |
10
- | ` emoji ` | ` emoji ` | The reaction emoji image URL. | ` string ` | ` undefined ` |
11
- | ` name ` | ` name ` | The name of the emoji to use as alternative image text. | ` string ` | ` ':emoji:' ` |
12
- | ` reacted ` | ` reacted ` | Whether the reaction should show as reacted by the user. | ` boolean ` | ` false ` |
7
+ | Property | Attribute | Description | Type | Default |
8
+ | ------------- | ------------- | -------------------------------------------------------- | --------- | ----------- |
9
+ | ` count ` | ` count ` | The number of people who reacted. | ` number ` | ` 1 ` |
10
+ | ` emoji ` | ` emoji ` | The reaction emoji image URL. | ` string ` | ` undefined ` |
11
+ | ` interactive ` | ` interactive ` | Whether the reaction should be reactive. | ` boolean ` | ` false ` |
12
+ | ` name ` | ` name ` | The name of the emoji to use as alternative image text. | ` string ` | ` ':emoji:' ` |
13
+ | ` reacted ` | ` reacted ` | Whether the reaction should show as reacted by the user. | ` boolean ` | ` false ` |
13
14
14
15
---
15
16
Original file line number Diff line number Diff line change @@ -177,7 +177,7 @@ <h3 class="title">Reactions</h3>
177
177
< discord-reactions slot ="reactions ">
178
178
< discord-reaction name ="👍 " emoji ="/static/thumbsup.svg " count ="1 "> </ discord-reaction >
179
179
< discord-reaction name ="👀 " emoji ="/static/eyes.svg " count ="2 " reacted > </ discord-reaction >
180
- < discord-reaction name ="👀 " emoji ="/static/dragonite.png " count ="10 " reacted > </ discord-reaction >
180
+ < discord-reaction interactive =" true " name ="dragonite " emoji ="/static/dragonite.png " count ="10 " reacted > </ discord-reaction >
181
181
</ discord-reactions >
182
182
</ discord-message >
183
183
</ discord-messages >
You can’t perform that action at this time.
0 commit comments