diff options
author | Ondřej Hruška <ondra@ondrovo.com> | 2017-07-27 00:41:28 +0200 |
---|---|---|
committer | Ondřej Hruška <ondra@ondrovo.com> | 2017-07-27 00:41:28 +0200 |
commit | cb69e35b3b13a67df5216b2c5fd657a62b3bda7a (patch) | |
tree | ee076b48136dfbccfd9b9009eb05551f9d9baa31 /app/javascript/glitch/components/status/visibility_icon.js | |
parent | e82021e0e634c4cf4ba1880c6c47fac16c839d2e (diff) |
Add visibility icon to Detailed status
Diffstat (limited to 'app/javascript/glitch/components/status/visibility_icon.js')
-rw-r--r-- | app/javascript/glitch/components/status/visibility_icon.js | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/app/javascript/glitch/components/status/visibility_icon.js b/app/javascript/glitch/components/status/visibility_icon.js new file mode 100644 index 000000000..017b69cbb --- /dev/null +++ b/app/javascript/glitch/components/status/visibility_icon.js @@ -0,0 +1,48 @@ +// Package imports // +import React from 'react'; +import PropTypes from 'prop-types'; +import { defineMessages, injectIntl } from 'react-intl'; +import ImmutablePureComponent from 'react-immutable-pure-component'; + +const messages = defineMessages({ + public: { id: 'privacy.public.short', defaultMessage: 'Public' }, + unlisted: { id: 'privacy.unlisted.short', defaultMessage: 'Unlisted' }, + private: { id: 'privacy.private.short', defaultMessage: 'Followers-only' }, + direct: { id: 'privacy.direct.short', defaultMessage: 'Direct' }, +}); + +@injectIntl +export default class VisibilityIcon extends ImmutablePureComponent { + + static propTypes = { + visibility: PropTypes.string, + intl: PropTypes.object.isRequired, + withLabel: PropTypes.bool, + }; + + render() { + const { withLabel, visibility, intl } = this.props; + + const visibilityClass = { + public: 'globe', + unlisted: 'unlock-alt', + private: 'lock', + direct: 'envelope', + }[visibility]; + + const label = intl.formatMessage(messages[visibility]); + + const icon = (<i + className={`status__visibility-icon fa fa-fw fa-${visibilityClass}`} + title={label} + aria-hidden='true' + />); + + if (withLabel) { + return (<span style={{ whiteSpace: 'nowrap' }}>{icon} {label}</span>); + } else { + return icon; + } + } + +} |