🎨 (account card) add gradient
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
<div
|
||||
class="account-card box"
|
||||
:style="getColor(account.color)"
|
||||
@click="goToAccount(account._id)"
|
||||
@click="goToAccount(account._id || '')"
|
||||
>
|
||||
<router-link
|
||||
:class="{ 'is-primary': !account.color, 'is-white': account.color }"
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { Component, Prop, Vue } from 'vue-property-decorator'
|
||||
import { findContrastColor, findDarkValue } from '@/utils'
|
||||
import { findContrastColor, findDarkValue, findSlightLightValue } from '@/utils'
|
||||
import bus, { SYNC } from '@/utils/bus-event'
|
||||
import accountService from '@/services/AccountService'
|
||||
import IAccount from '@/models/IAccount'
|
||||
@@ -33,6 +33,8 @@ import transactionService from '../services/TransactionService'
|
||||
import TransactionType from '../enums/TransactionType'
|
||||
import colors from '../data/colors'
|
||||
|
||||
const GRADIENT = true
|
||||
|
||||
@Component
|
||||
export default class AccountCard extends Vue {
|
||||
@Prop({ type: Object, required: true })
|
||||
@@ -57,8 +59,11 @@ export default class AccountCard extends Vue {
|
||||
if (!color) {
|
||||
return null
|
||||
}
|
||||
|
||||
return {
|
||||
backgroundColor: color,
|
||||
background: GRADIENT
|
||||
? `linear-gradient(45deg, ${color}, ${findSlightLightValue(color)})`
|
||||
: color,
|
||||
color: this.findContrastColor(color)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,10 +74,12 @@ export default [
|
||||
(color: IColor): IColor => {
|
||||
const darkValue = lightness(color.value, dark).toLowerCase()
|
||||
const lightValue = lightness(color.value, light).toLowerCase()
|
||||
const slightLightValue = lightness(color.value, 10).toLowerCase()
|
||||
return {
|
||||
...color,
|
||||
darkValue,
|
||||
lightValue,
|
||||
slightLightValue,
|
||||
constrastColor:
|
||||
fontColorContrast(color.value) === '#000000' ? darkValue : lightValue
|
||||
}
|
||||
|
||||
@@ -3,5 +3,6 @@ export default interface IColor {
|
||||
value: string | null
|
||||
darkValue?: string | null
|
||||
lightValue?: string | null
|
||||
slightLightValue?: string | null
|
||||
constrastColor?: string | null
|
||||
}
|
||||
|
||||
@@ -70,6 +70,16 @@ export const findLightValue = (value: string): string | null => {
|
||||
return find && find.lightValue ? find.lightValue : null
|
||||
}
|
||||
|
||||
export const findSlightLightValue = (value: string): string | null => {
|
||||
if (!value) {
|
||||
return null
|
||||
}
|
||||
const find: IColor | undefined = colors.find(
|
||||
(color: IColor) => color.value === value
|
||||
)
|
||||
return find && find.slightLightValue ? find.slightLightValue : null
|
||||
}
|
||||
|
||||
export const toHex = (text: string): string => {
|
||||
return (
|
||||
[...text]
|
||||
|
||||
Reference in New Issue
Block a user