From af5bd49c2fed4e8493de1d4238678958d43040bb Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Sat, 24 Dec 2022 01:07:55 -0800 Subject: [PATCH] Add display for Telumas and fix WeaponModal display --- components/WeaponKeySelect/index.tsx | 14 +++++----- components/WeaponUnit/index.scss | 10 ++++---- components/WeaponUnit/index.tsx | 38 ++++++++++++++++++++++++++-- 3 files changed, 48 insertions(+), 14 deletions(-) diff --git a/components/WeaponKeySelect/index.tsx b/components/WeaponKeySelect/index.tsx index 81609a75..a1bc39ee 100644 --- a/components/WeaponKeySelect/index.tsx +++ b/components/WeaponKeySelect/index.tsx @@ -48,17 +48,17 @@ const WeaponKeySelect = React.forwardRef( ) let groupedKeys = [] for (let i = 0; i <= numGroups; i++) { - groupedKeys[i] = weaponKeys.filter((key) => key.group == i) + const values = weaponKeys.filter((key) => key.group == i) + if (values.length > 0) groupedKeys[i] = values } - setKeys(groupedKeys) + setKeys(groupedKeys.filter(() => true)) } function fetchWeaponKeys() { - api.endpoints.weapon_keys.getAll(filterParams).then((response) => { - const keys = response.data - organizeWeaponKeys(keys) - }) + api.endpoints.weapon_keys + .getAll(filterParams) + .then((response) => organizeWeaponKeys(response.data)) } fetchWeaponKeys() @@ -90,7 +90,7 @@ const WeaponKeySelect = React.forwardRef( if (props.series == 2 && index == 0) name = pendulumNames[0] else if (props.series == 2 && props.slot == 1 && index == 1) name = pendulumNames[1] - else if (props.series == 3) name = telumaNames[index] + else if (props.series == 3) name = telumaNames[0] else if (props.series == 17) name = gauphNames[props.slot] else if (props.series == 22) name = emblemNames[index] diff --git a/components/WeaponUnit/index.scss b/components/WeaponUnit/index.scss index 79f69ec1..225b005d 100644 --- a/components/WeaponUnit/index.scss +++ b/components/WeaponUnit/index.scss @@ -48,11 +48,11 @@ left: -3.5%; } - .Modifiers > .AxSkills { + .Modifiers > .Skills { bottom: 12%; right: -3.5%; - & > .AxSkill { + & > .Skill { width: 25%; height: auto; } @@ -80,11 +80,11 @@ left: -3.5%; } - .Modifiers > .AxSkills { + .Modifiers > .Skills { bottom: 12%; left: -3.5%; - & > .AxSkill { + & > .Skill { width: 20%; height: auto; } @@ -158,7 +158,7 @@ position: absolute; z-index: 3; - .AxSkills { + .Skills { display: flex; gap: $unit-fourth; justify-content: flex-end; diff --git a/components/WeaponUnit/index.tsx b/components/WeaponUnit/index.tsx index 52523ee5..db499054 100644 --- a/components/WeaponUnit/index.tsx +++ b/components/WeaponUnit/index.tsx @@ -11,6 +11,7 @@ import Button from '~components/Button' import type { SearchableObject } from '~types' +import { appState } from '~utils/appState' import { axData } from '~utils/axData' import { weaponAwakening } from '~utils/awakening' @@ -95,6 +96,37 @@ const WeaponUnit = (props: Props) => { } } + function telumaImage(index: number) { + const baseUrl = `${process.env.NEXT_PUBLIC_SIERO_IMG_URL}/weapon-keys/` + let filename = '' + let altText = '' + + // If there is a grid weapon, it is a Draconic Weapon and it has keys + if ( + props.gridWeapon && + props.gridWeapon.object.series === 3 && + props.gridWeapon.weapon_keys + ) { + if (index === 0 && props.gridWeapon.weapon_keys[0]) { + altText = `${props.gridWeapon.weapon_keys[0].name[locale]}` + filename = `${props.gridWeapon.weapon_keys[0].slug}.png` + } else if (index === 1 && props.gridWeapon.weapon_keys[1]) { + altText = `${props.gridWeapon.weapon_keys[1].name[locale]}` + + const element = props.gridWeapon.object.element + filename = `${props.gridWeapon.weapon_keys[1].slug}-${element}.png` + } + + return ( + {`${altText}`} + ) + } + } + function axImage(index: number) { const axSkill = getCanonicalAxSkill(index) @@ -108,7 +140,7 @@ const WeaponUnit = (props: Props) => { return ( {`axskill`} ) @@ -157,9 +189,11 @@ const WeaponUnit = (props: Props) => {
{awakeningImage()} -
+
{axImage(0)} {axImage(1)} + {telumaImage(0)} + {telumaImage(1)}
{weapon?.name.en}