Skip to content

Commit

Permalink
refactor: pivot to discordapp fork which contains svgs within dist/
Browse files Browse the repository at this point in the history
Signed-off-by: Adam Setch <adam.setch@outlook.com>
  • Loading branch information
setchy committed Aug 9, 2024
1 parent 5835ab4 commit a64d2a1
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 42 deletions.
1 change: 0 additions & 1 deletion assets/svg/1f6dc.svg

This file was deleted.

7 changes: 0 additions & 7 deletions assets/svg/README.md

This file was deleted.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
"afterSign": "scripts/notarize.js"
},
"dependencies": {
"@discordapp/twemoji": "15.0.3",
"@electron/remote": "2.1.2",
"@primer/octicons-react": "19.11.0",
"@twemoji/api": "15.1.0",
Expand Down
18 changes: 18 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/components/__snapshots__/AllRead.test.tsx.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/components/__snapshots__/Oops.test.tsx.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 1 addition & 11 deletions src/components/icons/Emoji.test.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
import { render } from '@testing-library/react';
import { Errors } from '../../utils/constants';
import { Emoji, type IEmoji } from './Emoji';

describe('components/icons/Emoji.tsx', () => {
it('should render - online CDN SVGs', () => {
it('should render', () => {
const props: IEmoji = {
emoji: '🍺',
};
const tree = render(<Emoji {...props} />);
expect(tree).toMatchSnapshot();
});

it('should render - offline SVGs', () => {
const offlineEmojis = Errors.NETWORK.emojis;

const tree = render(<Emoji emoji={offlineEmojis[0]} />);

expect(tree.baseElement.innerHTML).not.toContain('https://'); // Offline emojis should not have an online URL
expect(offlineEmojis.length).toEqual(1); // Ensure all NETWORK error emojis are configured for offline use - future proofing
});
});
16 changes: 4 additions & 12 deletions src/components/icons/Emoji.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import path from 'node:path';
import twemoji from '@twemoji/api';
import twemoji from '@discordapp/twemoji';
import type { FC } from 'react';

export interface IEmoji {
Expand All @@ -18,18 +18,10 @@ export const Emoji: FC<IEmoji> = (props: IEmoji) => {
folder: 'svg',
ext: '.svg',
callback: (icon: string, options: TwemojiOptions, _variant: string) => {
// Offline
let source: string;
const source = path.resolve(
`${__dirname}/../../node_modules/@discordapp/twemoji/dist`,
);

switch (icon) {
// Offline Emojis sourced from ../assets/svg
case '1f6dc': // 🛜 wifi/network
source = path.resolve(`${__dirname}/../../assets`);
break;
default:
source = options.base;
break;
}
return ''.concat(source, '/', options.size, '/', icon, options.ext);
},
});
Expand Down
6 changes: 3 additions & 3 deletions src/components/icons/__snapshots__/Emoji.test.tsx.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a64d2a1

Please sign in to comment.