Comments (4)
Hi @EtienneLem - how would one go about adding that custom prop? Is this a hack or sth already available?
Cheers,
F
from emoji-mart.
I'm also curious about how to do this.
from emoji-mart.
I’m thinking about making a pull request and would like to discuss how we should implement this beforehand. Here’s what I have thought of:
import { Picker } from 'emoji-mart'
const customEmojis = [
{
id: 'octocat',
name: 'Octocat',
colons: ':octocat:',
keywords: ['github'],
emoticons: [],
imageUrl: 'https://assets-cdn.github.com/images/icons/emoji/octocat.png?v7'
}
]
<Picker custom={customEmojis} />
The name
, colons
, keywords
, and emoticons
properties would be used for searching.
The above would render something like this:
The emoji
object one would receive onClick
would look like this:
{
id: 'octocat',
name: 'Octocat',
colons: ':octocat',
emoticons: [],
custom: true,
imageUrl: 'https://assets-cdn.github.com/images/icons/emoji/octocat.png?v7'
}
The custom
property would make it easy to distinguish between official unicode emoji and custom emoji images.
Additionally, I would add the custom category to the I18N
object so users can provide a different category name.
@EtienneLem It would be great if you could take a look at this and let me know what you think.
from emoji-mart.
I love it! That’s how simple I imagined it. Perhaps the custom
props could be an object that looks like { name: 'Custom', emojis: [], anchorUrl: '' }
so that the anchor can also be customized. I like the idea of customizing the name through I18N
, so either works for me.
For the search, it’s simply a substr
search on a concatenated string of name
, short_names
, keywords
and emoticons
(in that order). It’s okay to pass an extra param to EmojiIndex#search
with the custom emojis because the lib does claim to be searchable even without being mounted 😄 Happy to chip in the PR at some point if you need help
Also, both colons
and id
are short_names[0]
where short_names
is an array of known… well short names I guess. Most of them only have 1, but some have more, i.e.
That emoji looks like:
{
name: 'Smiling Face with Open Mouth and Tightly-Closed Eyes',
short_names: ['laughing', 'satisfied'],
emoticons: [':>', ':->'],
}
and that’s all EmojiMart needs and will return a sanitized emoji object on click. However, it may get complicated in that area (getSanitizedData
and friends). So yeah, just pointing it out. It may be less complicated to have the custom emojis data a little bit different from the original ones. The Preview
component do expect short_names
though.
I feel like saying more would confuse you more than help you 😅
I’ll let you have have a first go at it. Don’t hesitate to ping me ✌️
from emoji-mart.
Related Issues (20)
- Adding HTML node in insertContent
- Serious Memory Leak when show/disappear <Picker> Component
- There are style issues in lower versions of Google Chrome(version69)
- When you slide the scroll bar very fast, the icon below cannot be rendered. HOT 6
- Emoji Mart Picker categories not responding to click events
- Browser.js styling
- "native" only printing correctly on Mac (not Windows or Linux) HOT 1
- Whole screen flickers on initial usage (from React) HOT 1
- Adding support to Swedish language
- React component throws React.forwardRef error HOT 1
- How can I add other utf8 characters as custom emojis?
- How to detect loading of Picker?
- Rerendered emoji fails to be inserted
- Question: Using twitter SVG
- Supporting multi skin tone handshakes
- What font is used? HOT 1
- Emoji Rendering issue
- Set twitter is not working in any lib version HOT 1
- Svelte Integration
- How does onEmojiSelect work with the custom emojis?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from emoji-mart.