-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finished server rendering of template using absurd, css next
- Loading branch information
1 parent
576450a
commit c84ef21
Showing
10 changed files
with
126 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
import { CATEGORY } from './constant'; | ||
const CATEGORY = require('./constant').CATEGORY; | ||
|
||
export default [ | ||
module.exports = [ | ||
CATEGORY.PEOPLE, | ||
CATEGORY.NATURE, | ||
CATEGORY.ACTIVITY, | ||
CATEGORY.PLACES, | ||
CATEGORY.OBJECTS, | ||
CATEGORY.SYMBOLS, | ||
CATEGORY.FLAGS, | ||
CATEGORY.OTHER | ||
CATEGORY.FLAGS | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,26 @@ | ||
export const IMAGE_SET = { | ||
const IMAGE_SET = { | ||
APPLE: 0, | ||
GOOGLE: 1, | ||
TWITTER: 2, | ||
EMOJIONE: 4 | ||
}; | ||
|
||
export const SIZE = { | ||
const SIZE = { | ||
16: 0, | ||
20: 1, | ||
32: 2, | ||
64: 4 | ||
}; | ||
|
||
export const CATEGORY = { | ||
const CATEGORY = { | ||
ACTIVITY: 0, | ||
FLAGS: 1, | ||
FOODS: 2, | ||
NATURE: 4, | ||
OBJECTS: 8, | ||
PEOPLE: 16, | ||
PLACES: 32, | ||
SYMBOLS: 64, | ||
OTHER: 128 | ||
SYMBOLS: 64 | ||
}; | ||
|
||
module.exports = { IMAGE_SET, SIZE, CATEGORY }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
const emojiData = require('emoji-data'); | ||
const categoryDataMap = require('./map').categoryDataMap; | ||
|
||
const sortedEmojiData = emojiData | ||
.sort((emojiA, emojiB) => emojiA['sort_order'] - emojiB['sort_order']) | ||
.reduce((obj, emoji, index) => { | ||
const category = categoryDataMap[emoji.category]; | ||
const categoryArray = obj[category] || []; | ||
return Object.assign(obj, { | ||
[category]: categoryArray.concat(Object.assign(emoji, { index })) | ||
}); | ||
}, {}); | ||
|
||
module.exports = sortedEmojiData; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,35 @@ | ||
import { IMAGE_SET, SIZE, CATEGORY } from './constant'; | ||
const Constant = require('./constant'); | ||
const IMAGE_SET = Constant.IMAGE_SET; | ||
const SIZE = Constant.SIZE; | ||
const CATEGORY = Constant.CATEGORY; | ||
|
||
export const categoryDataMap = { | ||
const categoryDataMap = { | ||
Activity: CATEGORY.ACTIVITY, | ||
Flags: CATEGORY.FLAGS, | ||
Foods: CATEGORY.FOODS, | ||
Nature: CATEGORY.NATURE, | ||
Objects: CATEGORY.OBJECTS, | ||
People: CATEGORY.PEOPLE, | ||
Places: CATEGORY.PLACES, | ||
Symbols: CATEGORY.SYMBOLS, | ||
null: CATEGORY.OTHER | ||
Symbols: CATEGORY.SYMBOLS | ||
}; | ||
|
||
export const categoryNameMap = { | ||
const categoryNameMap = { | ||
[CATEGORY.ACTIVITY]: 'ACTIVITY', | ||
[CATEGORY.FLAGS]: 'FLAGS', | ||
[CATEGORY.FOODS]: 'FOOD & DRINK', | ||
[CATEGORY.NATURE]: 'ANIMALS & NATURE', | ||
[CATEGORY.OBJECTS]: 'OBJECTS', | ||
[CATEGORY.PEOPLE]: 'SMILEYS & PEOPLE', | ||
[CATEGORY.PLACES]: 'TRAVEL & PLACES', | ||
[CATEGORY.SYMBOLS]: 'SYMBOLS', | ||
[CATEGORY.OTHER]: 'OTHER' | ||
[CATEGORY.SYMBOLS]: 'SYMBOLS' | ||
}; | ||
|
||
export const sizeMap = { | ||
const sizeMap = { | ||
'0': 16, | ||
'1': 20, | ||
'2': 32, | ||
'4': 64 | ||
}; | ||
|
||
module.exports = { categoryDataMap, categoryNameMap, sizeMap }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
const emojiData = require('./emoji.data'); | ||
const categoryOrder = require('./category-order'); | ||
const Constant = require('./constant'); | ||
const Map = require('./map'); | ||
const IMAGE_SET = Constant.IMAGE_SET; | ||
const SIZE = Constant.SIZE; | ||
const sizeMap = Map.sizeMap; | ||
const categoryDataMap = Map.categoryDataMap; | ||
const categoryNameMap = Map.categoryNameMap; | ||
|
||
const getBoolNameByImageSet = imageSet => { | ||
switch (imageSet) { | ||
case IMAGE_SET.APPLE: | ||
return 'has_img_apple'; | ||
case IMAGE_SET.GOOGLE: | ||
return 'has_img_google'; | ||
case IMAGE_SET.TWITTER: | ||
return 'has_img_twitter'; | ||
case IMAGE_SET.EMOJIONE: | ||
return 'has_img_emojione'; | ||
} | ||
}; | ||
const getImageSetClassName = imageSet => { | ||
switch (imageSet) { | ||
case IMAGE_SET.APPLE: | ||
return 'ep-a'; | ||
case IMAGE_SET.GOOGLE: | ||
return 'ep-g'; | ||
case IMAGE_SET.TWITTER: | ||
return 'ep-t'; | ||
case IMAGE_SET.EMOJIONE: | ||
return 'ep-e'; | ||
} | ||
}; | ||
|
||
const getSizeKeyByValue = size => { | ||
return sizeMap[size]; | ||
}; | ||
|
||
const getEmojiClassName = emoji => { | ||
const className = Object.keys(IMAGE_SET).reduce((_className, imageSetKey) => { | ||
const imageSet = IMAGE_SET[imageSetKey]; | ||
const boolNameForImageSet = getBoolNameByImageSet(imageSet); | ||
if (emoji[boolNameForImageSet]) { | ||
const imageSetClassName = getImageSetClassName(imageSet); | ||
return _className + ` ${imageSetClassName}`; | ||
} else { | ||
return _className; | ||
} | ||
}, ''); | ||
return className; | ||
}; | ||
|
||
module.exports = api => { | ||
api.morph('html').add({ | ||
'div[class="ep"]': { | ||
'div[class="ep-categories"]': categoryOrder.reduce((obj, category) => Object.assign(obj, { | ||
[`span[class="ep-c" data-category-id="${category}"]`]: { | ||
[`span[class="cat cat-${category}"]`]: '', | ||
'span[class="ep-c-text"]': categoryNameMap[category] | ||
} | ||
}), {}), | ||
'div[class="ep-emojies"]': categoryOrder.reduce((catObj, category) => Object.assign(catObj, { | ||
[`div[class="ep-emojies-c" data-category-id="${category}"]`]: { | ||
'div': emojiData[category].reduce((emojiObj, emoji) => Object.assign(emojiObj, { | ||
[`span[class="ep-emoji${getEmojiClassName(emoji)}" data-index="${emoji.index}"]`]: '' | ||
}), {}) | ||
} | ||
}), {}) | ||
} | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters