|
| 1 | +import React from "react"; |
| 2 | +import styles from './FeedPage.module.css'; |
| 3 | +import CurrentUserInfo from "./CurrentUserInfo"; |
| 4 | +import MostAppreciatedUsers from "./MostAppreciatedUsers"; |
| 5 | + |
| 6 | +function Appreciations() { |
| 7 | + |
| 8 | + return <article id="appreciation-{{ appreciation.id }}" className="appreciation media"> |
| 9 | + <figure className="media-left is-flex"> |
| 10 | + <div className="participants-avatar image is-48x48"> |
| 11 | + <img alt="Profile picture of {{ appreciation.creator.name }}" |
| 12 | + title="{{ appreciation.creator.name }}" |
| 13 | + className="is-rounded" src="{{ appreciation.creator.profile_pic }}"/> |
| 14 | + </div> |
| 15 | + <div className="participants-avatar image is-48x48"> |
| 16 | + {/*{% set mentions = appreciation.get_mentions() %}*/} |
| 17 | + {/*{% if mentions %}*/} |
| 18 | + <img alt="Profile picture of {{ mentions[0].user.name }}" |
| 19 | + title="{{ mentions[0].user.name }}" |
| 20 | + className="is-rounded" src="{{ mentions[0].user.profile_pic }}"/> |
| 21 | + {/*{% endif %}*/} |
| 22 | + </div> |
| 23 | + </figure> |
| 24 | + <div className="media-content"> |
| 25 | + <div className="content"> |
| 26 | + <div> |
| 27 | + <a href="/profile/{{appreciation.creator.username}}"> |
| 28 | + <strong> |
| 29 | + {/*{appreciation.creator.name}*/} |
| 30 | + </strong> |
| 31 | + </a> |
| 32 | + <small> |
| 33 | + <time dateTime="{{ appreciation.created_at | iso_time }}"> |
| 34 | + {/*{appreciation.created_at | humanize_time}*/} |
| 35 | + </time> |
| 36 | + </small> |
| 37 | + </div> |
| 38 | + <div className="mt-2"> |
| 39 | + {/*{appreciation.content | add_mentions}*/} |
| 40 | + </div> |
| 41 | + </div> |
| 42 | + <nav className="level is-mobile"> |
| 43 | + <div className="level-left"> |
| 44 | + <div className="level-item"> |
| 45 | + {/*{% if appreciation.is_liked_by(user) %}*/} |
| 46 | + <form method="post" |
| 47 | + action="{{ url_for('appreciation.dislike') }}"> |
| 48 | + {/*{{like_form.csrf_token}}*/} |
| 49 | + <input type="hidden" name="appreciation" value="{{ appreciation.id }}"/> |
| 50 | + <button title="Like" type="submit" |
| 51 | + className="post-action-button clear-button has-text-danger level-item is-clickable"> |
| 52 | + <span className="icon is-medium"> |
| 53 | + <ion-icon name="heart"/> |
| 54 | + </span> |
| 55 | + </button> |
| 56 | + </form> |
| 57 | + {/*{% else %}*/} |
| 58 | + <form method="post" |
| 59 | + action="{{ url_for('appreciation.like') }}"> |
| 60 | + {/*{{like_form.csrf_token}}*/} |
| 61 | + <input type="hidden" name="appreciation" value="{{ appreciation.id }}"/> |
| 62 | + <button title="Like" type="submit" |
| 63 | + className="post-action-button clear-button has-text-danger level-item is-clickable"> |
| 64 | + <span className="icon is-medium"> |
| 65 | + <ion-icon name="heart-outline"/> |
| 66 | + </span> |
| 67 | + </button> |
| 68 | + </form> |
| 69 | + {/*{% endif %}*/} |
| 70 | + <button type="button" className="clear-button has-text-danger level-item is-clickable" |
| 71 | + data-toggle-modal="#likes-{{ appreciation.id }}"> |
| 72 | + <span> |
| 73 | + {/*{{like_count}} {{choose_plural(like_count, 'like', 'likes')}}*/} |
| 74 | + </span> |
| 75 | + </button> |
| 76 | + </div> |
| 77 | + <button title="Comment" |
| 78 | + className="post-action-button comment-button clear-button has-text-info level-item is-clickable" |
| 79 | + data-toggle="#comments-{{ appreciation.id }}"> |
| 80 | + <span className="icon is-medium"> |
| 81 | + <ion-icon name="chatbubble-outline"></ion-icon> |
| 82 | + </span> |
| 83 | + <span> |
| 84 | + {/*{{appreciation.comment_count}}*/} |
| 85 | + </span> |
| 86 | + </button> |
| 87 | + <div className="modal" id="likes-{{ appreciation.id }}"> |
| 88 | + <div className="modal-background"/> |
| 89 | + <div className="modal-content"> |
| 90 | + <div className="box"> |
| 91 | + <h2 className="is-size-4">Likes</h2> |
| 92 | + <div className="menu mt-4"> |
| 93 | + <ul className="menu-list"> |
| 94 | + {/*{% for like in appreciation.likes %}*/} |
| 95 | + <li className="is-flex pb-2"> |
| 96 | + <figure className="media-left is-flex"> |
| 97 | + <div className="participants-avatar image is-48x48"> |
| 98 | + <img alt="Profile picture of {{ like.user.name }}" |
| 99 | + title="{{ like.user.name }}" |
| 100 | + className="is-rounded" |
| 101 | + src="{{ like.user.profile_pic }}"/> |
| 102 | + </div> |
| 103 | + </figure> |
| 104 | + <div className="content"> |
| 105 | + <h3 className="is-size-5 has-font-weight-bold mb-0"> |
| 106 | + {/*{{like.user.name}}*/} |
| 107 | + </h3> |
| 108 | + <p className="help"> |
| 109 | + {/*{like.user.designation}}*/} |
| 110 | + </p> |
| 111 | + </div> |
| 112 | + </li> |
| 113 | + {/*{% else %}*/} |
| 114 | + <li className="is-flex pb-2"> |
| 115 | + <div className="content"> |
| 116 | + <h3 className="is-size-5 mb-0 text-center"> |
| 117 | + No likes yet |
| 118 | + </h3> |
| 119 | + </div> |
| 120 | + </li> |
| 121 | + {/*{% endfor %}*/} |
| 122 | + </ul> |
| 123 | + </div> |
| 124 | + </div> |
| 125 | + </div> |
| 126 | + <button type="reset" className="modal-close is-large" data-action="close"/> |
| 127 | + </div> |
| 128 | + </div> |
| 129 | + </nav> |
| 130 | + <div className="block hide is-clipped" id="comments-{{appreciation.id}}"> |
| 131 | + <form method="post" action="{{ url_for('appreciation.comment') }}"> |
| 132 | + {/*{{comment_form.csrf_token}}*/} |
| 133 | + <input type="hidden" name="appreciation" value="{{appreciation.id}}"/> |
| 134 | + <div className="field is-grouped"> |
| 135 | + <label className="is-sr-only" htmlFor="comment-content-{{ appreciation.id }}">Write a |
| 136 | + comment</label> |
| 137 | + <div className="control is-expanded"> |
| 138 | + <textarea id="comment-content-{{ appreciation.id }}" data-has-mentions name="content" rows={2} |
| 139 | + className="textarea"/> |
| 140 | + </div> |
| 141 | + <div className="control"> |
| 142 | + <button className="button is-primary" type="submit">Comment</button> |
| 143 | + </div> |
| 144 | + </div> |
| 145 | + </form> |
| 146 | + {/*{% for comment in appreciation.get_comments() %}*/} |
| 147 | + <div className="comment"> |
| 148 | + <div> |
| 149 | + <strong><a> |
| 150 | + {/*{{comment.user.name}}*/} |
| 151 | + </a></strong> |
| 152 | + <small> |
| 153 | + <time dateTime="{{ appreciation.created_at | iso_time }}"> |
| 154 | + {/*{{comment.created_at | humanize_time}}*/} |
| 155 | + </time> |
| 156 | + </small> |
| 157 | + </div> |
| 158 | + <p> |
| 159 | + {/*{{comment.content | add_mentions}}*/} |
| 160 | + </p> |
| 161 | + </div> |
| 162 | + {/*{% endfor %}*/} |
| 163 | + </div> |
| 164 | + </div> |
| 165 | + </article>; |
| 166 | +} |
| 167 | + |
| 168 | +export default function FeedPage() { |
| 169 | + return ( |
| 170 | + <div className="container"> |
| 171 | + <div className="columns"> |
| 172 | + <div className="column is-two-thirds"> |
| 173 | + <div className="box"> |
| 174 | + <form className="note-form block" method="post" action="{{ url_for('appreciation.appreciate') }}"> |
| 175 | + <div className="field"> |
| 176 | + <label htmlFor="note-field" className="is-sr-only">Write a note a @mention to send a note</label> |
| 177 | + <div className="control"> |
| 178 | + <textarea id="note-field" rows={2} className="textarea" data-has-mentions="" |
| 179 | + name="{{form.content.name}}" |
| 180 | + placeholder="Write a message that includes @mention"/> |
| 181 | + </div> |
| 182 | + </div> |
| 183 | + <div className="field mt-2 send-container is-clipped"> |
| 184 | + <div className="control"> |
| 185 | + <button className="button is-primary is-rounded is-medium"> |
| 186 | + <span className="icon"> |
| 187 | + <ion-icon name="paper-plane-outline" size="large"/> |
| 188 | + </span> |
| 189 | + <span> |
| 190 | + Hi five! |
| 191 | + </span> |
| 192 | + </button> |
| 193 | + </div> |
| 194 | + </div> |
| 195 | + </form> |
| 196 | + <hr/> |
| 197 | + {/*{% for appreciation in appreciations %}*/} |
| 198 | + <Appreciations/> |
| 199 | + {/*{% endfor %}*/} |
| 200 | + </div> |
| 201 | + </div> |
| 202 | + <div className="column is-one-third"> |
| 203 | + <div className={styles.rightSidebar}> |
| 204 | + <CurrentUserInfo/> |
| 205 | + <MostAppreciatedUsers/> |
| 206 | + </div> |
| 207 | + </div> |
| 208 | + </div> |
| 209 | + </div> |
| 210 | + ); |
| 211 | +} |
0 commit comments