Use a view helper to remove branching from the bubbles controller
This commit is contained in:
@@ -4,8 +4,8 @@ import { signedDifferenceInDays } from "helpers/date_helpers"
|
||||
const REFRESH_INTERVAL = 3_600_000 // 1 hour (in milliseconds)
|
||||
|
||||
export default class extends Controller {
|
||||
static targets = [ "closingTop", "consideringTop", "days", "bottom" ]
|
||||
static values = { "closesAt": String, "reminderBefore": Number }
|
||||
static targets = [ "top", "days", "bottom" ]
|
||||
static values = { "closesAt": String, "reminderBefore": Number, "entropyAction": String }
|
||||
|
||||
#timer
|
||||
|
||||
@@ -26,12 +26,7 @@ export default class extends Controller {
|
||||
return
|
||||
}
|
||||
|
||||
if (this.hasClosingTopTarget) {
|
||||
this.closingTopTarget.innerHTML = closesInDays < 1 ? "Closes" : "Closes in"
|
||||
}
|
||||
if (this.hasConsideringTopTarget) {
|
||||
this.consideringTopTarget.innerHTML = closesInDays < 1 ? "Falls Back" : "Falls Back in"
|
||||
}
|
||||
this.topTarget.innerHTML = closesInDays < 1 ? this.entropyActionValue : `${this.entropyActionValue} in`
|
||||
this.daysTarget.innerHTML = closesInDays < 1 ? "!" : closesInDays
|
||||
this.bottomTarget.innerHTML = closesInDays < 1 ? "Today" : (closesInDays === 1 ? "day" : "days")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user