Merge pull request #211 from 67P/feature/expense-list

Expense list UI improvements
This commit was merged in pull request #211.
This commit is contained in:
Râu Cao
2023-01-15 12:35:17 +08:00
committed by GitHub
9 changed files with 110 additions and 68 deletions
+4 -20
View File
@@ -44,26 +44,10 @@
<h3>Expense items</h3> <h3>Expense items</h3>
{{#if this.expenses}} {{#if this.expenses}}
<ul class="expense-list"> <ExpenseList @expenses={{this.expenses}}
{{#each this.expenses as |expense|}} @removeExpenseItem={{this.removeExpenseItem}}
<li> @deletable={{true}} />
<div class="description" rowspan="2">
<h4>
<span class="date">{{expense.date}}:</span>
<span class="title">{{expense.title}}</span>
</h4>
<p class="description">{{expense.description}}</p>
</div>
<div class="amount">
{{fmt-fiat-currency expense.amount expense.currency}}
</div>
<div class="actions">
<button {{on "click" (fn this.removeExpenseItem expense)}}
class="danger small" type="button">delete</button>
</div>
</li>
{{/each}}
</ul>
<p class="actions"> <p class="actions">
<button {{on "click" this.showExpenseForm}} <button {{on "click" this.showExpenseForm}}
class="green small" type="button">+ Add another item</button> class="green small" type="button">+ Add another item</button>
+9
View File
@@ -0,0 +1,9 @@
import Component from '@glimmer/component';
export default class ExpenseListComponent extends Component {
get showDeleteButton () {
return !!this.args.deletable;
}
}
+29
View File
@@ -0,0 +1,29 @@
<ul class="expense-list">
{{#each @expenses as |expense|}}
<li class="expense-item">
<h4>
<span class="date">{{fmt-date-localized expense.date}}:</span>
<span class="title">{{expense.title}}</span>
</h4>
<div class="amount">
{{fmt-fiat-currency expense.amount expense.currency}}
</div>
<p class="description">
{{expense.description}}
</p>
<p class="tags">
{{#each expense.tags as |tag|}}
<button class="small yellow" role="none">
<IconTag />{{tag}}
</button>
{{/each}}
</p>
{{#if this.showDeleteButton}}
<div class="actions">
<button {{on "click" (fn @removeExpenseItem expense)}}
class="danger small" type="button">delete</button>
</div>
{{/if}}
</li>
{{/each}}
</ul>
+3 -16
View File
@@ -14,22 +14,9 @@
<span class="amount"> <span class="amount">
{{sats-to-btc reimbursement.amount}}</span>&#8239;<span class="symbol">BTC</span> {{sats-to-btc reimbursement.amount}}</span>&#8239;<span class="symbol">BTC</span>
</p> </p>
<ul class="expense-list">
{{#each reimbursement.expenses as |expense|}} <ExpenseList @expenses={{reimbursement.expenses}} />
<li>
<div class="description" rowspan="2">
<h4>
<span class="date">{{expense.date}}:</span>
<span class="title">{{expense.title}}</span>
</h4>
<p class="description">{{expense.description}}</p>
</div>
<div class="amount">
{{fmt-fiat-currency expense.amount expense.currency}}
</div>
</li>
{{/each}}
</ul>
<div class="meta"> <div class="meta">
<p class="confirmation-eta"> <p class="confirmation-eta">
<ConfirmedIn @confirmedAtBlock={{reimbursement.confirmedAt}} /> <ConfirmedIn @confirmedAtBlock={{reimbursement.confirmedAt}} />
+8
View File
@@ -0,0 +1,8 @@
import { helper } from '@ember/component/helper';
import getLocale from 'kredits-web/utils/get-locale';
export default helper(function(dateStr) {
const date = new Date(dateStr);
const locale = getLocale();
return new Intl.DateTimeFormat(locale).format(date);
});
+32 -11
View File
@@ -31,32 +31,53 @@ button, input[type=submit], .button {
&.small { &.small {
font-size: 0.86rem; font-size: 0.86rem;
padding: 0.2rem 0.8rem; padding: 0.2rem 0.8rem;
svg {
width: 1em;
height: 1em;
vertical-align: middle;
margin-right: 0.4rem;
}
} }
&.danger:not(:disabled) { &.danger:not(:disabled) {
color: $red; color: $red;
background-color: rgba(40, 21, 21, 0.6); background-color: rgba(40, 21, 21, 0.6);
border-color: rgba(40, 21, 21, 1); border-color: rgba(40, 21, 21, 1);
&:hover { background-color: rgba(40, 21, 21, 0.8); }
&:hover { &:focus, &:active, &.active { border-color: $red; }
background-color: rgba(40, 21, 21, 0.8);
}
&:focus, &:active, &.active {
border-color: $red;
}
} }
&.green:not(:disabled) { &.green:not(:disabled) {
color: $green; color: $green;
background-color: rgba(21, 40, 21, 0.6); background-color: rgba(21, 40, 21, 0.6);
border-color: rgba(21, 40, 21, 1); border-color: rgba(21, 40, 21, 1);
&:hover { background-color: rgba(21, 40, 21, 0.8); }
&:focus, &:active, &.active { border-color: $green; }
}
&:hover { &.pink:not(:disabled) {
background-color: rgba(21, 40, 21, 0.8); color: $pink;
background-color: rgba(40, 21, 40, 0.6);
border-color: rgba(40, 21, 40, 1);
&:hover { background-color: rgba(40, 21, 40, 0.8); }
&:focus, &:active, &.active { border-color: $pink; }
} }
&:focus, &:active, &.active {
border-color: $green; &.purple:not(:disabled) {
color: $purple;
background-color: rgba(24, 21, 40, 0.6);
border-color: rgba(24, 21, 40, 1);
&:hover { background-color: rgba(24, 21, 40, 0.8); }
&:focus, &:active, &.active { border-color: $purple; }
} }
&.yellow:not(:disabled) {
color: $yellow;
background-color: rgba(40, 40, 21, 0.6);
border-color: rgba(40, 40, 21, 1);
&:hover { background-color: rgba(40, 40, 21, 0.8); }
&:focus, &:active, &.active { border-color: $yellow; }
} }
&.icon { &.icon {
+15 -17
View File
@@ -17,32 +17,30 @@ ul.expense-list {
} }
} }
.description {
grid-row-start: 1;
grid-row-end: 3;
}
.amount {
justify-self: end;
// font-weight: normal;
}
.actions {
justify-self: end;
}
h4 { h4 {
font-size: 1.2rem; font-size: 1.2rem;
font-weight: normal; font-weight: normal;
line-height: 2rem; line-height: 2rem;
} }
p { .amount {
line-height: 2rem; justify-self: end;
}
&.description { .description {
font-size: 1rem; font-size: 1rem;
opacity: 0.7; opacity: 0.7;
grid-column-start: span 2;
}
.tags {
button {
margin-left: 0;
} }
} }
.actions {
justify-self: end;
}
} }
+1
View File
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-tag"><path d="M20.59 13.41l-7.17 7.17a2 2 0 0 1-2.83 0L2 12V2h10l8.59 8.59a2 2 0 0 1 0 2.82z"></path><line x1="7" y1="7" x2="7.01" y2="7"></line></svg>

After

Width:  |  Height:  |  Size: 355 B

+5
View File
@@ -0,0 +1,5 @@
export default function() {
return (navigator.languages && navigator.languages.length) ?
navigator.languages[0] :
navigator.language;
}