-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
154 lines (139 loc) · 5.62 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0,viewport-fit=cover" name="viewport" />
<title>POPO Emoji Picker</title>
<link rel="icon" href="favicon.ico" />
<link rel="stylesheet" href="css/emoji-picker.css" />
<link rel="stylesheet" href="css/emoji-demo.css" />
<script async defer src="https://buttons.github.io/buttons.js"></script>
</head>
<body>
<div class="demo-container">
<h1 style="margin-bottom: 40px">popo Emoji Picker</h1>
<div class="demo-flex-wrapper" style="margin-bottom: 20px">
<div style="margin-right: 10px"><b style="color: var(--p-color-text-secondary)">Type: </b></div>
<div class="demo-button-group js-type-selector">
<button type="button" class="demo-button active">native</button>
<button type="button" class="demo-button">apple</button>
<button type="button" class="demo-button">google</button>
<button type="button" class="demo-button">twitter</button>
<button type="button" class="demo-button">facebook</button>
</div>
</div>
<div class="demo-flex-wrapper" style="margin-bottom: 30px">
<div style="margin-right: 10px"><b style="color: var(--p-color-text-secondary)">Language: </b></div>
<div class="demo-button-group js-language-selector">
<button type="button" class="demo-button active">english</button>
<button type="button" class="demo-button">chinese-simplified</button>
</div>
</div>
<div class="demo-flex-wrapper" style="margin-bottom: 30px">
<div style="margin-right: 10px"><b style="color: var(--p-color-text-secondary)">Theme: </b></div>
<div class="demo-button-group js-theme-selector">
<button type="button" class="demo-button active">auto</button>
<button type="button" class="demo-button">light</button>
<button type="button" class="demo-button">dark</button>
</div>
</div>
<div style="margin-bottom: 20px">
<a class="github-button" href="https://github.com/po-po/popo-Emoji-Picker" data-size="large" data-show-count="true" aria-label="Star po-po/popo-Emoji-Picker on GitHub">Star</a>
</div>
<div class="demo-flex-wrapper js-theme-wrapper" style="align-items: start">
<div class="demo-flex-1">
<div style="margin-bottom: 15px"><b style="color: var(--p-color-text-secondary)">Emoji Picker </b></div>
<div class="demo-input-wrapper">
<div class="demo-input"></div>
<div class="demo-input-footer">
<div class="demo-switch-button"></div>
<div class="demo-word-limit"></div>
</div>
</div>
</div>
<div class="demo-flex-1">
<div style="margin-bottom: 15px"><b style="color: var(--p-color-text-secondary)">Emoji Transform</b></div>
<div class="js-transform-box"></div>
</div>
</div>
</div>
<script type="module">
import { EmojiPicker, emojiTransform } from './js/emoji.js';
window.picker = new EmojiPicker({
inputElement: document.querySelector('.demo-input'),
toggleButtonElement: document.querySelector('.demo-switch-button'),
theme: 'auto', // auto | dark | light
placeholder: 'Please Enter Content',
showWordLimit: true,
maxLength: 100,
isNative: true,
language: 'en',
created: (picker) => {
picker.setValue('Hello world! 💜💛❤️😄🙂😍');
picker.togglePicker();
},
inputChange: ({ result, length, maxLength }) => {
transform(result);
if (maxLength) {
document.querySelector('.demo-word-limit').textContent = `${length}/${maxLength}`;
}
},
});
function transform(result) {
const transformBox = document.querySelector('.js-transform-box');
const list = ['native', 'image', 'unicode'];
let htmlStr = '';
list.forEach((type) => {
htmlStr += `
<div class="demo-input-wrapper" style="margin-bottom: 20px">
<div>
<b style="color: var(--p-color-text-secondary)">${type} : </b>
<span style="color: var(--p-color-text-default)">${emojiTransform(result, type) || '--'}</span>
</div>
</div>`;
});
transformBox.innerHTML = htmlStr;
}
// change theme
document.querySelectorAll('.js-theme-selector button').forEach((btn) => {
btn.addEventListener('click', () => {
document.querySelector('.js-theme-selector button.active').classList.remove('active');
const theme = btn.textContent;
picker.setTheme(theme);
document.querySelector('.js-theme-wrapper').className = `demo-flex-wrapper js-theme-wrapper p-theme-${theme}`;
btn.classList.add('active');
});
});
// change language
document.querySelectorAll('.js-language-selector button').forEach((btn) => {
btn.addEventListener('click', () => {
document.querySelector('.js-language-selector button.active').classList.remove('active');
const language = btn.textContent;
picker.setLanguage(language === 'english' ? 'en' : 'zh-CN');
btn.classList.add('active');
});
});
// change type
document.querySelectorAll('.js-type-selector button').forEach((btn) => {
btn.addEventListener('click', () => {
document.querySelector('.js-type-selector button.active').classList.remove('active');
const imageType = btn.textContent;
if (imageType === 'native') {
picker.setNative(true);
} else {
const cdnRoot = `https://cdn.jsdelivr.net/npm/emoji-datasource-${imageType}@15.1.2`;
const cssVars = {
'--emoji-background-image': `url(${cdnRoot}/img/${imageType}/sheets-128/64.png)`,
};
for (let [key, value] of Object.entries(cssVars)) {
document.documentElement.style.setProperty(key, value.toString());
}
picker.setNative(false);
}
btn.classList.add('active');
});
});
</script>
</body>
</html>