]> cat aescling's git repositories - mastodon.git/commitdiff
Add bot icon to bot avatars and migrate to newer version of Font Awesome (#8484)
authorMaciek Baron <thebezet@gmail.com>
Tue, 25 Sep 2018 03:08:55 +0000 (04:08 +0100)
committerEugen Rochko <eugen@zeonfederated.com>
Tue, 25 Sep 2018 03:08:55 +0000 (05:08 +0200)
* Migrate to newer version of Font Awesome

* Add bot icon to bot avatars

app/javascript/mastodon/common.js
app/javascript/mastodon/components/__tests__/__snapshots__/avatar-test.js.snap
app/javascript/mastodon/components/__tests__/avatar-test.js
app/javascript/mastodon/components/avatar.js
app/javascript/mastodon/components/bot_icon.js [new file with mode: 0644]
app/javascript/mastodon/features/account/components/header.js
app/javascript/styles/mastodon/components.scss
package.json
yarn.lock

index 2b10b8c30ae20995395769b3a05ac893876dc4dc..fdd3431ab0cefa2ae457b7050fbeacfa9a172910 100644 (file)
@@ -1,7 +1,8 @@
 import Rails from 'rails-ujs';
 
 export function start() {
-  require('font-awesome/css/font-awesome.css');
+  require('@fortawesome/fontawesome-free/css/fontawesome.css');
+  require('@fortawesome/fontawesome-free/css/solid.css');
   require.context('../images/', true);
 
   Rails.start();
index 76ab3374ae84886653ec6719a405c8fb0c2357fa..f6f6bfbf46970868e1bc9aa69a9b2cbb5d9cbbab 100644 (file)
@@ -13,7 +13,11 @@ exports[`<Avatar /> Autoplay renders a animated avatar 1`] = `
       "width": "100px",
     }
   }
-/>
+>
+  <i
+    className="fa fa-fw fa-robot bot-icon"
+  />
+</div>
 `;
 
 exports[`<Avatar /> Still renders a still avatar 1`] = `
@@ -29,5 +33,9 @@ exports[`<Avatar /> Still renders a still avatar 1`] = `
       "width": "100px",
     }
   }
