闭社主体 forked from https://github.com/tootsuite/mastodon
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
910 B

  1. import React from 'react';
  2. import ImmutablePropTypes from 'react-immutable-proptypes';
  3. import ImmutablePureComponent from 'react-immutable-pure-component';
  4. const filename = url => url.split('/').pop().split('#')[0].split('?')[0];
  5. export default class AttachmentList extends ImmutablePureComponent {
  6. static propTypes = {
  7. media: ImmutablePropTypes.list.isRequired,
  8. };
  9. render () {
  10. const { media } = this.props;
  11. return (
  12. <div className='attachment-list'>
  13. <div className='attachment-list__icon'>
  14. <i className='fa fa-link' />
  15. </div>
  16. <ul className='attachment-list__list'>
  17. {media.map(attachment =>
  18. <li key={attachment.get('id')}>
  19. <a href={attachment.get('remote_url')} target='_blank' rel='noopener'>{filename(attachment.get('remote_url'))}</a>
  20. </li>
  21. )}
  22. </ul>
  23. </div>
  24. );
  25. }
  26. }