Skip to content
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 max btn visibility for remove liquidity & farming #844

Merged
merged 2 commits into from
Oct 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/modules/demeterFarming/components/StakeDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<div slot="right" class="el-buttons el-buttons--between">
<span class="percent">%</span>
<s-button
v-if="isMaxButtonAvailable"
class="el-button--max s-typography-button--small"
type="primary"
alternative
Expand Down
12 changes: 9 additions & 3 deletions src/views/RemoveLiquidity.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
:value="String(removePartInput)"
:decimals="0"
:disabled="liquidityLocked"
:max="100"
:max="MAX_PART"
@input="handleRemovePartChange"
@focus="setFocusedField('removePart')"
@blur="resetFocusedField"
Expand All @@ -23,12 +23,13 @@
<div slot="right" class="el-buttons el-buttons--between">
<span class="percent">%</span>
<s-button
v-if="isMaxButtonAvailable"
class="el-button--max s-typography-button--small"
type="primary"
alternative
size="mini"
border-radius="mini"
@click.stop="handleRemovePartChange(100)"
@click.stop="handleRemovePartChange(MAX_PART)"
>
{{ t('buttons.max') }}
</s-button>
Expand Down Expand Up @@ -158,6 +159,7 @@ export default class RemoveLiquidity extends Mixins(
NetworkFeeDialogMixin
) {
readonly XOR_SYMBOL = XOR.symbol;
readonly MAX_PART = 100;

@state.removeLiquidity.liquidityAmount private liquidityAmount!: string;
@state.removeLiquidity.focusedField private focusedField!: string;
Expand Down Expand Up @@ -316,9 +318,13 @@ export default class RemoveLiquidity extends Mixins(
});
}

get isMaxButtonAvailable(): boolean {
return this.removePart !== this.MAX_PART;
}

handleRemovePartChange(value: string): void {
const newValue = parseFloat(value) || 0;
this.removePartInput = Math.min(Math.max(newValue, 0), 100);
this.removePartInput = Math.min(Math.max(newValue, 0), this.MAX_PART);
this.setRemovePart(this.removePartInput);
}

Expand Down