-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: update currency display in setting for change class #15391
base: develop
Are you sure you want to change the base?
Changes from 4 commits
e3cdab6
e69078f
a98572c
cc70a5c
e36dde7
791f565
834d47a
9c64166
9cea367
c0827f1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
<div | ||
v-for="currency of currencies" | ||
:key="currency.key" | ||
:needed-currency-only="neededCurrencyOnly" | ||
class="d-flex align-items-center" | ||
> | ||
<div | ||
|
@@ -54,6 +55,9 @@ export default { | |
amountNeeded: { | ||
type: Number, | ||
}, | ||
neededCurrencyOnly: { | ||
type: Boolean, | ||
}, | ||
}, | ||
data () { | ||
return { | ||
|
@@ -67,33 +71,40 @@ export default { | |
computed: { | ||
currencies () { | ||
const currencies = []; | ||
currencies.push({ | ||
type: 'hourglasses', | ||
icon: this.icons.hourglasses, | ||
value: this.userHourglasses, | ||
}); | ||
if (this.neededCurrencyOnly === true) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You don't need the equivalency operator, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Of course, derp! |
||
currencies.push({ | ||
type: 'gems', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should not be hard-coded. We might want to display Hourglasses only, or Gold only, in other places. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, I know. Need to figure it out! |
||
icon: this.icons.gem, | ||
value: this.userGems, | ||
}); | ||
} else { | ||
currencies.push({ | ||
type: 'hourglasses', | ||
icon: this.icons.hourglasses, | ||
value: this.userHourglasses, | ||
}); | ||
|
||
currencies.push({ | ||
type: 'gems', | ||
icon: this.icons.gem, | ||
value: this.userGems, | ||
}); | ||
currencies.push({ | ||
type: 'gems', | ||
icon: this.icons.gem, | ||
value: this.userGems, | ||
}); | ||
|
||
currencies.push({ | ||
type: 'gold', | ||
icon: this.icons.gold, | ||
value: this.userGold, | ||
}); | ||
currencies.push({ | ||
type: 'gold', | ||
icon: this.icons.gold, | ||
value: this.userGold, | ||
}); | ||
|
||
for (const currency of currencies) { | ||
if ( | ||
currency.type === this.currencyNeeded | ||
&& !this.enoughCurrency(this.currencyNeeded, this.amountNeeded) | ||
) { | ||
currency.notEnough = true; | ||
for (const currency of currencies) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're skipping this code block in the needed-only case. Don't we still want the component to notice when the user doesn't have enough of the needed currency, even if we're only showing one? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Still thinking this one through. |
||
if ( | ||
currency.type === this.currencyNeeded | ||
&& !this.enoughCurrency(this.currencyNeeded, this.amountNeeded) | ||
) { | ||
currency.notEnough = true; | ||
} | ||
} | ||
} | ||
|
||
return currencies; | ||
}, | ||
}, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
class="balance-info" | ||
:currency-needed="currencyNeeded" | ||
:amount-needed="amountNeeded" | ||
neededCurrencyOnly | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. huh, does this work as a destructured syntax? Do we set up props like this anywhere else? I'd lean toward keeping the style consistent for readability, tbh, given you've used our more common format even within this PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It does, which is weird. I have, however, rewritten it so it matches our more common format. |
||
/> | ||
</div> | ||
</template> | ||
|
@@ -28,6 +29,9 @@ export default { | |
amountNeeded: { | ||
type: Number, | ||
}, | ||
neededCurrencyOnly: { | ||
type: Boolean, | ||
}, | ||
}, | ||
}; | ||
</script> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,6 +66,8 @@ | |
<your-balance | ||
:amount-needed="amountNeeded" | ||
currency-needed="gems" | ||
:neededCurrencyOnly="true" | ||
class="currency-align" | ||
/> | ||
</div> | ||
</td> | ||
|
@@ -80,6 +82,11 @@ input { | |
margin-right: 2rem; | ||
} | ||
|
||
.currency-align { | ||
display: flex; | ||
align-items: center; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are helper classes for these. You don't need to add more CSS. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed, but still figuring it out |
||
} | ||
|
||
.form-group { | ||
margin-bottom: 1.5rem; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is so weird, why do we make an array and push stuff into it instead of just defining the array in the const declaration? or one better, defining the possible currencies in the common code... 🤔 You don't necessarily need to refactor it, just .. huh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I rewrote it so the array is defined within the const declaration instead using
.push()