Skip to content

Commit

Permalink
feat: camel case emoji data, rename native to isNative
Browse files Browse the repository at this point in the history
Breaking Changes: variables renamed
short_names -> shortNames
short_name -> shortName
obsoleted_by -> obsoletedBy
skin_tone -> SkinTone
Component Input renamed native -> isNative
  • Loading branch information
scttcper committed Aug 9, 2018
1 parent 23d1edf commit 473944a
Show file tree
Hide file tree
Showing 14 changed files with 4,109 additions and 4,102 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ use component
| **perLine** | `9` | Number of emojis per line. While there’s no minimum or maximum, this will affect the picker’s width. This will set _Frequently Used_ length as well (`perLine * totalFrequentLines (4)`) |
| **totalFrequentLines** | `4` | number of lines of frequently used emojis |
| **i18n** | [`{…}`](#i18n) | [An object](#i18n) containing localized strings |
| **native** | `false` | Renders the native unicode emoji |
| **isNative** | `false` | Renders the native unicode emoji |
| **set** | `apple` | The emoji set: `'apple', 'google', 'twitter', 'emojione', 'messenger', 'facebook'` |
| **sheetSize** | `64` | The emoji [sheet size](#sheet-sizes): `16, 20, 32, 64` |
| **backgroundImageFn** | `((set, sheetSize) => …)` | A Fn that returns that image sheet to use for emojis. Useful for avoiding a request if you have the sheet locally. |
Expand Down Expand Up @@ -215,7 +215,7 @@ Certain sets don’t support all emojis (i.e. Messenger & Facebook don’t suppo

To have the component render `:shrug:` you would need to:
```ts
emojiFallback = (emoji: any, props: any) => emoji ? `:${emoji.short_names[0]}:` : props.emoji
emojiFallback = (emoji: any, props: any) => emoji ? `:${emoji.shortNames[0]}:` : props.emoji
```
```html
<ngx-emoji
Expand Down
21 changes: 14 additions & 7 deletions scripts/build-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import * as stringifyObject from 'stringify-object';
const categories: any[] = [];
const emojis: any[] = [];
const skins: any[] = [];
const short_names: any = {};
const categoriesIndex: any = {};

const catPairs = [
Expand Down Expand Up @@ -107,8 +106,7 @@ emojiData.forEach((datum: any) => {

missingSets(datum);
if (datum.skin_variations) {
const variations = [];
for (const key of Object.keys(datum.skin_variations)) {
datum.skinVariations = Object.keys(datum.skin_variations).map((key) => {
const variation = datum.skin_variations[key];
setupSheet(variation);
missingSets(variation);
Expand All @@ -124,12 +122,21 @@ emojiData.forEach((datum: any) => {
delete variation.sort_order;
delete variation.obsoleted_by;
delete variation.obsoletes;
variations.push(variation);
}
datum.skin_variations = variations;
return variation;
});
delete datum.skin_variations;
}

datum.short_names = datum.short_names.filter((i: any) => i !== datum.short_name);
datum.shortNames = datum.short_names.filter((i: any) => i !== datum.short_name);
delete datum.short_names;

// renaming
datum.shortName = datum.short_name;
delete datum.short_name;
if (datum.obsoleted_by) {
datum.obsoletedBy = datum.obsoleted_by;
}
delete datum.obsoleted_by;


if (datum.text === '') {
Expand Down
6 changes: 3 additions & 3 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ import { Component } from '@angular/core';
const CUSTOM_EMOJIS = [
{
name: 'Party Parrot',
short_names: ['parrot'],
shortNames: ['parrot'],
keywords: ['party'],
imageUrl: './assets/images/parrot.gif',
},
{
name: 'Octocat',
short_names: ['octocat'],
shortNames: ['octocat'],
keywords: ['github'],
imageUrl: 'https://assets-cdn.github.com/images/icons/emoji/octocat.png?v7',
},
{
name: 'Squirrel',
short_names: ['shipit', 'squirrel'],
shortNames: ['shipit', 'squirrel'],
keywords: ['github'],
imageUrl: 'https://assets-cdn.github.com/images/icons/emoji/shipit.png?v7',
},
Expand Down
21 changes: 10 additions & 11 deletions src/lib/emoji/data/data.interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,35 @@ export interface EmojiCategory {
export interface CompressedEmojiData {
name: string;
unified: string;
short_name: string;
short_names?: string[];
shortName: string;
shortNames?: string[];
sheet: [number, number];
keywords?: string[];
hidden?: string[];
emoticons?: string[];
text?: string;
skin_variations?: EmojiVariation[];
obsoleted_by?: string;
skinVariations?: EmojiVariation[];
obsoletedBy?: string;
obsoletes?: string;
}

export interface EmojiData {
id: string;
name: string;
unified?: string;
short_name: string;
short_names: string[];
shortName: string;
shortNames: string[];
sheet: [number, number];
keywords: string[];
hidden: string[];
emoticons: string[];
text: string;
set?: Emoji['set'];
variations?: EmojiVariation[];
skin_variations: EmojiVariation[];
obsoleted_by?: string;
skinVariations: EmojiVariation[];
obsoletedBy?: string;
obsoletes?: string;
// search: any;
skin_tone?: Emoji['skin'];
skinTone?: Emoji['skin'];
custom?: boolean;
native?: string;
imageUrl?: string;
Expand All @@ -57,7 +56,7 @@ export interface EmojiVariation {
export interface SkinData {
name: string;
unified: string;
short_name: string;
shortName: string;
hidden: string[];
sheet: [number, number];
}
Loading

0 comments on commit 473944a

Please sign in to comment.