Skip to content

Commit

Permalink
Contributions page creation (#480)
Browse files Browse the repository at this point in the history
* Contributions - Mount basic ldefault layout

* Contributions - Add nonmonetary method input

* Contributions - Refine list of contributions

* Contributions - Style input to add nonmonetary

* Contributions -NonMonetary ui logic

* revert ListItem.vue

* Contributions - start DRYing contribution component

* Contributions - extract Contribution UI logic from view

* Contributions - Add some comments, adjust pixels and randomize placeholder

* Contributions - updates based on code review

* Contributions - updates based on code review

* Contributions - fix bug on contribution with keyboard enter on edit button to input

* fix #481 improve currencies.js

* Contributions - improve props/conditions readability

* Contributions - refactor i18n to treceiving contribution text
  • Loading branch information
sandrina-p authored and taoeffect committed Sep 7, 2018
1 parent 2e12fc8 commit 2950dab
Show file tree
Hide file tree
Showing 14 changed files with 524 additions and 15 deletions.
11 changes: 11 additions & 0 deletions frontend/simple/assets/sass/_groupincome.scss
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,15 @@ body {
color: $link-hover;
}
}

&is-link-inherit {
color: inherit;
cursor: pointer;
text-decoration: underline;

&:hover,
&:focus {
color: $link;
}
}
}
26 changes: 25 additions & 1 deletion frontend/simple/assets/sass/bulma_overrides/elements/box.scss
Original file line number Diff line number Diff line change
@@ -1,8 +1,32 @@
$box-shadow: none;
$box-radius: $radius;
$box-padding: $gi-spacer;
$box-shadow: none;

@import "../../node_modules/bulma/sass/elements/box";

$gi-compact-spacer: $gi-spacer*0.75;

.box {
border: 1px solid $grey-lighter;

&.is-compact {
padding: $gi-compact-spacer $gi-spacer;
margin-bottom: $gi-compact-spacer;
}

&.is-unfilled {
border: 1px dashed $primary;
}

&.has-controls {
display: flex;
justify-content: space-between;
// To makeup for the square buttons height inside
padding: 0 $gi-spacer-sm 0 0;
align-items: center;

.box-body {
padding: $gi-compact-spacer $gi-spacer;
}
}
}
55 changes: 55 additions & 0 deletions frontend/simple/assets/sass/bulma_overrides/elements/form.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
$input-border-color: $grey-light;
$input-hover-border-color: $grey;
$input-shadow: none;
$input-focus-box-shadow-size: 0 0 0 0.1em inset;

@import "../../node_modules/bulma/sass/elements/form";

.input {
Expand All @@ -6,6 +11,56 @@
}
}

.field.gi-has-addons {
.button {
position: relative;
border-color: $input-border-color;
border-width: 1px 0 1px 0;
border-radius: 0;
padding: 0 $gi-spacer-sm;

// Hide box-shadow between input and first button during :focus
&::before {
content: "";
position: absolute;
width: 6px;
background-color: $input-background-color;
top: 2px;
left: -3px;
height: calc(100% - 4px);
}

&:last-of-type {
border-radius: 0 $radius $radius 0;
border-right-width: 1px;
padding-right: $gi-spacer;
}

&:hover,
&:focus {
color: $text !important; // overide has-text-* class
}
}

.input {
height: auto;
padding-left: $gi-spacer;
padding-right: $gi-spacer;
border-right: 0;
border-top-right-radius: 0;
border-bottom-right-radius: 0;

&:hover ~ .button {
border-color: $input-hover-border-color;
}

&:focus ~ .button {
border-color: $primary;
box-shadow: $input-focus-box-shadow-size $input-focus-box-shadow-color;
}
}
}