-/>
+>
+  <i
+    className="fa fa-fw fa-robot bot-icon"
+  />
+</div>
 `;
index dd3f7b7d2104f06a54c825bf4e495360f7f70b5e..cc99d3a5352f1508a2cd390708e7e5eac28f3cc2 100644 (file)
@@ -10,6 +10,7 @@ describe('<Avatar />', () => {
     display_name: 'Alice',
     avatar: '/animated/alice.gif',
     avatar_static: '/static/alice.jpg',
+    bot: true,
   });
 
   const size     = 100;
index 570505833fc09a11c034bc805529190d587b4e18..e46f1ed760e32a0f06d474a3e42c566b5faa7239 100644 (file)
@@ -1,6 +1,7 @@
 import React from 'react';
 import PropTypes from 'prop-types';
 import ImmutablePropTypes from 'react-immutable-proptypes';
+import BotIcon from './bot_icon';
 import { autoPlayGif } from '../initial_state';
 
 export default class Avatar extends React.PureComponent {
@@ -65,7 +66,9 @@ export default class Avatar extends React.PureComponent {
         onMouseEnter={this.handleMouseEnter}
         onMouseLeave={this.handleMouseLeave}
         style={style}
-      />
+      >
+        <BotIcon account={account} />
+      </div>
     );
   }
 
diff --git a/app/javascript/mastodon/components/bot_icon.js b/app/javascript/mastodon/components/bot_icon.js
new file mode 100644 (file)
index 0000000..f4bd702
--- /dev/null
@@ -0,0 +1,23 @@
+import React from 'react';
+import ImmutablePropTypes from 'react-immutable-proptypes';
+import ImmutablePureComponent from 'react-immutable-pure-component';
+
+export default class BotIcon extends ImmutablePureComponent {
+
+  static propTypes = {
+    account: ImmutablePropTypes.map.isRequired,
+  };
+
+  render () {
+    const { account } = this.props;
+
+    if (account.get('bot')) {
+      return (
+        <i className='fa fa-fw fa-robot bot-icon' />
+      );
+    }
+
+    return '';
+  }
+
+}
index 11ae589053ffdfb32c811e5563df5de16ef9e238..e498ba5ccc420959f764f0584d646b2031751011 100644 (file)
@@ -3,6 +3,7 @@ import ImmutablePropTypes from 'react-immutable-proptypes';
 import PropTypes from 'prop-types';
 import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
 import IconButton from '../../../components/icon_button';
+import BotIcon from '../../../components/bot_icon';
 import Motion from '../../ui/util/optional_motion';
 import spring from 'react-motion/lib/spring';
 import ImmutablePureComponent from 'react-immutable-pure-component';
@@ -67,6 +68,7 @@ class Avatar extends ImmutablePureComponent {
             onBlur={this.handleMouseOut}
           >
             <span style={{ display: 'none' }}>{account.get('acct')}</span>
+            <BotIcon account={account} />
           </a>
         )}
       </Motion>
index 3fb924aa42bb0de2d56cc2faa9c25a03f1250f5a..b3f3347dfda7ea289e50d92cde0a5ab2c92a46fd 100644 (file)
     vertical-align: middle;
     margin-right: 5px;
   }
+
+  .bot-icon {
+    position: absolute;
+    bottom: -.333em;
+    left: -.333em;
+  }
 }
 
 a .account__avatar {
@@ -1327,10 +1333,22 @@ a .account__avatar {
 .account__header__avatar {
   background-size: 90px 90px;
   display: block;
+  font-size: 1.5em;
   height: 90px;
   margin: 0 auto 10px;
-  overflow: hidden;
+  position: relative;
   width: 90px;
+
+  .bot-icon {
+    color: $dark-text-color;
+    position: absolute;
+    bottom: 0;
+    left: 0;
+
+    .light & {
+      color: $inverted-text-color;
+    }
+  }
 }
 
 .account-authorize {
index 8320a76fb8cb4d7e86261757b59c01e7e52466fd..155bb7e0b0a9ab2c6c06cb476bd02cc7ea490e4e 100644 (file)
@@ -37,6 +37,7 @@
     "@babel/preset-env": "^7.0.0",
     "@babel/preset-react": "^7.0.0",
     "@babel/runtime": "^7.0.0",
+    "@fortawesome/fontawesome-free": "^5.2.0",
     "array-includes": "^3.0.3",
     "autoprefixer": "^8.6.5",
     "axios": "~0.16.2",
@@ -58,7 +59,6 @@
     "exif-js": "^2.3.0",
     "express": "^4.16.2",
     "file-loader": "^2.0.0",
-    "font-awesome": "^4.7.0",
     "glob": "^7.1.1",
     "history": "^4.7.2",
     "http-link-header": "^0.8.0",
index d2063ddeaf073345885ecc84d91a9d6fdb29fe18..adac9aa0602b6a713fa26258b5b113b961c019dc 100644 (file)
--- a/yarn.lock
+++ b/yarn.lock
   version "1.0.0"
   resolved "https://registry.yarnpkg.com/@csstools/sass-import-resolve/-/sass-import-resolve-1.0.0.tgz#32c3cdb2f7af3cd8f0dca357b592e7271f3831b5"
 
+"@fortawesome/fontawesome-free@^5.2.0":
+  version "5.2.0"
+  resolved "https://registry.yarnpkg.com/@fortawesome/fontawesome-free/-/fontawesome-free-5.2.0.tgz#50cd9856774351c56c0b1b0db4efe122d7913e58"
+
 "@types/node@*":
   version "10.9.4"
   resolved "https://registry.yarnpkg.com/@types/node/-/node-10.9.4.tgz#0f4cb2dc7c1de6096055357f70179043c33e9897"
@@ -3279,10 +3283,6 @@ follow-redirects@^1.0.0, follow-redirects@^1.2.3:
   dependencies:
     debug "=3.1.0"
 
-font-awesome@^4.7.0:
-  version "4.7.0"
-  resolved "https://registry.yarnpkg.com/font-awesome/-/font-awesome-4.7.0.tgz#8fa8cf0411a1a31afd07b06d2902bb9fc815a133"
-
 for-in@^0.1.3:
   version "0.1.8"
   resolved "https://registry.yarnpkg.com/for-in/-/for-in-0.1.8.tgz#d8773908e31256109952b1fdb9b3fa867d2775e1"