-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Calvin Rohloff
committed
Sep 19, 2024
1 parent
1930671
commit da04831
Showing
10 changed files
with
119 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export interface Reaction { | ||
count: number; | ||
emoji: { | ||
id: string | null; | ||
name: string; | ||
}; | ||
me: true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { Reaction } from '@/discord/structures/Reaction'; | ||
import { grabTheRightIcon } from '@/utils/emojiUtils'; | ||
|
||
type MessageReactionProps = { | ||
reaction: Reaction; | ||
}; | ||
|
||
export default function MessageReaction({ reaction }: MessageReactionProps) { | ||
const twemojiHash = | ||
reaction.emoji.id === null ? grabTheRightIcon(reaction.emoji.name) : null; | ||
|
||
const url = twemojiHash | ||
? `https://cdn.jsdelivr.net/gh/twitter/twemoji@latest/assets/svg/${twemojiHash}.svg` | ||
: undefined; | ||
|
||
return ( | ||
<div className="MessageReaction"> | ||
<img className="MessageReaction-emoji" src={url} alt="" /> | ||
<p className="MessageReaction-count">{reaction.count}</p> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,18 @@ | ||
import { createRoot } from 'react-dom/client'; | ||
import App from './App'; | ||
import { AppConfig } from '../common/appconfig'; | ||
|
||
const container = document.getElementById('root') as HTMLElement; | ||
const root = createRoot(container); | ||
root.render(<App />); | ||
// eslint-disable-next-line import/prefer-default-export, import/no-mutable-exports | ||
export let config: AppConfig | null = null; | ||
|
||
window.electron.ipcRenderer | ||
.invoke('app:config') | ||
.then((conf: AppConfig) => { | ||
config = conf; | ||
|
||
const container = document.getElementById('root') as HTMLElement; | ||
const root = createRoot(container); | ||
root.render(<App />); | ||
return true; | ||
}) | ||
.catch((err) => console.error(err)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
.MessageReaction { | ||
display: flex; | ||
gap: 6px; | ||
min-width: 40px; | ||
height: 20px; | ||
padding: 10px 12px; | ||
background: #4d7cf227; | ||
border-radius: 10px; | ||
border: 2px solid #4d7cf263; | ||
cursor: pointer; | ||
} | ||
|
||
.MessageReaction:hover { | ||
transform: scale(1.02); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
const UFE0Fg = /\uFE0F/g; | ||
|
||
// avoid using a string literal like '\u200D' here because minifiers expand it inline | ||
const U200D = String.fromCharCode(0x200d); | ||
|
||
function toCodePoint(unicodeSurrogates: string, sep?: string) { | ||
const r = []; | ||
let c = 0; | ||
let p = 0; | ||
let i = 0; | ||
|
||
while (i < unicodeSurrogates.length) { | ||
// eslint-disable-next-line no-plusplus | ||
c = unicodeSurrogates.charCodeAt(i++); | ||
if (p) { | ||
// eslint-disable-next-line no-bitwise | ||
r.push((0x10000 + ((p - 0xd800) << 10) + (c - 0xdc00)).toString(16)); | ||
p = 0; | ||
} else if (c >= 0xd800 && c <= 0xdbff) { | ||
p = c; | ||
} else { | ||
r.push(c.toString(16)); | ||
} | ||
} | ||
return r.join(sep ?? '-'); | ||
} | ||
|
||
// eslint-disable-next-line import/prefer-default-export | ||
export function grabTheRightIcon(emoji: string) { | ||
return toCodePoint( | ||
emoji.indexOf(U200D) < 0 ? emoji.replace(UFE0Fg, '') : emoji, | ||
); | ||
} |