From f4be26467bb876e454767400c4bca13b39007a97 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Tue, 15 Sep 2020 04:15:35 -0700 Subject: [PATCH] Set weapons when they're selected --- src/components/SearchModal/SearchModal.css | 1 + src/components/SearchModal/SearchModal.tsx | 7 ++-- .../WeaponGridMainhand/WeaponGridMainhand.css | 13 +++++-- .../WeaponGridMainhand/WeaponGridMainhand.tsx | 18 +++++++++- .../WeaponGridUnit/WeaponGridUnit.css | 9 +++++ .../WeaponGridUnit/WeaponGridUnit.tsx | 18 +++++++++- src/components/WeaponResult/WeaponResult.tsx | 34 ++----------------- 7 files changed, 62 insertions(+), 38 deletions(-) diff --git a/src/components/SearchModal/SearchModal.css b/src/components/SearchModal/SearchModal.css index 8a5ef09c..30f02471 100644 --- a/src/components/SearchModal/SearchModal.css +++ b/src/components/SearchModal/SearchModal.css @@ -24,5 +24,6 @@ } .SearchModal #results_container { + margin: 0; padding: 0 12px 12px 12px; } \ No newline at end of file diff --git a/src/components/SearchModal/SearchModal.tsx b/src/components/SearchModal/SearchModal.tsx index ca0b5abf..f89bba85 100644 --- a/src/components/SearchModal/SearchModal.tsx +++ b/src/components/SearchModal/SearchModal.tsx @@ -9,6 +9,7 @@ import './SearchModal.css' interface Props { close: () => void + send: (weapon: Weapon) => void placeholderText: string } @@ -68,11 +69,11 @@ class SearchModal extends React.Component { if (results.length) { return ( -
+
    { results.map( result => { - return + return { this.props.send(result) }} /> })} -
+ ) } } diff --git a/src/components/WeaponGridMainhand/WeaponGridMainhand.css b/src/components/WeaponGridMainhand/WeaponGridMainhand.css index 748da59a..bed958c8 100644 --- a/src/components/WeaponGridMainhand/WeaponGridMainhand.css +++ b/src/components/WeaponGridMainhand/WeaponGridMainhand.css @@ -4,11 +4,12 @@ border: 1px solid rgba(0, 0, 0, 0); border-radius: 8px; display: flex; - height: 432px; + height: 420px; justify-content: center; margin-right: 24px; + overflow: hidden; transition: all 0.18s ease-in-out; - width: 205px; + width: 200px; } .WeaponGridMainhand:hover { @@ -18,10 +19,18 @@ transform: scale(1.05, 1.05); } +.WeaponGridMainhand img { + position: relative; + width: 100%; + z-index: 2; +} + .WeaponGridMainhand .icon { + position: absolute; color: #c9c9c9; height: 20px; width: 20px; + z-index: 1; } .WeaponGridMainhand:hover .icon { diff --git a/src/components/WeaponGridMainhand/WeaponGridMainhand.tsx b/src/components/WeaponGridMainhand/WeaponGridMainhand.tsx index 2694a830..d48dc2d3 100644 --- a/src/components/WeaponGridMainhand/WeaponGridMainhand.tsx +++ b/src/components/WeaponGridMainhand/WeaponGridMainhand.tsx @@ -1,22 +1,38 @@ -import React from 'react' +import React, { useEffect, useState } from 'react' import './WeaponGridMainhand.css' import SearchModal from '../SearchModal/SearchModal' import { useModal as useModal } from '../../useModal' +import mainhandImages from '../../images/mainhand/*.jpg' import Plus from '../../../assets/plus.svg' function WeaponGridUnit() { const { open, openModal, closeModal } = useModal() + const [weapon, setWeapon] = useState({ + id: '', + granblue_id: 0, + name: { + en: '', + jp: '' + } + }) + + function receiveData(data: Weapon) { + setWeapon(data) + closeModal() + } return (
+
{open ? ( ) : null} diff --git a/src/components/WeaponGridUnit/WeaponGridUnit.css b/src/components/WeaponGridUnit/WeaponGridUnit.css index 73e031c6..c3a3a787 100644 --- a/src/components/WeaponGridUnit/WeaponGridUnit.css +++ b/src/components/WeaponGridUnit/WeaponGridUnit.css @@ -6,6 +6,7 @@ display: flex; height: 92px; justify-content: center; + overflow: hidden; transition: all 0.18s ease-in-out; width: 160px; } @@ -17,10 +18,18 @@ transform: scale(1.1, 1.1); } +.WeaponGridUnit img { + position: relative; + width: 100%; + z-index: 2; +} + .WeaponGridUnit .icon { + position: absolute; color: #c9c9c9; height: 20px; width: 20px; + z-index: 1; } .WeaponGridUnit:hover .icon { diff --git a/src/components/WeaponGridUnit/WeaponGridUnit.tsx b/src/components/WeaponGridUnit/WeaponGridUnit.tsx index 535c3623..26dce1f6 100644 --- a/src/components/WeaponGridUnit/WeaponGridUnit.tsx +++ b/src/components/WeaponGridUnit/WeaponGridUnit.tsx @@ -1,23 +1,39 @@ -import React from 'react' +import React, { useEffect, useState } from 'react' import './WeaponGridUnit.css' import SearchModal from '../SearchModal/SearchModal' import { useModal as useModal } from '../../useModal' +import gridImages from '../../images/grid/*.jpg' import Plus from '../../../assets/plus.svg' function WeaponGridUnit() { const { open, openModal, closeModal } = useModal() + const [weapon, setWeapon] = useState({ + id: '', + granblue_id: 0, + name: { + en: '', + jp: '' + } + }) + + function receiveData(data: Weapon) { + setWeapon(data) + closeModal() + } return (
+
{open ? ( ) : null} diff --git a/src/components/WeaponResult/WeaponResult.tsx b/src/components/WeaponResult/WeaponResult.tsx index 70b15271..dafaf699 100644 --- a/src/components/WeaponResult/WeaponResult.tsx +++ b/src/components/WeaponResult/WeaponResult.tsx @@ -6,37 +6,9 @@ import WeaponLabelIcon from '../WeaponLabelIcon/WeaponLabelIcon' import gridImages from '../../images/grid/*.jpg' -interface Weapon { - id: string - granblue_id: number - element: number - proficiency: number - max_level: number - max_skill_level: number - name: { - en: string - jp: string - } - hp: { - min_hp: number - max_hp: number - max_hp_flb: number - max_hp_ulb: number - } - atk: { - min_atk: number - max_atk: number - max_atk_flb: number - max_atk_ulb: number - } - uncap: { - flb: boolean - ulb: boolean - } -} - interface Props { data: Weapon + onClick: () => Weapon } const Element = ['null', 'wind', 'fire', 'water', 'earth', 'dark', 'light'] @@ -47,7 +19,7 @@ class WeaponResult extends React.Component { render() { const weapon = this.props.data return ( -
+
  • {weapon.name.en}
    @@ -57,7 +29,7 @@ class WeaponResult extends React.Component {
    -
    +
  • ) } }