Skip to content

Commit

Permalink
Pass filters from parent component
Browse files Browse the repository at this point in the history
We need to constantly recalculate these which wasn't happening in the child component
  • Loading branch information
lorgan3 committed Jul 9, 2024
1 parent ef3d004 commit ffa1174
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 12 deletions.
15 changes: 5 additions & 10 deletions src/components/molecules/SpellSlot.vue
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
<script setup lang="ts">
import { Spell } from "../../data/spells";
import { Manager } from "../../data/network/manager";
import { ELEMENT_COLOR_MAP } from "../../graphics/elements";
import { Element } from "../../data/spells/types";
const SPRITES_PER_ROW = 5;
const { spell, animated } = defineProps<{
const { spell, animated, element1Filter, element2Filter } = defineProps<{
spell: Spell;
animated?: boolean;
element1Filter: string;
element2Filter: string;
}>();
const getElementFilter = (element: Element) =>
`brightness(${
0.1 + Math.min(1, Manager.instance.getElementValue(element) / 1.3)
})`;
</script>

<template>
Expand All @@ -37,7 +32,7 @@ const getElementFilter = (element: Element) =>
:style="{
'--dash-offset': 0,
stroke: ELEMENT_COLOR_MAP[spell.elements[0]],
filter: getElementFilter(spell.elements[0]),
filter: element1Filter,
}"
x="2px"
y="2px"
Expand All @@ -50,7 +45,7 @@ const getElementFilter = (element: Element) =>
:style="{
'--dash-offset': 1,
stroke: ELEMENT_COLOR_MAP[spell.elements[1] || spell.elements[0]],
filter: getElementFilter(spell.elements[1] || spell.elements[0]),
filter: element2Filter,
}"
x="2px"
y="2px"
Expand Down
25 changes: 23 additions & 2 deletions src/components/organisms/Inventory.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { Message, MessageType } from "../../data/network/types";
import Tooltip from "../atoms/Tooltip.vue";
import SpellDescription from "../molecules/SpellDescription.vue";
import SpellSlot from "../molecules/SpellSlot.vue";
import { Element } from "../../data/spells/types";
const props = defineProps<{
isOpen: boolean;
Expand Down Expand Up @@ -78,6 +79,11 @@ const handleClick = (spell?: Spell) => {
selectedSpell.value = spell;
}
};
const getElementFilter = (element: Element) =>
`brightness(${
0.1 + Math.min(1, Manager.instance.getElementValue(element) / 1.3)
})`;
</script>

<template>
Expand Down Expand Up @@ -108,7 +114,15 @@ const handleClick = (spell?: Spell) => {
locked: !availableList[selectedSpell.iconId],
}"
>
<SpellSlot :spell="selectedSpell" />
<SpellSlot
:spell="selectedSpell"
:element1Filter="getElementFilter(selectedSpell.elements[0])"
:element2Filter="
getElementFilter(
selectedSpell.elements[1] || selectedSpell.elements[0]
)
"
/>
</div>
</Tooltip>
</div>
Expand All @@ -128,7 +142,14 @@ const handleClick = (spell?: Spell) => {
}"
@click="handleClick(spell)"
>
<SpellSlot :spell="spell" :animated="spell === selectedSpell" />
<SpellSlot
:spell="spell"
:animated="spell === selectedSpell"
:element1Filter="getElementFilter(spell.elements[0])"
:element2Filter="
getElementFilter(spell.elements[1] || spell.elements[0])
"
/>
</div>
</Tooltip>
</div>
Expand Down

0 comments on commit ffa1174

Please sign in to comment.