mirror of
https://github.com/discourse/discourse.git
synced 2024-12-18 12:08:32 +08:00
Merge pull request #4945 from jjaffeux/emoji-picker
Adds support for skin tones in emoji picker
This commit is contained in:
commit
bd7fbe6ad9
|
@ -1,6 +1,6 @@
|
||||||
import groups from 'discourse/lib/emoji/groups';
|
import groups from 'discourse/lib/emoji/groups';
|
||||||
import KeyValueStore from "discourse/lib/key-value-store";
|
import KeyValueStore from "discourse/lib/key-value-store";
|
||||||
import { emojiList } from 'pretty-text/emoji';
|
import { emojiList, isSkinTonableEmoji } from 'pretty-text/emoji';
|
||||||
import { emojiUrlFor } from 'discourse/lib/text';
|
import { emojiUrlFor } from 'discourse/lib/text';
|
||||||
import { findRawTemplate } from 'discourse/lib/raw-templates';
|
import { findRawTemplate } from 'discourse/lib/raw-templates';
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ let PER_ROW = 12;
|
||||||
const PER_PAGE = 60;
|
const PER_PAGE = 60;
|
||||||
|
|
||||||
let ungroupedIcons, recentlyUsedIcons;
|
let ungroupedIcons, recentlyUsedIcons;
|
||||||
|
let selectedSkinTone = keyValueStore.getObject('selectedSkinTone') || 1;
|
||||||
|
|
||||||
if (!keyValueStore.getObject(EMOJI_USAGE)) {
|
if (!keyValueStore.getObject(EMOJI_USAGE)) {
|
||||||
keyValueStore.setObject({key: EMOJI_USAGE, value: {}});
|
keyValueStore.setObject({key: EMOJI_USAGE, value: {}});
|
||||||
|
@ -121,6 +122,13 @@ function bindEvents(page, offset, options) {
|
||||||
render(p, 0, options);
|
render(p, 0, options);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('.emoji-modal .tones-button').click(function(){
|
||||||
|
selectedSkinTone = parseInt($(this).data('skin-tone'));
|
||||||
|
keyValueStore.setObject({key: 'selectedSkinTone', value: selectedSkinTone});
|
||||||
|
render(page, offset, options);
|
||||||
|
return false;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function render(page, offset, options) {
|
function render(page, offset, options) {
|
||||||
|
@ -139,12 +147,29 @@ function render(page, offset, options) {
|
||||||
rows.push(row);
|
rows.push(row);
|
||||||
row = [];
|
row = [];
|
||||||
}
|
}
|
||||||
row.push({src: emojiUrlFor(icons[i]), title: icons[i]});
|
|
||||||
|
let code = icons[i];
|
||||||
|
if(selectedSkinTone !== 1 && isSkinTonableEmoji(code)) {
|
||||||
|
code = `${code}:t${selectedSkinTone}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
row.push({src: emojiUrlFor(code), title: code});
|
||||||
}
|
}
|
||||||
rows.push(row);
|
rows.push(row);
|
||||||
|
|
||||||
|
const skinTones = [];
|
||||||
|
const skinToneNames = ['default', 'light', 'medium-light', 'medium', 'medium-dark', 'dark'];
|
||||||
|
for(let i=1; i<skinToneNames.length+1; i++){
|
||||||
|
skinTones.push({
|
||||||
|
selected: selectedSkinTone === i,
|
||||||
|
level: i,
|
||||||
|
className: skinToneNames[i-1]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const model = {
|
const model = {
|
||||||
toolbarItems: toolbarItems,
|
toolbarItems: toolbarItems,
|
||||||
|
skinTones: skinTones,
|
||||||
rows: rows,
|
rows: rows,
|
||||||
prevDisabled: offset === 0,
|
prevDisabled: offset === 0,
|
||||||
nextDisabled: (max + 1) > icons.length,
|
nextDisabled: (max + 1) > icons.length,
|
||||||
|
|
|
@ -14,22 +14,32 @@
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class='info'></div>
|
<div class='footer'>
|
||||||
<div class='nav'>
|
<div class='info'></div>
|
||||||
<span class='prev'>
|
<div class='tones'>
|
||||||
{{#if prevDisabled}}
|
{{#each skinTones as |skinTone|}}
|
||||||
{{fa-icon "fast-backward"}}
|
<button class='tones-button {{skinTone.className}}' data-skin-tone="{{skinTone.level}}">
|
||||||
{{else}}
|
{{#if skinTone.selected}}{{fa-icon "check"}}{{/if}}
|
||||||
<a>{{fa-icon "fast-backward"}}</a>
|
</button>
|
||||||
{{/if}}
|
{{/each}}
|
||||||
</span>
|
</div>
|
||||||
<span class='next'>
|
<div class='nav'>
|
||||||
{{#if nextDisabled}}
|
<span class='prev'>
|
||||||
{{fa-icon "fast-forward"}}
|
{{#if prevDisabled}}
|
||||||
{{else}}
|
{{fa-icon "fast-backward"}}
|
||||||
<a>{{fa-icon "fast-forward"}}</a>
|
{{else}}
|
||||||
{{/if}}
|
<a>{{fa-icon "fast-backward"}}</a>
|
||||||
</span>
|
{{/if}}
|
||||||
|
</span>
|
||||||
|
<span class='next'>
|
||||||
|
{{#if nextDisabled}}
|
||||||
|
{{fa-icon "fast-forward"}}
|
||||||
|
{{else}}
|
||||||
|
<a>{{fa-icon "fast-forward"}}</a>
|
||||||
|
{{/if}}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class='clearfix'></div>
|
<div class='clearfix'></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -18,6 +18,8 @@ body img.emoji {
|
||||||
margin-top: -132px;
|
margin-top: -132px;
|
||||||
margin-left: -222px;
|
margin-left: -222px;
|
||||||
background-color: dark-light-choose(#dadada, blend-primary-secondary(5%));
|
background-color: dark-light-choose(#dadada, blend-primary-secondary(5%));
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
|
|
||||||
table.emoji-page td {
|
table.emoji-page td {
|
||||||
|
@ -71,30 +73,12 @@ table.emoji-page td {
|
||||||
background-color: $secondary;
|
background-color: $secondary;
|
||||||
}
|
}
|
||||||
|
|
||||||
.emoji-modal .info {
|
|
||||||
height: 30px;
|
|
||||||
margin-left: 8px;
|
|
||||||
margin-top: 15px;
|
|
||||||
margin-bottom: 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.emoji-modal .info span {
|
|
||||||
margin-left: 5px;
|
|
||||||
font-weight: bold;
|
|
||||||
color: $primary;
|
|
||||||
}
|
|
||||||
|
|
||||||
.emoji-modal .info {
|
|
||||||
float: left;
|
|
||||||
}
|
|
||||||
.emoji-modal .nav {
|
|
||||||
float: right;
|
|
||||||
margin-top: 15px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.emoji-modal .nav span {
|
.emoji-modal .nav span {
|
||||||
color: dark-light-choose(#aaa, #555);
|
color: dark-light-choose(#aaa, #555);
|
||||||
margin-right: 10px;
|
}
|
||||||
|
|
||||||
|
.emoji-modal .nav span.next {
|
||||||
|
margin-left: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.emoji-modal .nav a {
|
.emoji-modal .nav a {
|
||||||
|
@ -108,3 +92,54 @@ table.emoji-page td {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.emoji-modal .footer {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
flex-direction: row;
|
||||||
|
flex-grow: 2;
|
||||||
|
padding: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.emoji-modal .info {
|
||||||
|
flex: 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
.emoji-modal .info span {
|
||||||
|
margin-left: 5px;
|
||||||
|
font-weight: bold;
|
||||||
|
color: $primary;
|
||||||
|
}
|
||||||
|
|
||||||
|
.emoji-modal .nav {
|
||||||
|
margin-left: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.emoji-modal .tones {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
|
||||||
|
.emoji-modal .tones-button {
|
||||||
|
width: 20px;
|
||||||
|
height: 20px;
|
||||||
|
margin-left: 5px;
|
||||||
|
border: 0;
|
||||||
|
border-radius: 3px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
.emoji-modal .tones-button.default { background: #ffcc4d; }
|
||||||
|
.emoji-modal .tones-button.light { background: #f7dece; }
|
||||||
|
.emoji-modal .tones-button.medium-light { background: #f3d2a2; }
|
||||||
|
.emoji-modal .tones-button.medium { background: #d5ab88; }
|
||||||
|
.emoji-modal .tones-button.medium-dark { background: #af7e57; }
|
||||||
|
.emoji-modal .tones-button.dark { background: #7c533e; }
|
||||||
|
|
||||||
|
.emoji-modal .tones-button i.fa {
|
||||||
|
color: #fff;
|
||||||
|
text-shadow: 0.5px 1.5px 0 rgba(0,0,0,0.3);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user