-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: use emoji-mart all.json, split out json (#839)
- Loading branch information
1 parent
2d32a91
commit e6ca246
Showing
10 changed files
with
69 additions
and
29 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
#!/usr/bin/env node | ||
|
||
import crypto from 'crypto' | ||
import fs from 'fs' | ||
import pify from 'pify' | ||
|
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,5 +1,3 @@ | ||
#!/usr/bin/env node | ||
|
||
import svgs from './svgs' | ||
import path from 'path' | ||
import fs from 'fs' | ||
|
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,33 @@ | ||
import path from 'path' | ||
import fs from 'fs' | ||
import pify from 'pify' | ||
import CleanCSS from 'clean-css' | ||
|
||
const writeFile = pify(fs.writeFile.bind(fs)) | ||
const readFile = pify(fs.readFile.bind(fs)) | ||
const copyFile = pify(fs.copyFile.bind(fs)) | ||
|
||
async function compileThirdPartyCss () { | ||
let css = await readFile(path.resolve(__dirname, '../node_modules/emoji-mart/css/emoji-mart.css'), 'utf8') | ||
css = `/* compiled from emoji-mart.css */` + new CleanCSS().minify(css).styles | ||
await writeFile(path.resolve(__dirname, '../static/emoji-mart.css'), css, 'utf8') | ||
} | ||
|
||
async function compileThirdPartyJson () { | ||
await copyFile( | ||
path.resolve(__dirname, '../node_modules/emoji-mart/data/all.json'), | ||
path.resolve(__dirname, '../static/emoji-mart-all.json') | ||
) | ||
} | ||
|
||
async function main () { | ||
await Promise.all([ | ||
compileThirdPartyCss(), | ||
compileThirdPartyJson() | ||
]) | ||
} | ||
|
||
main().catch(err => { | ||
console.error(err) | ||
process.exit(1) | ||
}) |
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { importEmojiMart } from '../_utils/asyncModules' | ||
import { loadCSS } from '../_utils/loadCSS' | ||
|
||
async function fetchEmojiMartData () { | ||
return (await fetch('/emoji-mart-all.json')).json() | ||
} | ||
|
||
let Picker // cache so we don't have to recreate every time | ||
|
||
export async function createEmojiMartPicker () { | ||
if (!Picker) { | ||
loadCSS('/emoji-mart.css') | ||
let [data, createEmojiMartPickerFromData] = await Promise.all([ | ||
fetchEmojiMartData(), | ||
importEmojiMart() | ||
]) | ||
Picker = createEmojiMartPickerFromData(data) | ||
} | ||
return Picker | ||
} |
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