🎨 (Color) add contrast color

This commit is contained in:
Julien Calixte
2019-10-25 19:37:28 +02:00
parent 20a02ce294
commit e38637020d
10 changed files with 95 additions and 30 deletions

View File

@@ -6,7 +6,7 @@
>
<router-link
:class="{ 'is-primary': !account.color, 'is-white': account.color }"
:style="`color: ${findDarkValue(account.color)}`"
:style="`color: ${findContrastColor(account.color)}`"
:to="{ name: 'account', params: { id: account._id } }"
>{{ account.name }}</router-link
>
@@ -22,7 +22,7 @@
<script lang="ts">
import { Component, Prop, Vue } from 'vue-property-decorator'
import { findDarkValue } from '@/utils'
import { findContrastColor, findDarkValue } from '@/utils'
import bus, { SYNC } from '@/utils/bus-event'
import accountService from '@/services/AccountService'
import IAccount from '@/models/IAccount'
@@ -45,8 +45,8 @@ export default class AccountCard extends Vue {
)
}
public findDarkValue(color: string): string | null {
return findDarkValue(color)
public findContrastColor(color: string): string | null {
return findContrastColor(color)
}
public goToAccount(id: string): void {
@@ -59,7 +59,7 @@ export default class AccountCard extends Vue {
}
return {
backgroundColor: color,
color: this.findDarkValue(color)
color: this.findContrastColor(color)
}
}

View File

@@ -17,7 +17,7 @@
<script lang="ts">
import { Component, Prop, Vue } from 'vue-property-decorator'
import { Getter } from 'vuex-class'
import { findDarkValue } from '@/utils'
import { findContrastColor } from '@/utils'
import bus, { SYNC } from '@/utils/bus-event'
import accountService from '@/services/AccountService'
import IAccount from '@/models/IAccount'

View File

@@ -170,7 +170,7 @@ import transactionService from '@/services/TransactionService'
import formatDate from '@/utils/format-date'
import notif from '@/utils/notif'
import { money } from '@/utils/filters'
import { confirmation, alertMessage, findDarkValue } from '@/utils'
import { confirmation, alertMessage, findContrastColor } from '@/utils'
const today: Date = new Date()
@@ -302,7 +302,7 @@ export default class TransactionCreate extends Vue {
}
return {
backgroundColor: this.account.color,
color: findDarkValue(this.account.color) || 'black'
color: findContrastColor(this.account.color) || 'black'
}
}