refactor: add unicode version, slug and reduce json size
This commit is contained in:
parent
db04194152
commit
bdb8799fe1
|
@ -25,6 +25,7 @@ export default function App() {
|
|||
"emoji": "❤️",
|
||||
"name": "red heart",
|
||||
"slug": "red_heart",
|
||||
"unicode_version": "0.6",
|
||||
}
|
||||
*/
|
||||
};
|
||||
|
|
|
@ -6,7 +6,7 @@ for (const [key, value] of Object.entries(json)) {
|
|||
const newData = value.map((emoji) => ({
|
||||
emoji: emoji.emoji,
|
||||
name: emoji.name,
|
||||
slug: emoji.slug,
|
||||
v: emoji.unicode_version,
|
||||
}));
|
||||
newArray.push({
|
||||
title: key.replace(' & ', '_').replace(' ', '_').toLocaleLowerCase(),
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,7 +1,7 @@
|
|||
import * as React from 'react';
|
||||
|
||||
import { StyleSheet, View, Text, FlatList } from 'react-native';
|
||||
import type { EmojisByCategory, EmojiType } from '../types';
|
||||
import type { EmojisByCategory, EmojiType, JsonEmoji } from '../types';
|
||||
import { SingleEmoji } from './SingleEmoji';
|
||||
import { KeyboardContext } from '../KeyboardContext';
|
||||
|
||||
|
@ -9,9 +9,7 @@ const emptyEmoji = {
|
|||
emoji: '',
|
||||
name: 'blank emoji',
|
||||
slug: 'blank_emoji',
|
||||
skin_tone_support: false,
|
||||
unicode_version: '0',
|
||||
emoji_version: '0',
|
||||
};
|
||||
|
||||
export const EmojiCategory = ({
|
||||
|
@ -46,11 +44,18 @@ export const EmojiCategory = ({
|
|||
index,
|
||||
});
|
||||
|
||||
const parseEmoji = (emoji: JsonEmoji) => ({
|
||||
name: emoji.name,
|
||||
emoji: emoji.emoji,
|
||||
unicode_version: emoji.v,
|
||||
slug: emoji.name.replace(' ', '_'),
|
||||
});
|
||||
|
||||
const renderItem = React.useCallback(
|
||||
(props) => (
|
||||
<SingleEmoji
|
||||
{...props}
|
||||
onPress={() => onEmojiSelected(props.item)}
|
||||
onPress={() => onEmojiSelected(parseEmoji(props.item))}
|
||||
emojiSize={emojiSize}
|
||||
/>
|
||||
),
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import * as React from 'react';
|
||||
import { View, Text, TouchableOpacity, StyleSheet } from 'react-native';
|
||||
import type { EmojiType } from '../types';
|
||||
import type { JsonEmoji } from '../types';
|
||||
|
||||
export class SingleEmoji extends React.Component<{
|
||||
item: EmojiType;
|
||||
onPress: (emojiObject: EmojiType) => void;
|
||||
item: JsonEmoji;
|
||||
onPress: () => void;
|
||||
emojiSize: number;
|
||||
}> {
|
||||
shouldComponentUpdate() {
|
||||
|
@ -13,7 +13,7 @@ export class SingleEmoji extends React.Component<{
|
|||
render() {
|
||||
const { item, emojiSize, onPress } = this.props;
|
||||
return (
|
||||
<TouchableOpacity onPress={() => onPress(item)} style={styles.container}>
|
||||
<TouchableOpacity onPress={() => onPress()} style={styles.container}>
|
||||
<View style={styles.iconContainer}>
|
||||
<Text style={{ fontSize: emojiSize }}>{item.emoji}</Text>
|
||||
</View>
|
||||
|
|
|
@ -1,7 +1,13 @@
|
|||
export type JsonEmoji = {
|
||||
emoji: string;
|
||||
name: string;
|
||||
v: string;
|
||||
};
|
||||
export type EmojiType = {
|
||||
emoji: string;
|
||||
name: string;
|
||||
slug: string;
|
||||
unicode_version: string;
|
||||
};
|
||||
|
||||
export type CategoryTypes =
|
||||
|
|
Loading…
Reference in New Issue