style: more colors.

This commit is contained in:
Julien Calixte
2019-08-23 10:41:40 +02:00
parent 93a17d4ef5
commit 6cb70d91ae
7 changed files with 49 additions and 6 deletions

View File

@@ -1,5 +1,5 @@
<template> <template>
<article class="account-share message is-success is-medium" v-if="show && user"> <article class="account-share message is-success is-medium" v-if="show">
<div class="message-header"> <div class="message-header">
<p>Partagez le compte</p> <p>Partagez le compte</p>
<button class="delete" v-if="canClose" aria-label="close" @click="hide"></button> <button class="delete" v-if="canClose" aria-label="close" @click="hide"></button>

View File

@@ -148,7 +148,7 @@
</div> </div>
</div> </div>
</div> </div>
<fab-button @valid="submitTransaction" :margin="true"> <fab-button @valid="submitTransaction" :margin="true" :button-style="backgroundColor">
<awe-icon icon="check" /> <awe-icon icon="check" />
</fab-button> </fab-button>
</div> </div>
@@ -170,7 +170,7 @@ import transactionService from '@/services/TransactionService'
import formatDate from '@/utils/format-date' import formatDate from '@/utils/format-date'
import notif from '@/utils/notif' import notif from '@/utils/notif'
import { money } from '@/utils/filters' import { money } from '@/utils/filters'
import { confirmation, alertMessage } from '@/utils' import { confirmation, alertMessage, findDarkValue } from '@/utils'
const today: Date = new Date() const today: Date = new Date()
@@ -296,6 +296,16 @@ export default class TransactionCreate extends Vue {
return this.payFor.filter((p, index) => p.weight > 0) return this.payFor.filter((p, index) => p.weight > 0)
} }
public get backgroundColor(): any | null {
if (!this.account || !this.account.color) {
return null
}
return {
backgroundColor: this.account.color,
color: findDarkValue(this.account.color) || 'black'
}
}
@Watch('payBy') @Watch('payBy')
public onPayByChange(payBy: string, oldPayBy: string) { public onPayByChange(payBy: string, oldPayBy: string) {
if ( if (

View File

@@ -2,6 +2,7 @@ import IColor from '@/models/IColor'
import lightness from 'lightness' import lightness from 'lightness'
const dark = -70 const dark = -70
const light = dark * -1
export default [ export default [
{ {
@@ -47,10 +48,31 @@ export default [
{ {
label: 'Rouge sombre pastel', label: 'Rouge sombre pastel',
value: '#c03b22' value: '#c03b22'
},
{
label: `Perle d'eau`,
value: '#76c5bf'
},
{
label: 'Expresso',
value: '#ab7642'
},
{
label: 'Menthe',
value: '#b3ffe1'
},
{
label: 'Neige',
value: '#fff6f6'
},
{
label: 'Rose lavande',
value: '#eea1eb'
} }
].map( ].map(
(color: IColor): IColor => ({ (color: IColor): IColor => ({
...color, ...color,
darkValue: lightness(color.value, dark).toLowerCase() darkValue: lightness(color.value, dark).toLowerCase(),
lightValue: lightness(color.value, light).toLowerCase()
}) })
) )

View File

@@ -2,4 +2,5 @@ export default interface IColor {
label: string | null label: string | null
value: string | null value: string | null
darkValue?: string | null darkValue?: string | null
lightValue?: string | null
} }

View File

@@ -50,6 +50,16 @@ export const findDarkValue = (value: string): string | null => {
return find && find.darkValue ? find.darkValue : null return find && find.darkValue ? find.darkValue : null
} }
export const findLightValue = (value: string): string | null => {
if (!value) {
return null
}
const find: IColor | undefined = colors.find(
(color: IColor) => color.value === value
)
return find && find.lightValue ? find.lightValue : null
}
export const toHex = (text: string): string => { export const toHex = (text: string): string => {
return ( return (
[...text] [...text]

View File

@@ -133,7 +133,7 @@ export default class AccountNew extends Vue {
user.alias ? user.alias.toLowerCase() : '' user.alias ? user.alias.toLowerCase() : ''
) )
if (aliases.length === 0) { if (aliases.length === 0) {
notif.alert('Au moins une personne doit être créée.') notif.alert('Au moins une personne doit être ajoutée au compte.')
return false return false
} }
if (aliases.length !== new Set(aliases).size) { if (aliases.length !== new Set(aliases).size) {

View File

@@ -42,7 +42,7 @@
<account-share :account="account" :can-close="false" /> <account-share :account="account" :can-close="false" />
</div> </div>
<div class="column is-one-third"> <div class="column is-one-third">
<article class="message is-primary"> <article class="message is-primary is-medium">
<div class="message-header"> <div class="message-header">
<p>Actions</p> <p>Actions</p>
</div> </div>