Last active
June 27, 2019 16:07
-
-
Save ashour/9a8b208c37f4a6b43f7fd5be9f1165d5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Supported locales | |
| */ | |
| type Locale = "en" | "ar"; | |
| /** | |
| * Determines localized UI elements and data shown | |
| */ | |
| let currentLocale: Locale = "en"; | |
| /** | |
| * Retrieve HTML for a single post, humanizing the post's date | |
| */ | |
| function renderPost(post: Post): string { | |
| const avatarMargin = currentLocale === "en" ? "mr-3" : "ml-3"; | |
| return ( | |
| `<li class="list-group-item"> | |
| <div class="d-flex"> | |
| <div | |
| class="${avatarMargin} rounded-circle" | |
| style="width: 4rem; height: 4rem; overflow: hidden;" | |
| > | |
| <img src="${post.photo}" | |
| style="object-fit: cover; object-position: center; min-height: 100%; width: 100%;" | |
| /> | |
| </div> | |
| <div style="flex: 1;"> | |
| <h4 class="h6 d-flex justify-content-between align-items-baseline"> | |
| <span>${post.name} ${__("posted")}</span> | |
| <span class="small">${humanFriendlyDate(post.posted_at)}</span> | |
| </h4> | |
| <p style="text-align: ${currentLocale === "en" ? "left" : "right"}"> | |
| ${post.post} | |
| </p> | |
| </div> | |
| </div> | |
| </li>` | |
| ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment