diff --git a/app/soapbox/features/emoji/components/emoji-picker.tsx b/app/soapbox/features/emoji/components/emoji-picker.tsx
index 06e7dfa9a..695fae2cc 100644
--- a/app/soapbox/features/emoji/components/emoji-picker.tsx
+++ b/app/soapbox/features/emoji/components/emoji-picker.tsx
@@ -13,7 +13,7 @@ const getImageURL = (set: string, name: string) => {
return joinPublicPath(`/packs/emoji/${name}.svg`);
};
-function Picker(props: any) {
+const Picker = (props: any) => {
const ref = useRef(null);
useEffect(() => {
@@ -23,7 +23,7 @@ function Picker(props: any) {
}, []);
return
;
-}
+};
export {
Picker,
diff --git a/app/soapbox/features/emoji/search.ts b/app/soapbox/features/emoji/search.ts
index 14123367f..e9ca9879e 100644
--- a/app/soapbox/features/emoji/search.ts
+++ b/app/soapbox/features/emoji/search.ts
@@ -40,6 +40,7 @@ export const addCustomToPool = (customEmojis: any[]) => {
const search = (str: string, { maxResults = 5, custom }: searchOptions = {}, custom_emojis?: any): Emoji[] => {
return index.search(str, maxResults)
.flatMap((id: string) => {
+ console.log(id);
if (id[0] === 'c') {
const { shortcode, static_url } = custom_emojis.get((id as string).slice(1)).toJS();
@@ -55,7 +56,7 @@ const search = (str: string, { maxResults = 5, custom }: searchOptions = {}, cus
return {
id: (id as string).slice(1),
- colons: ':' + id + ':',
+ colons: ':' + id.slice(1) + ':',
unified: skins[0].unified,
native: skins[0].native,
};
diff --git a/app/soapbox/features/soapbox-config/components/icon-picker-dropdown.tsx b/app/soapbox/features/soapbox-config/components/icon-picker-dropdown.tsx
index 950afdc08..4abde9e5a 100644
--- a/app/soapbox/features/soapbox-config/components/icon-picker-dropdown.tsx
+++ b/app/soapbox/features/soapbox-config/components/icon-picker-dropdown.tsx
@@ -13,10 +13,10 @@ const messages = defineMessages({
interface IIconPickerDropdown {
value: string
- onPickEmoji: React.ChangeEventHandler
+ onPickIcon: (icon: string) => void
}
-const IconPickerDropdown: React.FC = ({ value, onPickEmoji }) => {
+const IconPickerDropdown: React.FC = ({ value, onPickIcon }) => {
const intl = useIntl();
const [active, setActive] = useState(false);
@@ -73,9 +73,9 @@ const IconPickerDropdown: React.FC = ({ value, onPickEmoji
diff --git a/app/soapbox/features/soapbox-config/components/icon-picker-menu.tsx b/app/soapbox/features/soapbox-config/components/icon-picker-menu.tsx
index 7e975afaa..765d282c2 100644
--- a/app/soapbox/features/soapbox-config/components/icon-picker-menu.tsx
+++ b/app/soapbox/features/soapbox-config/components/icon-picker-menu.tsx
@@ -1,30 +1,25 @@
-/* eslint-disable @typescript-eslint/no-unused-vars */
import clsx from 'clsx';
import { supportsPassiveEvents } from 'detect-passive-events';
import React, { useCallback, useEffect, useRef } from 'react';
-import { defineMessages, useIntl } from 'react-intl';
+import { FormattedMessage, defineMessages, useIntl } from 'react-intl';
+
+import { Text } from 'soapbox/components/ui';
const messages = defineMessages({
emoji: { id: 'icon_button.label', defaultMessage: 'Select icon' },
- emoji_search: { id: 'emoji_button.search', defaultMessage: 'Search…' },
- emoji_not_found: { id: 'icon_button.not_found', defaultMessage: 'No icons!! (╯°□°)╯︵ ┻━┻' },
- custom: { id: 'icon_button.icons', defaultMessage: 'Icons' },
- search_results: { id: 'emoji_button.search_results', defaultMessage: 'Search results' },
});
-const backgroundImageFn = () => '';
const listenerOptions = supportsPassiveEvents ? { passive: true } : false;
-const categoriesSort = ['custom'];
interface IIconPickerMenu {
- customEmojis: Record>
+ icons: Record>
onClose: () => void
- onPick: any
+ onPick: (icon: string) => void
style?: React.CSSProperties
}
-const IconPickerMenu: React.FC = ({ customEmojis, onClose, onPick, style }) => {
+const IconPickerMenu: React.FC = ({ icons, onClose, onPick, style }) => {
const intl = useIntl();
const node = useRef(null);
@@ -59,70 +54,42 @@ const IconPickerMenu: React.FC = ({ customEmojis, onClose, onPi
});
};
- const getI18n = () => {
-
- return {
- search: intl.formatMessage(messages.emoji_search),
- notfound: intl.formatMessage(messages.emoji_not_found),
- categories: {
- search: intl.formatMessage(messages.search_results),
- custom: intl.formatMessage(messages.custom),
- },
- };
- };
-
- const handleClick = (emoji: Record) => {
- emoji.native = emoji.colons;
-
+ const handleClick = (icon: string) => {
onClose();
- onPick(emoji);
+ onPick(icon);
};
- const buildIcons = () => {
- const emojis: Record = [];
+ const renderIcon = (icon: string) => {
+ const name = icon.replace('fa fa-', '');
- Object.values(customEmojis).forEach((category) => {
- category.forEach((icon) => {
- const name = icon.replace('fa fa-', '');
- if (icon !== 'email' && icon !== 'memo') {
- emojis.push({
- id: name,
- name,
- short_names: [name],
- emoticons: [],
- keywords: [name],
- imageUrl: '',
- });
- }
- });
- });
-
- return emojis;
+ return (
+
+
+
+ );
};
- const data = { compressed: true, categories: [], aliases: [], emojis: [] };
const title = intl.formatMessage(messages.emoji);
return (
-
- {/*
*/}
+
+
+
+
+ {Object.values(icons).flat().map(icon => renderIcon(icon))}
+
+
);
};
diff --git a/app/soapbox/features/soapbox-config/components/icon-picker.tsx b/app/soapbox/features/soapbox-config/components/icon-picker.tsx
index 475f87b6a..e4b9d6c5e 100644
--- a/app/soapbox/features/soapbox-config/components/icon-picker.tsx
+++ b/app/soapbox/features/soapbox-config/components/icon-picker.tsx
@@ -4,15 +4,13 @@ import IconPickerDropdown from './icon-picker-dropdown';
interface IIconPicker {
value: string
- onChange: React.ChangeEventHandler
+ onChange: (icon: string) => void
}
-const IconPicker: React.FC
= ({ value, onChange }) => {
- return (
-
-
-
- );
-};
+const IconPicker: React.FC = ({ value, onChange }) => (
+
+
+
+);
export default IconPicker;
diff --git a/app/soapbox/features/soapbox-config/components/promo-panel-input.tsx b/app/soapbox/features/soapbox-config/components/promo-panel-input.tsx
index 93e32b0e3..0dd530c39 100644
--- a/app/soapbox/features/soapbox-config/components/promo-panel-input.tsx
+++ b/app/soapbox/features/soapbox-config/components/promo-panel-input.tsx
@@ -17,8 +17,8 @@ const messages = defineMessages({
const PromoPanelInput: StreamfieldComponent = ({ value, onChange }) => {
const intl = useIntl();
- const handleIconChange = (icon: any) => {
- onChange(value.set('icon', icon.id));
+ const handleIconChange = (icon: string) => {
+ onChange(value.set('icon', icon));
};
const handleChange = (key: 'text' | 'url'): React.ChangeEventHandler => {