From: Daniel Karbach
diff --git a/resources/js/components/rounds/SeedRolledBy.js b/resources/js/components/rounds/SeedRolledBy.js new file mode 100644 index 0000000..cf73401 --- /dev/null +++ b/resources/js/components/rounds/SeedRolledBy.js @@ -0,0 +1,23 @@ +import PropTypes from 'prop-types'; +import React from 'react'; + +import { getAvatarUrl, getUserName } from '../../helpers/User'; +import i18n from '../../i18n'; + +const SeedRolledBy = ({ round }) => round.rolled_by_user ? + + + +: null; + +SeedRolledBy.propTypes = { + round: PropTypes.shape({ + rolled_by_user: PropTypes.shape({ + }), + }), +}; + +export default SeedRolledBy; diff --git a/resources/js/helpers/User.js b/resources/js/helpers/User.js index c6a99c9..222e0f6 100644 --- a/resources/js/helpers/User.js +++ b/resources/js/helpers/User.js @@ -4,10 +4,12 @@ export const findResult = (user, round) => { return round.results.find(result => result.user_id == user.id); }; -export const getAvatarUrl = user => user.avatar +export const getAvatarUrl = user => user && user.avatar ? `//cdn.discordapp.com/avatars/${user.id}/${user.avatar}.png` : '/default-avatar.png'; +export const getUserName = user => (user && (user.nickname || user.username)) || ''; + export const hasFinishedRound = (user, round) => { const result = findResult(user, round); return result && result.has_finished; diff --git a/resources/js/i18n/de.js b/resources/js/i18n/de.js index 17cb41f..09d6db7 100644 --- a/resources/js/i18n/de.js +++ b/resources/js/i18n/de.js @@ -166,6 +166,7 @@ export default { lockError: 'Fehler beim Sperren', lockIncompleteWarning: 'Achtung: Noch nicht alle Runner haben ihr Ergebnis für diese Runde eingereicht!', lockSuccess: 'Runde gesperrt', + rolledBy: 'Gerollt von {{name}}', seed: 'Seed', setSeed: 'Seed eintragen', setSeedError: 'Seed konnte nicht eintragen werden', diff --git a/resources/js/i18n/en.js b/resources/js/i18n/en.js index f0c6871..72548f6 100644 --- a/resources/js/i18n/en.js +++ b/resources/js/i18n/en.js @@ -166,6 +166,7 @@ export default { lockError: 'Error locking round', lockIncompleteWarning: 'Warning: Not all runners have submitted their results for this round yet!', lockSuccess: 'Round locked', + rolledBy: 'Rolled by {{name}}', seed: 'Seed', setSeed: 'Set seed', setSeedError: 'Seed could not be set', diff --git a/resources/sass/rounds.scss b/resources/sass/rounds.scss index 4145523..d8d117d 100644 --- a/resources/sass/rounds.scss +++ b/resources/sass/rounds.scss @@ -20,7 +20,18 @@ font-size: 125%; } - .seed-code, .btn { + .rolled-by { + display: inline-block; + vertical-align: middle; + + img { + max-height: 2rem; + width: auto; + border-radius: 50%; + } + } + + .seed-code, .btn, .rolled-by { margin-bottom: 1ex; } }