about summary refs log tree commit diff
path: root/app/javascript/flavours/glitch/features/compose/account/index.js
diff options
context:
space:
mode:
authorThibaut Girka <thib@sitedethib.com>2019-04-19 20:14:32 +0200
committerThibG <thib@sitedethib.com>2019-04-22 20:15:47 +0200
commiteed2c9dd44d7f58bbb54554c2271c465b67b827c (patch)
tree63d7fbcccefc73b5af724e1325cbe5c6b8ce31e4 /app/javascript/flavours/glitch/features/compose/account/index.js
parent8933e8cb1d54a6c96e4085e426481143d3e209e0 (diff)
Rename flavours/glitch/features/drawer to flavours/glitch/features/compose
Diffstat (limited to 'app/javascript/flavours/glitch/features/compose/account/index.js')
-rw-r--r--app/javascript/flavours/glitch/features/compose/account/index.js76
1 files changed, 76 insertions, 0 deletions
diff --git a/app/javascript/flavours/glitch/features/compose/account/index.js b/app/javascript/flavours/glitch/features/compose/account/index.js
new file mode 100644
index 000000000..552848641
--- /dev/null
+++ b/app/javascript/flavours/glitch/features/compose/account/index.js
@@ -0,0 +1,76 @@
+//  Package imports.
+import React from 'react';
+import ImmutablePropTypes from 'react-immutable-proptypes';
+import {
+  FormattedMessage,
+  defineMessages,
+} from 'react-intl';
+
+//  Components.
+import Avatar from 'flavours/glitch/components/avatar';
+import Permalink from 'flavours/glitch/components/permalink';
+
+//  Utils.
+import { hiddenComponent } from 'flavours/glitch/util/react_helpers';
+import { profileLink } from 'flavours/glitch/util/backend_links';
+
+//  Messages.
+const messages = defineMessages({
+  edit: {
+    defaultMessage: 'Edit profile',
+    id: 'navigation_bar.edit_profile',
+  },
+});
+
+//  The component.
+export default function DrawerAccount ({ account }) {
+
+  //  We need an account to render.
+  if (!account) {
+    return (
+      <div className='drawer--account'>
+        { profileLink !== undefined && (
+          <a
+            className='edit'
+            href={ profileLink }
+          >
+            <FormattedMessage {...messages.edit} />
+          </a>
+        )}
+      </div>
+    );
+  }
+
+  //  The result.
+  return (
+    <div className='drawer--account'>
+      <Permalink
+        className='avatar'
+        href={account.get('url')}
+        to={`/accounts/${account.get('id')}`}
+      >
+        <span {...hiddenComponent}>{account.get('acct')}</span>
+        <Avatar
+          account={account}
+          size={40}
+        />
+      </Permalink>
+      <Permalink
+        className='acct'
+        href={account.get('url')}
+        to={`/accounts/${account.get('id')}`}
+      >
+        <strong>@{account.get('acct')}</strong>
+      </Permalink>
+      { profileLink !== undefined && (
+        <a
+          className='edit'
+          href={ profileLink }
+        ><FormattedMessage {...messages.edit} /></a>
+      )}
+    </div>
+  );
+}
+
+//  Props.
+DrawerAccount.propTypes = { account: ImmutablePropTypes.map };