From 7038c31e55aa48ccbb92f3539e6af1da89189798 Mon Sep 17 00:00:00 2001 From: ponnexcodev Date: Fri, 1 Sep 2023 10:13:29 +0800 Subject: [PATCH 1/2] Duration fixes --- src/typescript/augments/duration-date.ts | 14 ++++++++++++++ .../sale-page/toniq-entrepot-sale-card.element.ts | 7 ++++--- .../toniq-entrepot-sale-category-card.element.ts | 7 ++++--- 3 files changed, 22 insertions(+), 6 deletions(-) create mode 100644 src/typescript/augments/duration-date.ts diff --git a/src/typescript/augments/duration-date.ts b/src/typescript/augments/duration-date.ts new file mode 100644 index 00000000..c514c08a --- /dev/null +++ b/src/typescript/augments/duration-date.ts @@ -0,0 +1,14 @@ +import moment from 'moment'; + +export function getDurationDate(date: number) { + const dateDuration: moment.Duration = moment.duration(moment(date).diff(moment())); + var days = parseInt(dateDuration.asDays().toFixed(2)); + var hours = parseInt(dateDuration.asHours().toFixed(2)) - days * 24; + var minutes = parseInt(dateDuration.asMinutes().toFixed(2)) - (days * 24 * 60 + hours * 60); + + return { + days, + hours, + minutes, + }; +} diff --git a/src/typescript/ui/elements/main-content-pages/sale-page/toniq-entrepot-sale-card.element.ts b/src/typescript/ui/elements/main-content-pages/sale-page/toniq-entrepot-sale-card.element.ts index 722fbbea..6e3f984a 100644 --- a/src/typescript/ui/elements/main-content-pages/sale-page/toniq-entrepot-sale-card.element.ts +++ b/src/typescript/ui/elements/main-content-pages/sale-page/toniq-entrepot-sale-card.element.ts @@ -11,7 +11,8 @@ import { } from '@toniq-labs/design-system'; import {BigNumber} from 'bignumber.js'; import {truncateNumber} from '@augment-vir/common'; -import moment, {duration} from 'moment'; +import moment from 'moment'; +import {getDurationDate} from '../../../../augments/duration-date'; type StatsArray = { title: string; @@ -266,8 +267,8 @@ export const EntrepotSaleCardElement = defineElement<{ function formattedDate(date: number) { if (moment(date).isBefore(moment())) return inputs.dateMessage ? inputs.dateMessage : 'Just Ended'; - const dateDuration: any = duration(moment(date).diff(moment())); - const {days, hours, minutes} = dateDuration._data; + const {days, hours, minutes} = getDurationDate(date); + return html` ${days} diff --git a/src/typescript/ui/elements/main-content-pages/sale-page/toniq-entrepot-sale-category-card.element.ts b/src/typescript/ui/elements/main-content-pages/sale-page/toniq-entrepot-sale-category-card.element.ts index b21db132..1364ac10 100644 --- a/src/typescript/ui/elements/main-content-pages/sale-page/toniq-entrepot-sale-category-card.element.ts +++ b/src/typescript/ui/elements/main-content-pages/sale-page/toniq-entrepot-sale-category-card.element.ts @@ -11,7 +11,8 @@ import { } from '@toniq-labs/design-system'; import {BigNumber} from 'bignumber.js'; import {truncateNumber} from '@augment-vir/common'; -import moment, {duration} from 'moment'; +import moment from 'moment'; +import {getDurationDate} from '../../../../augments/duration-date'; type StatsArray = { title: string; @@ -302,8 +303,8 @@ export const EntrepotSaleCategoryCardElement = defineElement<{ function formattedDate(date: number) { if (moment(date).isBefore(moment())) return inputs.dateMessage ? inputs.dateMessage : 'Just Ended'; - const dateDuration: any = duration(moment(date).diff(moment())); - const {days, hours, minutes} = dateDuration._data; + const {days, hours, minutes} = getDurationDate(date); + return html` ${days} From 08ed9d5813bdd8750845b92cc673741b326a8bf4 Mon Sep 17 00:00:00 2001 From: ponnexcodev Date: Fri, 1 Sep 2023 10:28:26 +0800 Subject: [PATCH 2/2] hover fix --- .../sale-page/toniq-entrepot-sale-card.element.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/typescript/ui/elements/main-content-pages/sale-page/toniq-entrepot-sale-card.element.ts b/src/typescript/ui/elements/main-content-pages/sale-page/toniq-entrepot-sale-card.element.ts index 6e3f984a..96bd260e 100644 --- a/src/typescript/ui/elements/main-content-pages/sale-page/toniq-entrepot-sale-card.element.ts +++ b/src/typescript/ui/elements/main-content-pages/sale-page/toniq-entrepot-sale-card.element.ts @@ -96,7 +96,7 @@ export const EntrepotSaleCardElement = defineElement<{ height: 100%; } - :host(:hover) { + .card-button:hover > .card-wrapper { border-color: ${toniqColors.pageInteraction.foregroundColor}; }