-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4bfee0f
commit cb18d1a
Showing
9 changed files
with
330 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
.../action/views/swap/components/swap-token-to-amount/components/swap-token-amount-input.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<template> | ||
<div | ||
:class="`swap-token-amount-input ${ | ||
value === '0.0' || value === 'Searching' ? 'placeholder' : '' | ||
}`" | ||
> | ||
{{ | ||
value !== "0.0" && value !== "Searching" | ||
? `≈ ${$filters.formatFloatingPointValue(value).value}` | ||
: value | ||
}} | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
export default { | ||
name: "SwapTokenAmountInput", | ||
}; | ||
</script> | ||
|
||
<script setup lang="ts"> | ||
defineProps({ | ||
placeholder: { | ||
type: String, | ||
default: () => { | ||
return ""; | ||
}, | ||
}, | ||
value: { | ||
type: String, | ||
default: () => { | ||
return ""; | ||
}, | ||
}, | ||
changeFocus: { | ||
type: Function, | ||
default: () => { | ||
return null; | ||
}, | ||
}, | ||
autofocus: { | ||
type: Boolean, | ||
default: () => { | ||
return false; | ||
}, | ||
}, | ||
}); | ||
</script> | ||
|
||
<style lang="less"> | ||
@import "~@action/styles/theme.less"; | ||
.swap-token-amount-input { | ||
outline: none; | ||
background: @white; | ||
margin: 0; | ||
padding: 0 76px 0 16px; | ||
font-style: normal; | ||
font-weight: 400; | ||
font-size: 34px; | ||
line-height: 40px; | ||
letter-spacing: 0.25px; | ||
color: @primaryLabel; | ||
width: 100%; | ||
box-sizing: border-box; | ||
border: 0 none; | ||
} | ||
.placeholder { | ||
color: @tertiaryLabel; | ||
} | ||
</style> |
125 changes: 125 additions & 0 deletions
125
packages/extension/src/ui/action/views/swap/components/swap-token-to-amount/index.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
<template> | ||
<div class="swap-token-input" :class="{ focus: isFocus }"> | ||
<swap-token-select | ||
:toggle-select="toggleSelect" | ||
:token="token" | ||
></swap-token-select> | ||
|
||
<swap-token-amount-input | ||
v-show="!!token" | ||
:value="amount" | ||
></swap-token-amount-input> | ||
|
||
<swap-token-fast-list | ||
v-show="!token" | ||
:select-token="selectToken" | ||
></swap-token-fast-list> | ||
|
||
<!-- <a v-show="!!token" class="swap-token-input__max">Max</a> --> | ||
<div v-show="!!token && Number(amount) > 0" class="swap-token-input__fiat"> | ||
≈ ${{ tokenPrice ? $filters.formatFiatValue(tokenPrice).value : "~" }} | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
export default { | ||
name: "SwapTokenToAmount", | ||
}; | ||
</script> | ||
|
||
<script setup lang="ts"> | ||
import { computed, ref } from "vue"; | ||
import SwapTokenSelect from "../swap-token-select/index.vue"; | ||
import SwapTokenFastList from "../swap-token-fast-list/index.vue"; | ||
import SwapTokenAmountInput from "./components/swap-token-amount-input.vue"; | ||
import { PropType } from "vue"; | ||
import { BaseToken } from "@/types/base-token"; | ||
import BigNumber from "bignumber.js"; | ||
const props = defineProps({ | ||
toggleSelect: { | ||
type: Function, | ||
default: () => { | ||
return null; | ||
}, | ||
}, | ||
selectToken: { | ||
type: Function, | ||
default: () => { | ||
return null; | ||
}, | ||
}, | ||
token: { | ||
type: Object as PropType<BaseToken | null>, | ||
default: () => { | ||
return null; | ||
}, | ||
}, | ||
amount: { | ||
type: String, | ||
default: () => "0.0", | ||
}, | ||
}); | ||
const isFocus = ref(false); | ||
const tokenPrice = computed(() => { | ||
if (props.token?.price && props.amount !== "Searching") { | ||
return new BigNumber(props.amount) | ||
.times(new BigNumber(props.token.price)) | ||
.toFixed(); | ||
} | ||
return null; | ||
}); | ||
</script> | ||
|
||
<style lang="less" scoped> | ||
@import "~@action/styles/theme.less"; | ||
.swap-token-input { | ||
width: 100%; | ||
min-height: 148px; | ||
border: 1px solid rgba(95, 99, 104, 0.2); | ||
box-sizing: border-box; | ||
border-radius: 10px; | ||
position: relative; | ||
&.focus { | ||
border: 1px solid @primary; | ||
} | ||
&__max { | ||
padding: 4px 8px; | ||
text-decoration: none; | ||
position: absolute; | ||
width: 41px; | ||
height: 24px; | ||
right: 18px; | ||
bottom: 30px; | ||
background: rgba(0, 0, 0, 0.02); | ||
border-radius: 6px; | ||
cursor: pointer; | ||
font-style: normal; | ||
font-weight: 500; | ||
font-size: 12px; | ||
line-height: 16px; | ||
letter-spacing: 0.8px; | ||
box-sizing: border-box; | ||
color: @primaryLabel; | ||
} | ||
&__fiat { | ||
font-style: normal; | ||
font-weight: 400; | ||
font-size: 14px; | ||
line-height: 20px; | ||
text-align: center; | ||
letter-spacing: 0.25px; | ||
color: @secondaryLabel; | ||
position: absolute; | ||
left: 16px; | ||
bottom: 16px; | ||
} | ||
} | ||
</style> |
Oops, something went wrong.