Add Summon and Character hovercards
This commit is contained in:
parent
f950543c96
commit
d5ac0ba6d7
7 changed files with 200 additions and 5 deletions
0
components/CharacterHovercard/index.scss
Normal file
0
components/CharacterHovercard/index.scss
Normal file
87
components/CharacterHovercard/index.tsx
Normal file
87
components/CharacterHovercard/index.tsx
Normal file
|
|
@ -0,0 +1,87 @@
|
||||||
|
import React from 'react'
|
||||||
|
import * as HoverCard from '@radix-ui/react-hover-card'
|
||||||
|
|
||||||
|
import WeaponLabelIcon from '~components/WeaponLabelIcon'
|
||||||
|
import UncapIndicator from '~components/UncapIndicator'
|
||||||
|
|
||||||
|
import { axData } from '~utils/axData'
|
||||||
|
|
||||||
|
import './index.scss'
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
gridCharacter: GridCharacter
|
||||||
|
children: React.ReactNode
|
||||||
|
}
|
||||||
|
|
||||||
|
interface KeyNames {
|
||||||
|
[key: string]: {
|
||||||
|
en: string,
|
||||||
|
jp: string
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const CharacterHovercard = (props: Props) => {
|
||||||
|
const Element = ['null', 'wind', 'fire', 'water', 'earth', 'dark', 'light']
|
||||||
|
const Proficiency = ['none', 'sword', 'dagger', 'axe', 'spear', 'bow', 'staff', 'fist', 'harp', 'gun', 'katana']
|
||||||
|
|
||||||
|
const tintElement = Element[props.gridCharacter.object.element]
|
||||||
|
const wikiUrl = `https://gbf.wiki/${props.gridCharacter.object.name.en.replaceAll(' ', '_')}`
|
||||||
|
|
||||||
|
function characterImage() {
|
||||||
|
let imgSrc = ""
|
||||||
|
|
||||||
|
if (props.gridCharacter) {
|
||||||
|
const character = props.gridCharacter.object
|
||||||
|
|
||||||
|
// Change the image based on the uncap level
|
||||||
|
let suffix = '01'
|
||||||
|
if (props.gridCharacter.uncap_level == 6)
|
||||||
|
suffix = '04'
|
||||||
|
else if (props.gridCharacter.uncap_level == 5)
|
||||||
|
suffix = '03'
|
||||||
|
else if (props.gridCharacter.uncap_level > 2)
|
||||||
|
suffix = '02'
|
||||||
|
|
||||||
|
imgSrc = `${process.env.NEXT_PUBLIC_SIERO_IMG_URL}/chara-grid/${character.granblue_id}_${suffix}.jpg`
|
||||||
|
}
|
||||||
|
|
||||||
|
return imgSrc
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<HoverCard.Root>
|
||||||
|
<HoverCard.Trigger>
|
||||||
|
{ props.children }
|
||||||
|
</HoverCard.Trigger>
|
||||||
|
<HoverCard.Content className="Weapon Hovercard">
|
||||||
|
<div className="top">
|
||||||
|
<div className="title">
|
||||||
|
<h4>{ props.gridCharacter.object.name.en }</h4>
|
||||||
|
<img alt={props.gridCharacter.object.name.en} src={characterImage()} />
|
||||||
|
</div>
|
||||||
|
<div className="subInfo">
|
||||||
|
<div className="icons">
|
||||||
|
<WeaponLabelIcon labelType={Element[props.gridCharacter.object.element]} />
|
||||||
|
<WeaponLabelIcon labelType={ Proficiency[props.gridCharacter.object.proficiency.proficiency1] } />
|
||||||
|
{ (props.gridCharacter.object.proficiency.proficiency2) ?
|
||||||
|
<WeaponLabelIcon labelType={ Proficiency[props.gridCharacter.object.proficiency.proficiency2] } />
|
||||||
|
: ''}
|
||||||
|
</div>
|
||||||
|
<UncapIndicator
|
||||||
|
type="character"
|
||||||
|
ulb={props.gridCharacter.object.uncap.ulb || false}
|
||||||
|
flb={props.gridCharacter.object.uncap.flb || false}
|
||||||
|
special={false}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<a className={`Button ${tintElement}`} href={wikiUrl} target="_new">View more on gbf.wiki</a>
|
||||||
|
<HoverCard.Arrow />
|
||||||
|
</HoverCard.Content>
|
||||||
|
</HoverCard.Root>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default CharacterHovercard
|
||||||
|
|
||||||
|
|
@ -7,6 +7,7 @@ import PlusIcon from '~public/icons/Add.svg'
|
||||||
|
|
||||||
import './index.scss'
|
import './index.scss'
|
||||||
import { omit } from 'lodash'
|
import { omit } from 'lodash'
|
||||||
|
import CharacterHovercard from '~components/CharacterHovercard'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
gridCharacter: GridCharacter | undefined
|
gridCharacter: GridCharacter | undefined
|
||||||
|
|
@ -75,7 +76,7 @@ const CharacterUnit = (props: Props) => {
|
||||||
</SearchModal>
|
</SearchModal>
|
||||||
)
|
)
|
||||||
|
|
||||||
return (
|
const unitContent = (
|
||||||
<div>
|
<div>
|
||||||
<div className={classes}>
|
<div className={classes}>
|
||||||
{ (props.editable) ? editableImage : image }
|
{ (props.editable) ? editableImage : image }
|
||||||
|
|
@ -92,6 +93,18 @@ const CharacterUnit = (props: Props) => {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const withHovercard = (
|
||||||
|
<CharacterHovercard gridCharacter={gridCharacter!}>
|
||||||
|
{unitContent}
|
||||||
|
</CharacterHovercard>
|
||||||
|
)
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={classes}>
|
||||||
|
{ (gridCharacter) ? withHovercard : unitContent }
|
||||||
|
</div>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CharacterUnit
|
export default CharacterUnit
|
||||||
|
|
|
||||||
0
components/SummonHovercard/index.scss
Normal file
0
components/SummonHovercard/index.scss
Normal file
83
components/SummonHovercard/index.tsx
Normal file
83
components/SummonHovercard/index.tsx
Normal file
|
|
@ -0,0 +1,83 @@
|
||||||
|
import React from 'react'
|
||||||
|
import * as HoverCard from '@radix-ui/react-hover-card'
|
||||||
|
|
||||||
|
import WeaponLabelIcon from '~components/WeaponLabelIcon'
|
||||||
|
import UncapIndicator from '~components/UncapIndicator'
|
||||||
|
|
||||||
|
import { axData } from '~utils/axData'
|
||||||
|
|
||||||
|
import './index.scss'
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
gridSummon: GridSummon
|
||||||
|
children: React.ReactNode
|
||||||
|
}
|
||||||
|
|
||||||
|
interface KeyNames {
|
||||||
|
[key: string]: {
|
||||||
|
en: string,
|
||||||
|
jp: string
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const SummonHovercard = (props: Props) => {
|
||||||
|
const Element = ['null', 'wind', 'fire', 'water', 'earth', 'dark', 'light']
|
||||||
|
const Proficiency = ['none', 'sword', 'dagger', 'axe', 'spear', 'bow', 'staff', 'fist', 'harp', 'gun', 'katana']
|
||||||
|
|
||||||
|
const tintElement = Element[props.gridSummon.object.element]
|
||||||
|
const wikiUrl = `https://gbf.wiki/${props.gridSummon.object.name.en.replaceAll(' ', '_')}`
|
||||||
|
|
||||||
|
function summonImage() {
|
||||||
|
let imgSrc = ""
|
||||||
|
|
||||||
|
if (props.gridSummon) {
|
||||||
|
const summon = props.gridSummon.object
|
||||||
|
|
||||||
|
const upgradedSummons = [
|
||||||
|
'2040094000', '2040100000', '2040080000', '2040098000',
|
||||||
|
'2040090000', '2040084000', '2040003000', '2040056000'
|
||||||
|
]
|
||||||
|
|
||||||
|
let suffix = ''
|
||||||
|
if (upgradedSummons.indexOf(summon.granblue_id.toString()) != -1 && props.gridSummon.uncap_level == 5)
|
||||||
|
suffix = '_02'
|
||||||
|
|
||||||
|
// Generate the correct source for the summon
|
||||||
|
imgSrc = `${process.env.NEXT_PUBLIC_SIERO_IMG_URL}/summon-grid/${summon.granblue_id}${suffix}.jpg`
|
||||||
|
}
|
||||||
|
|
||||||
|
return imgSrc
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<HoverCard.Root>
|
||||||
|
<HoverCard.Trigger>
|
||||||
|
{ props.children }
|
||||||
|
</HoverCard.Trigger>
|
||||||
|
<HoverCard.Content className="Weapon Hovercard">
|
||||||
|
<div className="top">
|
||||||
|
<div className="title">
|
||||||
|
<h4>{ props.gridSummon.object.name.en }</h4>
|
||||||
|
<img alt={props.gridSummon.object.name.en} src={summonImage()} />
|
||||||
|
</div>
|
||||||
|
<div className="subInfo">
|
||||||
|
<div className="icons">
|
||||||
|
<WeaponLabelIcon labelType={Element[props.gridSummon.object.element]}/>
|
||||||
|
</div>
|
||||||
|
<UncapIndicator
|
||||||
|
type="summon"
|
||||||
|
ulb={props.gridSummon.object.uncap.ulb || false}
|
||||||
|
flb={props.gridSummon.object.uncap.flb || false}
|
||||||
|
special={false}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<a className={`Button ${tintElement}`} href={wikiUrl} target="_new">View more on gbf.wiki</a>
|
||||||
|
<HoverCard.Arrow />
|
||||||
|
</HoverCard.Content>
|
||||||
|
</HoverCard.Root>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default SummonHovercard
|
||||||
|
|
||||||
|
|
@ -2,6 +2,7 @@ import React, { useEffect, useState } from 'react'
|
||||||
import classnames from 'classnames'
|
import classnames from 'classnames'
|
||||||
|
|
||||||
import SearchModal from '~components/SearchModal'
|
import SearchModal from '~components/SearchModal'
|
||||||
|
import SummonHovercard from '~components/SummonHovercard'
|
||||||
import UncapIndicator from '~components/UncapIndicator'
|
import UncapIndicator from '~components/UncapIndicator'
|
||||||
import PlusIcon from '~public/icons/Add.svg'
|
import PlusIcon from '~public/icons/Add.svg'
|
||||||
|
|
||||||
|
|
@ -81,8 +82,8 @@ const SummonUnit = (props: Props) => {
|
||||||
</SearchModal>
|
</SearchModal>
|
||||||
)
|
)
|
||||||
|
|
||||||
return (
|
const unitContent = (
|
||||||
<div className={classes}>
|
<div>
|
||||||
{ (props.editable) ? editableImage : image }
|
{ (props.editable) ? editableImage : image }
|
||||||
{ (gridSummon) ?
|
{ (gridSummon) ?
|
||||||
<UncapIndicator
|
<UncapIndicator
|
||||||
|
|
@ -97,6 +98,18 @@ const SummonUnit = (props: Props) => {
|
||||||
<h3 className="SummonName">{summon?.name.en}</h3>
|
<h3 className="SummonName">{summon?.name.en}</h3>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const withHovercard = (
|
||||||
|
<SummonHovercard gridSummon={gridSummon!}>
|
||||||
|
{unitContent}
|
||||||
|
</SummonHovercard>
|
||||||
|
)
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={classes}>
|
||||||
|
{ (gridSummon) ? withHovercard : unitContent }
|
||||||
|
</div>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default SummonUnit
|
export default SummonUnit
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ import UncapIndicator from '~components/UncapIndicator'
|
||||||
import { axData } from '~utils/axData'
|
import { axData } from '~utils/axData'
|
||||||
|
|
||||||
import './index.scss'
|
import './index.scss'
|
||||||
import { keys } from 'lodash'
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
gridWeapon: GridWeapon
|
gridWeapon: GridWeapon
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue