Skip to content

Commit

Permalink
fix: rename customCategorySort to customCategorySorting (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
nolanlawson committed Sep 13, 2020
1 parent 6be51f1 commit 117b201
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions README.md
Expand Up @@ -233,7 +233,7 @@ The `new Picker(options)` constructor supports several options:

Name | Type | Default | Description |
------ | ------ | ------ | ------ |
`customCategorySort` | function | - | Function to sort custom category strings (sorted alphabetically by default) |
`customCategorySorting` | function | - | Function to sort custom category strings (sorted alphabetically by default) |
`customEmoji` | CustomEmoji[] | - | Array of custom emoji |
`dataSource` | string | "https://cdn.jsdelivr.net/npm/emojibase-data@5/en/data.json" | URL to fetch the emojibase data from (`data-source` when used as an attribute) |
`i18n` | I18n | - | i18n object (see below for details) |
Expand Down Expand Up @@ -323,10 +323,10 @@ But you should still support them if you internationalize your app!

#### Custom category order

By default, custom categories are sorted alphabetically. To change this, pass in your own `customCategorySort`:
By default, custom categories are sorted alphabetically. To change this, pass in your own `customCategorySorting`:

```js
picker.customCategorySort = (category1, category2) => { /* your sorting code */ };
picker.customCategorySorting = (category1, category2) => { /* your sorting code */ };
```

This function should accept two strings and return a number.
Expand Down
6 changes: 3 additions & 3 deletions src/picker/components/Picker/Picker.js
Expand Up @@ -35,7 +35,7 @@ let skinToneEmoji = DEFAULT_SKIN_TONE_EMOJI
let i18n = enI18n
let database = null
let customEmoji = null
let customCategorySort = (a, b) => a < b ? -1 : a > b ? 1 : 0
let customCategorySorting = (a, b) => a < b ? -1 : a > b ? 1 : 0

// private
let initialLoad = true
Expand Down Expand Up @@ -407,7 +407,7 @@ $: {
}
return [...categoriesToEmoji.entries()]
.map(([category, emojis]) => ({ category, emojis }))
.sort((a, b) => customCategorySort(a.category, b.category))
.sort((a, b) => customCategorySorting(a.category, b.category))
}

currentEmojisWithCategories = calculateCurrentEmojisWithCategories()
Expand Down Expand Up @@ -616,5 +616,5 @@ export {
i18n,
skinToneEmoji,
customEmoji,
customCategorySort
customCategorySorting
}
6 changes: 3 additions & 3 deletions src/types/picker.ts
Expand Up @@ -6,7 +6,7 @@ export default class Picker extends HTMLElement {
i18n: I18n
skinToneEmoji: string
customEmoji?: CustomEmoji[]
customCategorySort?: (a: string, b: string) => number
customCategorySorting?: (a: string, b: string) => number

/**
*
Expand All @@ -15,15 +15,15 @@ export default class Picker extends HTMLElement {
* @param i18n - i18n object (see below for details)
* @param skinToneEmoji - The emoji to use for the skin tone picker (`skin-tone-emoji` when used as an attribute)
* @param customEmoji - Array of custom emoji
* @param customCategorySort - Function to sort custom category strings (sorted alphabetically by default)
* @param customCategorySorting - Function to sort custom category strings (sorted alphabetically by default)
*/
constructor({
dataSource = 'https://cdn.jsdelivr.net/npm/emojibase-data@5/en/data.json',
locale = 'en',
i18n,
skinToneEmoji = '🖐️',
customEmoji,
customCategorySort
customCategorySorting
}: PickerConstructorOptions = {}) {
super()
}
Expand Down
2 changes: 1 addition & 1 deletion src/types/shared.ts
Expand Up @@ -38,7 +38,7 @@ export interface PickerConstructorOptions {
i18n?: I18n
skinToneEmoji?: string
customEmoji?: CustomEmoji[]
customCategorySort?: (a: string, b: string) => number
customCategorySorting?: (a: string, b: string) => number
}

export interface I18n {
Expand Down
2 changes: 1 addition & 1 deletion test/spec/picker/Picker.test.js
Expand Up @@ -419,7 +419,7 @@ describe('Picker tests', () => {
])

const order = ['Ungulates', 'Primates', 'Avians']
picker.customCategorySort = (a, b) => {
picker.customCategorySorting = (a, b) => {
const aIdx = order.indexOf(a)
const bIdx = order.indexOf(b)
return aIdx < bIdx ? -1 : 1
Expand Down

0 comments on commit 117b201

Please sign in to comment.