Fix getting category names from i18n
Since the Category names update in emoji-data (4.0.0)release
parent
63509f72ea
commit
fdf3c2d3a3
|
@ -40,13 +40,24 @@ var emojiLibByChar = Object.keys(emojiLib.lib).reduce(
|
||||||
{}
|
{}
|
||||||
)
|
)
|
||||||
|
|
||||||
var categories = ['Smileys & People', 'Animals & Nature', 'Food & Drink', 'Activities', 'Travel & Places', 'Objects', 'Symbols', 'Flags'],
|
var data = { categories: [], emojis: {}, skins: {}, short_names: {} },
|
||||||
data = { categories: [], emojis: {}, skins: {}, short_names: {} },
|
|
||||||
categoriesIndex = {}
|
categoriesIndex = {}
|
||||||
|
|
||||||
|
var categories = [
|
||||||
|
['Smileys & People', 'people'],
|
||||||
|
['Animals & Nature', 'nature'],
|
||||||
|
['Food & Drink', 'foods'],
|
||||||
|
['Activities', 'activity'],
|
||||||
|
['Travel & Places', 'places'],
|
||||||
|
['Objects', 'objects'],
|
||||||
|
['Symbols', 'symbols'],
|
||||||
|
['Flags', 'flags'],
|
||||||
|
]
|
||||||
|
|
||||||
categories.forEach((category, i) => {
|
categories.forEach((category, i) => {
|
||||||
data.categories[i] = { name: category, emojis: [] }
|
let [name, id] = category
|
||||||
categoriesIndex[category] = i
|
data.categories[i] = { id: id, name: name, emojis: [] }
|
||||||
|
categoriesIndex[name] = i
|
||||||
})
|
})
|
||||||
|
|
||||||
emojiData.sort((a, b) => {
|
emojiData.sort((a, b) => {
|
||||||
|
|
|
@ -144,7 +144,7 @@ export default class Category extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
var { name, hasStickyPosition, emojiProps, i18n } = this.props,
|
var { id, name, hasStickyPosition, emojiProps, i18n } = this.props,
|
||||||
emojis = this.getEmojis(),
|
emojis = this.getEmojis(),
|
||||||
labelStyles = {},
|
labelStyles = {},
|
||||||
labelSpanStyles = {},
|
labelSpanStyles = {},
|
||||||
|
@ -180,7 +180,7 @@ export default class Category extends React.Component {
|
||||||
className="emoji-mart-category-label"
|
className="emoji-mart-category-label"
|
||||||
>
|
>
|
||||||
<span style={labelSpanStyles} ref={this.setLabelRef}>
|
<span style={labelSpanStyles} ref={this.setLabelRef}>
|
||||||
{i18n.categories[name.toLowerCase()]}
|
{i18n.categories[id]}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -10,9 +10,9 @@ import { deepMerge, measureScrollbar } from '../utils'
|
||||||
|
|
||||||
import { Anchors, Category, Emoji, Preview, Search } from '.'
|
import { Anchors, Category, Emoji, Preview, Search } from '.'
|
||||||
|
|
||||||
const RECENT_CATEGORY = { name: 'Recent', emojis: null }
|
const RECENT_CATEGORY = { id: 'recent', name: 'Recent', emojis: null }
|
||||||
const SEARCH_CATEGORY = { name: 'Search', emojis: null, anchor: false }
|
const SEARCH_CATEGORY = { id: 'search', name: 'Search', emojis: null, anchor: false }
|
||||||
const CUSTOM_CATEGORY = { name: 'Custom', emojis: [] }
|
const CUSTOM_CATEGORY = { id: 'custom', name: 'Custom', emojis: [] }
|
||||||
|
|
||||||
const I18N = {
|
const I18N = {
|
||||||
search: 'Search',
|
search: 'Search',
|
||||||
|
@ -459,6 +459,7 @@ export default class Picker extends React.PureComponent {
|
||||||
<Category
|
<Category
|
||||||
ref={this.setCategoryRef.bind(this, `category-${i}`)}
|
ref={this.setCategoryRef.bind(this, `category-${i}`)}
|
||||||
key={category.name}
|
key={category.name}
|
||||||
|
id={category.id}
|
||||||
name={category.name}
|
name={category.name}
|
||||||
emojis={category.emojis}
|
emojis={category.emojis}
|
||||||
perLine={perLine}
|
perLine={perLine}
|
||||||
|
|
Loading…
Reference in New Issue