Skip to content

Commit

Permalink
Merge pull request #1040 from aeternity/feature/rebranded_button
Browse files Browse the repository at this point in the history
Rebrand tip icon
  • Loading branch information
mradkov authored Mar 24, 2021
2 parents 6a50665 + 78f3de0 commit 5edb21a
Show file tree
Hide file tree
Showing 3 changed files with 148 additions and 52 deletions.
116 changes: 81 additions & 35 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/assets/iconTipRebranded.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
78 changes: 61 additions & 17 deletions src/components/TipInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@
:title="title"
@click="useSdkWallet && (showModal = true)"
>
<img :src="iconTip">
<template v-if="userAddress">
<IconTipUser />
</template>
<template v-else>
<IconTip :class="{ tipped: tipUrlStats.isTipped }" />
</template>
<AeAmountFiat
v-if="!userAddress && tipAmount.value"
:amount="tipAmount.value"
Expand Down Expand Up @@ -59,7 +64,7 @@
<div class="not-bootstrap-row">
<AeInputAmount
v-model="inputValue"
:select-token-f="(token) => inputToken = token"
:select-token-f="token => (inputToken = token)"
/>
<AeButton :disabled="!isValid || v1TipWarning">
{{ tip ? $t('retip') : $t('tip') }}
Expand All @@ -73,9 +78,8 @@

<script>
import { mapState, mapGetters } from 'vuex';
import iconTip from '../assets/iconTip.svg';
import iconTipUser from '../assets/iconTipUser.svg';
import iconTipped from '../assets/iconTipped.svg';
import IconTipUser from '../assets/iconTipUser.svg?icon-component';
import IconTip from '../assets/iconTipRebranded.svg?icon-component';
import Backend from '../utils/backend';
import { EventBus } from '../utils/eventBus';
import { createDeepLinkUrl, shiftDecimalPlaces } from '../utils';
Expand All @@ -94,6 +98,8 @@ export default {
AeAmountFiat,
Modal,
Dropdown,
IconTip,
IconTipUser,
},
props: {
tip: { type: Object, default: null },
Expand Down Expand Up @@ -142,29 +148,37 @@ export default {
};
},
v1TipWarning() {
return this.tip && this.tip.id.split('_')[1] === 'v1' && this.inputToken !== null;
return (
this.tip
&& this.tip.id.split('_')[1] === 'v1'
&& this.inputToken !== null
);
},
tipUrl() {
if (this.comment) {
return `https://superhero.com/tip/${this.comment.tipId}/comment/${this.comment.id}`;
}
if (this.userAddress) {
const { href } = this.$router.resolve({ name: 'user-profile', params: { address: this.userAddress } });
const { href } = this.$router.resolve({
name: 'user-profile',
params: { address: this.userAddress },
});
return `https://superhero.com${href}`;
}
return this.tip.url;
},
deepLink() {
return createDeepLinkUrl(this.tip
? { type: 'retip', id: this.tip.id } : { type: 'tip', url: this.tipUrl });
return createDeepLinkUrl(
this.tip
? { type: 'retip', id: this.tip.id }
: { type: 'tip', url: this.tipUrl },
);
},
isValid() {
return (this.tip || this.message.trim().length > 0)
&& (this.inputToken !== null || this.inputValue > this.minTipAmount);
},
iconTip() {
if (this.userAddress) return iconTipUser;
return this.tipUrlStats.isTipped ? iconTipped : iconTip;
return (
(this.tip || this.message.trim().length > 0)
&& (this.inputToken !== null || this.inputValue > this.minTipAmount)
);
},
title() {
if (this.userAddress) return this.$t('components.TipInput.tipUser');
Expand All @@ -179,8 +193,12 @@ export default {
if (!this.isValid) return;
this.showLoading = true;
try {
const amount = shiftDecimalPlaces(this.inputValue,
this.inputToken !== null ? this.tokenInfo[this.inputToken].decimals : 18).toFixed();
const amount = shiftDecimalPlaces(
this.inputValue,
this.inputToken !== null
? this.tokenInfo[this.inputToken].decimals
: 18,
).toFixed();
if (!this.tip) {
await this.$store.dispatch('aeternity/tip', {
Expand Down Expand Up @@ -284,5 +302,31 @@ export default {
}
}
}
.iconTipRebranded {
width: 24px;
height: 24px;
opacity: 0.44;
path.inner {
opacity: 0.44;
}
&:hover {
opacity: 1;
}
&.tipped {
opacity: 1;
&:hover path {
fill: #0e52d8;
}
path {
fill: $secondary_color;
}
}
}
}
</style>

0 comments on commit 5edb21a

Please sign in to comment.