From 2110d91bc5016fd78aec02578b09506b6d67f45e Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Wed, 16 Mar 2022 14:45:34 +0100 Subject: [PATCH] display seed code --- app/Models/Round.php | 4 + .../2022_03_16_083537_add_seed_code.php | 32 ++++++++ resources/js/components/common/ZeldaIcon.js | 80 +++++++++++++++++++ resources/js/components/rounds/Item.js | 8 +- resources/js/components/rounds/SeedCode.js | 17 ++++ resources/js/i18n/de.js | 54 +++++++++++++ resources/sass/common.scss | 13 +++ resources/sass/rounds.scss | 14 ++++ 8 files changed, 220 insertions(+), 2 deletions(-) create mode 100644 database/migrations/2022_03_16_083537_add_seed_code.php create mode 100644 resources/js/components/common/ZeldaIcon.js create mode 100644 resources/js/components/rounds/SeedCode.js diff --git a/app/Models/Round.php b/app/Models/Round.php index 3b84c55..e935010 100644 --- a/app/Models/Round.php +++ b/app/Models/Round.php @@ -17,6 +17,10 @@ class Round extends Model return $this->belongsTo(Tournament::class); } + protected $casts = [ + 'code' => 'array', + ]; + protected $fillable = [ 'tournament_id', ]; diff --git a/database/migrations/2022_03_16_083537_add_seed_code.php b/database/migrations/2022_03_16_083537_add_seed_code.php new file mode 100644 index 0000000..db63d5a --- /dev/null +++ b/database/migrations/2022_03_16_083537_add_seed_code.php @@ -0,0 +1,32 @@ +text('code'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('rounds', function(Blueprint $table) { + $table->dropColumn('code'); + }); + } +}; diff --git a/resources/js/components/common/ZeldaIcon.js b/resources/js/components/common/ZeldaIcon.js new file mode 100644 index 0000000..84f2220 --- /dev/null +++ b/resources/js/components/common/ZeldaIcon.js @@ -0,0 +1,80 @@ +import PropTypes from 'prop-types'; +import React from 'react'; +import { withTranslation } from 'react-i18next'; + +import i18n from '../../i18n'; + +const getIconURL = name => { + switch (name) { + case 'big-key': + case 'blue-boomerang': + case 'blue-mail': + case 'blue-pendant': + case 'blue-potion': + case 'bombos': + case 'bomb': + case 'book': + case 'boots': + case 'bottle-bee': + case 'bottle': + case 'bow': + case 'bugnet': + case 'byrna': + case 'cape': + case 'compass': + case 'crystal': + case 'duck': + case 'ether': + case 'fairy': + case 'fighter-shield': + case 'fire-rod': + case 'fire-shield': + case 'flippers': + case 'flute': + case 'glove': + case 'green-mail': + case 'green-pendant': + case 'green-potion': + case 'hammer': + case 'heart-container': + case 'heart-piece': + case 'hookshot': + case 'ice-rod': + case 'lamp': + case 'map': + case 'mirror': + case 'mirror-shield': + case 'mitts': + case 'moonpearl': + case 'mushroom': + case 'powder': + case 'quake': + case 'red-bomb': + case 'red-boomerang': + case 'red-mail': + case 'red-pendant': + case 'red-potion': + case 'shovel': + case 'silvers': + case 'small-key': + case 'somaria': + return `/item/${name}.png`; + default: + return ''; + } +}; + +const ZeldaIcon = ({ name }) => + + {i18n.t(`icon.zelda.${name}`)} +; + +ZeldaIcon.propTypes = { + name: PropTypes.string, +}; + +export default withTranslation()(ZeldaIcon); diff --git a/resources/js/components/rounds/Item.js b/resources/js/components/rounds/Item.js index 1832edb..c17a5aa 100644 --- a/resources/js/components/rounds/Item.js +++ b/resources/js/components/rounds/Item.js @@ -1,12 +1,12 @@ import PropTypes from 'prop-types'; import React from 'react'; -import { Button } from 'react-bootstrap'; import { withTranslation } from 'react-i18next'; import SeedButton from './SeedButton'; +import SeedCode from './SeedCode'; import List from '../results/List'; import ReportButton from '../results/ReportButton'; -import { maySetSeed, isParticipant } from '../../helpers/permissions'; +import { isParticipant } from '../../helpers/permissions'; import { findParticipant } from '../../helpers/Tournament'; import { withUser } from '../../helpers/UserContext'; import i18n from '../../i18n'; @@ -24,6 +24,9 @@ const Item = ({ {i18n.t('rounds.date', { date: new Date(round.created_at) })}

+ {round.code ? + + : null} + + {code.map((symbol, index) => + + )} +; + +SeedCode.propTypes = { + code: PropTypes.arrayOf(PropTypes.string), +}; + +export default SeedCode; diff --git a/resources/js/i18n/de.js b/resources/js/i18n/de.js index 97089e6..27a2a40 100644 --- a/resources/js/i18n/de.js +++ b/resources/js/i18n/de.js @@ -28,6 +28,60 @@ export default { PendingIcon: 'Ausstehend', SecondPlaceIcon: 'Zweiter Platz', ThirdPlaceIcon: 'Dritter Platz', + zelda: { + 'big-key': 'Big Key', + 'blue-boomerang': 'Boomerang', + 'blue-mail': 'Blue Mail', + 'blue-pendant': 'Pendant of Power', + 'blue-potion': 'Blue Potion', + bombos: 'Bombos', + bomb: 'Bomb', + book: 'Book', + boots: 'Boots', + 'bottle-bee': 'Bee in a Bottle', + bottle: 'Bottle', + bow: 'Bow', + bugnet: 'Bugnet', + byrna: 'Cane of Byrna', + cape: 'Cape', + compass: 'Compass', + crystal: 'Crystal', + duck: 'Duck', + ether: 'Ether', + fairy: 'Fairy in a Bottle', + 'fighter-shield': 'Fighter Shield', + 'fire-rod': 'Fire Rod', + 'fire-shield': 'Fire Shield', + flippers: 'Flippers', + flute: 'Flute', + glove: 'Power Glove', + 'green-mail': 'Green Mail', + 'green-pendant': 'Pendant of Courage', + 'green-potion': 'Green Potion', + hammer: 'Hammer', + 'heart-container': 'Heart Container', + 'heart-piece': 'Heart Piece', + hookshot: 'Hookshot', + 'ice-rod': 'Ice Rod', + lamp: 'Lamp', + map: 'Map', + mirror: 'Mirror', + 'mirror-shield': 'Mirror Shield', + mitts: 'Titan \'s Mitts', + moonpearl: 'Moonpearl', + mushroom: 'Mushroom', + powder: 'Powder', + quake: 'Quake', + 'red-bomb': 'Red Bomb', + 'red-boomerang': 'Red Boomerang', + 'red-mail': 'Red Mail', + 'red-pendant': 'Pendant of Wisdom', + 'red-potion': 'Red Potion', + shovel: 'Shovel', + silvers: 'Silvers', + 'small-key': 'Small Key', + somaria: 'Cane of Somaria', + }, }, participants: { empty: 'Noch keine Teilnehmer eingetragen', diff --git a/resources/sass/common.scss b/resources/sass/common.scss index f585be0..57d0d5f 100644 --- a/resources/sass/common.scss +++ b/resources/sass/common.scss @@ -20,3 +20,16 @@ h1 { .text-bronze { color: $bronze; } + +.zelda-icon { + display: inline-flex; + align-items: center; + width: 2em; + height: 2em; + + img { + margin: auto; + max-width: 100%; + max-height: 100%; + } +} diff --git a/resources/sass/rounds.scss b/resources/sass/rounds.scss index ee38c82..f258d46 100644 --- a/resources/sass/rounds.scss +++ b/resources/sass/rounds.scss @@ -15,6 +15,20 @@ .date { font-size: 125%; } + + .seed-code { + margin: 1rem 0; + } } } } + +.seed-code { + display: flex; + flex-direction: row; + flex-wrap: nowrap; + align-items: center; + align-content: center; + justify-content: flex-start; + gap: 0.5ex; +} -- 2.39.2