.gi- {
&is-grouped-reverse {
flex-direction: row-reverse;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ $gap: 16px;
$strong-color: inherit;

$grey: hsl(0, 0%, 60%);
$grey-dark: hsl(0, 0%, 39%) // In between $grey (60%) and $grey-darker (21%)
$grey-dark: hsl(0, 0%, 39%); // In between $grey (60%) and $grey-darker (21%)
$white-ter: #f4f4f4;
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
$size-6: 0.875rem; // 14px
$size-5: 1.125rem; // 18px

@import "../../node_modules/bulma/sass/utilities/initial-variables";
@import "../../node_modules/bulma/sass/utilities/functions";

Expand Down Expand Up @@ -36,6 +39,3 @@ $body-family: $family-sans-serif;

$body-background-color: #fff;
$text: $grey-darker;

$size-6: 0.875rem; // 14px
$size-5: 1.125rem; // 18px
9 changes: 9 additions & 0 deletions frontend/simple/controller/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
GroupInvitees,
GroupSummary
} from '../views/components/CreateGroupSteps'
import Contributions from '../views/Contributions.vue'
import DesignSystem from '../views/DesignSystem.vue'
import GroupDashboard from '../views/GroupDashboard.vue'
import Home from '../views/Home.vue'
Expand Down Expand Up @@ -173,6 +174,14 @@ var router = new Router({
title: 'Your Group'
}
},
{
path: '/contributions',
component: Contributions,
meta: {
title: 'Contributions'
},
beforeEnter: createEnterGuards(loginGuard)
},
{
path: '/pay-group',
component: PayGroup,
Expand Down
199 changes: 199 additions & 0 deletions frontend/simple/views/Contributions.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
<template>
<main>
<div class="section is-hero">
<i18n tag="h1" class="title is-1 is-marginless">
Contributions
</i18n>
<i18n tag="p">See everyone’s contributions to the group and manage yours.</i18n>
</div>

<div class="section columns is-desktop is-multiline c-grid">
<section class="column">
<i18n tag="h2" class="title is-3">Receiving</i18n>

<ul class="c-ul">
<contribution
v-for="contribution, index in receiving"
:variant="isMonetary(contribution.type) ? 'editable' : undefined"
:isMonetary="isMonetary(contribution.type)"
@interaction="showReceivingSettings"
>
<span v-html="textReceivingContribution(contribution, index)"></span>
<template v-if="hasWhoElse(contribution.who)">
<i18n>and</i18n>
<tooltip>
<button class="gi-is-unstyled gi-is-link-inherit">{{contribution.who.length - 1}}<i18n>others</i18n></button>
<template slot="tooltip">
<p v-for="name, index in contribution.who" v-if="index > 0">{{name}}</p>
</template>
</tooltip>
</template>
</contribution>
</ul>
</section>

<section class="column">
<i18n tag="h2" class="title is-3">Giving</i18n>

<ul class="c-ul" v-if="givesNonMonetary || givesMonetary">
<contribution v-for="contribution, index in giving.nonMonetary"
class="has-text-weight-bold"
variant="editable"
@new-value="(value) => handleEditNonMonetary(value, index)"
>{{contribution}}</contribution>

<contribution v-if="givesMonetary"
variant="editable"
isMonetary
@interaction="showGivingMincomeSettings"
>
<span class="has-text-weight-bold">{{currency}}{{giving.monetary}}</span> <i18n>to other's mincome</i18n>
</contribution>
</ul>

<ul class="c-ul">
<contribution variant="unfilled" @new-value="submitAddNonMonetary">
<i class="fa fa-heart c-contribution-icon" aria-hidden="true"></i>
<i18n>Add a non-monetary method</i18n>
</contribution>

<contribution v-if="!givesMonetary" variant="unfilled" isMonetary @interaction="addMonetaryMethod">
<i class="fa fa-money c-contribution-icon" aria-hidden="true"></i>
<i18n>Add a monetary method</i18n>
</contribution>
</ul>
</section>
</div>
</main>
</template>
<style lang="scss" scoped>
@import "../assets/sass/theme/index";
.c-grid .column {
@include touch {
padding-left: 0;
padding-right: 0;
}
@include desktop {
&:first-child {
padding-left: 0;
}
&:last-child {
padding-right: 0;
}
}
}
.c-ul {
margin: $gi-spacer*0.75 0;
}
</style>
<script>
import currencies from './utils/currencies.js'
import Contribution from './components/Contribution.vue'
import Tooltip from './components/Tooltip.vue'
export default {
name: 'Contributions',
components: {
Contribution,
Tooltip
},
data () {
return {
currency: currencies['USD'],
receiving: [
{
type: 'no-monetary',
what: 'Cooking',
who: 'Lilia Bouvet'
},
{
type: 'no-monetary',
what: 'Cuteness',
who: ['Zoe Kim', 'Laurence E']
},
{
type: 'monetary',
what: 500,
who: [
'Jack Fisher',
'Charlotte Doherty',
'Thomas Baker',
'Francisco Scott'
]
}
],
giving: {
nonMonetary: [], // ArrayOf(String)
monetary: null // Number
}
}
},
computed: {
givesMonetary () {
return !!this.giving.monetary
},
givesNonMonetary () {
return this.giving.nonMonetary.length > 0
}
},
methods: {
// Receiving
isMonetary (type) {
return type === 'monetary'
},
getWho (who) {
if (!Array.isArray(who)) {
return who
}
return who.length > 3 ? who[0] : this.L('{who0} and {who1}', { who0: who[0], who1: who[1] })
},
textReceivingContribution (contribution, index) {
const who = this.getWho(contribution.who)
if (this.isMonetary(contribution.type)) {
return this.L('<strong>{what} from mincome</strong> from {who}', {
what: `${this.currency}${this.receiving[index].what}`,
who
})
} else {
return this.L('<strong>{what}</strong> from {who}', { what: contribution.what, who })
}
},
hasWhoElse (who) {
return Array.isArray(who) && who.length > 3
},
showGivingMincomeSettings () {
console.log('TODO UI - Show Giving Mincome Setting - next PR')
},
showReceivingSettings () {
console.log('TODO UI - Show Receiving Setting - next PR')
},
// Giving
submitAddNonMonetary (value) {
console.log('TODO BE - submitAddNonMonetary')
this.giving.nonMonetary.push(value)
},
handleEditNonMonetary (value, index) {
if (!value) {
console.log('TODO BE - deleteNonMonetary')
this.giving.nonMonetary.splice(index, 1)
} else {
console.log('TODO BE - editNonMonetary')
// https://vuejs.org/v2/guide/list.html#Caveats
this.$set(this.giving.nonMonetary, index, value)
}
},
// Giving Monetary Methods:
addMonetaryMethod () {
console.log('TODO UI - Show Monetary Settings Modal - next PR')
}
}
}
</script>
4 changes: 2 additions & 2 deletions frontend/simple/views/PayGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@
import Avatar from './components/Avatar.vue'
import ProgressBar from './components/Graphs/Progress.vue'
import { toPercent } from './utils/filters.js'
import { symbol } from './utils/currencies.js'
import currencies from './utils/currencies.js'
import Tooltip from './components/Tooltip.vue'
export default {
Expand Down Expand Up @@ -254,7 +254,7 @@ export default {
amount: 50
}
],
currency: symbol('USD'),
currency: currencies['USD'],
admirations: {
types: [this.L('Awesome'), this.L('Cool'), this.L('Great'), this.L('Nice'), this.L('Super'), this.L('Sweet')],
users: { /* index: 'admiration' */ }
Expand Down
Loading

0 comments on commit 2950dab

Please sign in to comment.