From db06b25376ac7e844e86fb9890fa9f1c2edd2d60 Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Sat, 16 Mar 2019 12:13:15 -0700 Subject: fix: update to emoji-mart 2.10.0 (#10281) * fix: update to emoji-mart 2.10.0 * remove useless change * fix CSS style of emoji picker, improve a11y * fix missing newline in scss * fix the title and input fonts --- .../compose/components/emoji_picker_dropdown.js | 51 +++++++++++++++++----- .../mastodon/features/emoji/emoji_picker.js | 4 +- app/javascript/styles/mastodon/components.scss | 4 +- app/javascript/styles/mastodon/emoji_picker.scss | 25 +++++++++-- config/webpack/rules/node_modules.js | 11 ++++- package.json | 2 +- yarn.lock | 9 ++-- 7 files changed, 82 insertions(+), 24 deletions(-) diff --git a/app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.js b/app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.js index c1429c756..038d93483 100644 --- a/app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.js +++ b/app/javascript/mastodon/features/compose/components/emoji_picker_dropdown.js @@ -50,6 +50,7 @@ class ModifierPickerMenu extends React.PureComponent { active: PropTypes.bool, onSelect: PropTypes.func.isRequired, onClose: PropTypes.func.isRequired, + modifier: PropTypes.number, }; handleClick = e => { @@ -86,20 +87,36 @@ class ModifierPickerMenu extends React.PureComponent { setRef = c => { this.node = c; + if (this.node) { + this.node.querySelector('li:first-child button').focus(); // focus the first element when opened + } } render () { - const { active } = this.props; + const { active, modifier } = this.props; return ( -
- - - - - - -
+ ); } @@ -131,10 +148,22 @@ class ModifierPicker extends React.PureComponent { render () { const { active, modifier } = this.props; + function setRef(ref) { + if (!ref) { + return; + } + // TODO: It would be nice if we could pass props directly to emoji-mart's buttons. + const button = ref.querySelector('button'); + button.setAttribute('aria-haspopup', 'true'); + button.setAttribute('aria-expanded', active); + } + return (
- - +
+ +
+
); } diff --git a/app/javascript/mastodon/features/emoji/emoji_picker.js b/app/javascript/mastodon/features/emoji/emoji_picker.js index 044d38cb2..73fcaa8c8 100644 --- a/app/javascript/mastodon/features/emoji/emoji_picker.js +++ b/app/javascript/mastodon/features/emoji/emoji_picker.js @@ -1,5 +1,5 @@ -import Picker from 'emoji-mart/dist-es/components/picker/picker'; -import Emoji from 'emoji-mart/dist-es/components/emoji/emoji'; +import Picker from 'emoji-mart/dist-modern/components/picker/picker'; +import Emoji from 'emoji-mart/dist-modern/components/emoji/emoji'; export { Picker, diff --git a/app/javascript/styles/mastodon/components.scss b/app/javascript/styles/mastodon/components.scss index 8da4e2f4a..caa45ee01 100644 --- a/app/javascript/styles/mastodon/components.scss +++ b/app/javascript/styles/mastodon/components.scss @@ -3339,11 +3339,11 @@ a.status-card.compact:hover { box-shadow: 1px 2px 6px rgba($base-shadow-color, 0.2); overflow: hidden; - button { + li { display: block; cursor: pointer; border: 0; - padding: 4px 8px; + padding: 3px 8px; background: transparent; &:hover, diff --git a/app/javascript/styles/mastodon/emoji_picker.scss b/app/javascript/styles/mastodon/emoji_picker.scss index e49084b5f..d53f41a0b 100644 --- a/app/javascript/styles/mastodon/emoji_picker.scss +++ b/app/javascript/styles/mastodon/emoji_picker.scss @@ -1,3 +1,5 @@ +@import '../../../node_modules/emoji-mart/css/emoji-mart.css'; + .emoji-mart { &, * { @@ -51,6 +53,14 @@ &:hover { color: darken($lighter-text-color, 4%); + + svg { + fill: darken($lighter-text-color, 4%); + } + } + + svg { + fill: $lighter-text-color; } } @@ -59,11 +69,19 @@ &:hover { color: darken($highlight-text-color, 4%); + + svg { + fill: darken($highlight-text-color, 4%); + } } .emoji-mart-anchor-bar { bottom: -1px; } + + svg { + fill: $highlight-text-color; + } } .emoji-mart-anchor-bar { @@ -83,7 +101,6 @@ } svg { - fill: currentColor; max-height: 18px; } } @@ -103,15 +120,14 @@ } .emoji-mart-search { - padding: 10px; - padding-right: 45px; + margin: 10px 40px 10px 5px; background: $simple-background-color; input { font-size: 14px; font-weight: 400; padding: 7px 9px; - font-family: inherit; + font-family: $font-sans-serif; display: block; width: 100%; background: rgba($ui-secondary-color, 0.3); @@ -166,6 +182,7 @@ font-weight: 500; padding: 5px 6px; background: $simple-background-color; + font-family: $font-sans-serif; } } diff --git a/config/webpack/rules/node_modules.js b/config/webpack/rules/node_modules.js index 7ed05504b..5debc1b5d 100644 --- a/config/webpack/rules/node_modules.js +++ b/config/webpack/rules/node_modules.js @@ -11,7 +11,16 @@ module.exports = { options: { babelrc: false, plugins: [ - 'transform-react-remove-prop-types', + [ + 'transform-react-remove-prop-types', + { + mode: 'remove', + removeImport: true, + additionalLibraries: [ + '../../utils/shared-props', // emoji-mart + ], + }, + ], ], cacheDirectory: join(settings.cache_path, 'babel-loader-node-modules'), cacheCompression: env.NODE_ENV === 'production', diff --git a/package.json b/package.json index 63cfa25b8..b9d8f8af1 100644 --- a/package.json +++ b/package.json @@ -85,7 +85,7 @@ "cssnano": "^4.1.10", "detect-passive-events": "^1.0.2", "dotenv": "^6.2.0", - "emoji-mart": "Gargron/emoji-mart#build", + "emoji-mart": "^2.10.0", "es6-symbol": "^3.1.1", "escape-html": "^1.0.3", "exif-js": "^2.3.0", diff --git a/yarn.lock b/yarn.lock index 9d7f0eccb..9b0ec51db 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3173,9 +3173,12 @@ elliptic@^6.0.0: minimalistic-assert "^1.0.0" minimalistic-crypto-utils "^1.0.0" -emoji-mart@Gargron/emoji-mart#build: - version "2.6.2" - resolved "https://codeload.github.com/Gargron/emoji-mart/tar.gz/ff00dc470b5b2d9f145a6d6e977a54de5df2b4c9" +emoji-mart@^2.10.0: + version "2.10.0" + resolved "https://registry.yarnpkg.com/emoji-mart/-/emoji-mart-2.10.0.tgz#e1adec430f4963f79055b12b80e6d60c5abb742d" + integrity sha512-VhcX463f8TDaQc1Tpc8rI31E15+8KXOYff1vwjokjMT52bZlCQCyq3zrnNScSYjv95f1+R4DMMreeuPvYFvOhg== + dependencies: + prop-types "^15.6.0" emoji-regex@^6.5.1: version "6.5.1" -- cgit