Explorar el Código

:sparkles: polished SpiderChart component | introduced ProfileCardItem vs ProfileCard

tags/0.0.2
juancarbajal98 hace 3 años
padre
commit
ae111e6303

+ 3
- 0
frontend/src/components/ProfileCard.vue Ver fichero

@@ -27,6 +27,8 @@ w-card.profile-card-list--card.xs12.pa12
27 27
             v-if='!isPaired || isList'
28 28
         )
29 29
 
30
+    SpiderChart
31
+
30 32
     footer(v-if='!isList && !isPaired')
31 33
         .pa12
32 34
             p {{ card.summary.about.tab }}
@@ -46,6 +48,7 @@ import NamePlate from './NamePlate.vue'
46 48
 import AspectBar from './AspectBar.vue'
47 49
 import SummaryBar from './SummaryBar.vue'
48 50
 import TagList from './TagList.vue'
51
+import SpiderChart from './SpiderChart.vue'
49 52
 import PairingButton from './PairingButton.vue'
50 53
 
51 54
 const router = useRouter()

+ 109
- 0
frontend/src/components/ProfileCardItem.vue Ver fichero

@@ -0,0 +1,109 @@
1
+<template lang="pug">
2
+w-card.profile-card-list--card.xs12.pa12
3
+    header.xs12.w-flex.column.center
4
+        NamePlate(
5
+            :is-list='isList'
6
+            :is-paired='isPaired'
7
+            :name='card.name'
8
+            :pid='card.pid'
9
+            :pronouns='card.pronouns'
10
+            :role='card.role'
11
+        )
12
+
13
+        w-button.text-upper.xs12.pa6(v-if='isPaired && !isList')
14
+            w-icon.mr1(xl) mdi mdi-chat
15
+            | start chat
16
+
17
+        template(v-if='!isList')
18
+            SummaryBar(:is-tab='isPaired' :tab-content='card.summary')
19
+            TagList(v-if='!isPaired || isList')
20
+
21
+    article.xs12.w-flex.column.justify-space-between
22
+        AspectBar(
23
+            :key='aspect.name'
24
+            :labels='aspect.labels'
25
+            :percentage='aspect.percentage'
26
+            v-for='aspect in aspects'
27
+            v-if='!isPaired || isList'
28
+        )
29
+
30
+    footer(v-if='!isList && !isPaired')
31
+        .pa12
32
+            p {{ card.summary.about.tab }}
33
+        PairingButton(@pair='onPair' @pass='onPass' v-if='!isPaired')
34
+</template>
35
+
36
+<script setup>
37
+import { ref } from 'vue'
38
+import { useRouter } from 'vue-router'
39
+import {
40
+    updateQueueByProfileId,
41
+    postMembershipByProfileId,
42
+    currentProfile,
43
+} from '../services'
44
+
45
+import NamePlate from './NamePlate.vue'
46
+import AspectBar from './AspectBar.vue'
47
+import SummaryBar from './SummaryBar.vue'
48
+import TagList from './TagList.vue'
49
+import PairingButton from './PairingButton.vue'
50
+
51
+const router = useRouter()
52
+// const isPaired = ref(true)
53
+const isPaired = ref(false)
54
+
55
+const props = defineProps({
56
+    card: {
57
+        type: Object,
58
+        required: true,
59
+    },
60
+    aspects: {
61
+        type: Array,
62
+        required: true,
63
+    },
64
+    isList: {
65
+        type: Boolean,
66
+        required: false,
67
+        default: true,
68
+    },
69
+})
70
+
71
+/**
72
+ * Attempt to pair with target profile
73
+ * Creates a grouping, and a membership
74
+ * for both profileId and targetId
75
+ */
76
+const onPair = async () => {
77
+    const group = await postMembershipByProfileId({
78
+        profileId: currentProfile.id.value,
79
+        targetId: props.card.pid,
80
+    })
81
+    updateQueueByProfileId(currentProfile.id.value, props.card.pid, false)
82
+    currentProfile.getGroupings()
83
+    console.warn('created grouping:', group)
84
+
85
+    let goToRoute = { name: 'HomeView' }
86
+    // if (group.membershipMatch.hasMatch) {
87
+    //     goToRoute = { name: 'PairsView' }
88
+    // }
89
+    router.push(goToRoute)
90
+}
91
+
92
+/**
93
+ * Send to the back of the matchQueue
94
+ * and forward back home
95
+ */
96
+const onPass = async () => {
97
+    updateQueueByProfileId(currentProfile.id.value, props.card.pid, true)
98
+    router.push({ name: 'HomeView' })
99
+}
100
+</script>
101
+
102
+<style lang="sass">
103
+.profile-card-list--card
104
+    background-color: #000
105
+    color: #fff
106
+    header > .w-button
107
+        background-color: #116006
108
+        color: #fff
109
+</style>

+ 2
- 2
frontend/src/components/ProfileCardList.vue Ver fichero

@@ -4,7 +4,7 @@ section.profile-card-list.xs12.w-flex.column
4 4
         w-select(:items="['one', 'two', 'three']" outline) Label
5 5
     
6 6
     article
7
-        ProfileCard.match-layout(
7
+        ProfileCardItem.match-layout(
8 8
             v-for="(card, i) in cards"
9 9
             :key="`${card.pid}-${i}`"
10 10
             :card="card"
@@ -21,7 +21,7 @@ import {
21 21
     postMembershipByProfileId,
22 22
     currentProfile,
23 23
 } from '../services'
24
-import ProfileCard from './ProfileCard.vue'
24
+import ProfileCardItem from './ProfileCardItem.vue'
25 25
 
26 26
 class Aspect {
27 27
     constructor({ name, labels, percentage = 50 }) {

+ 45
- 23
frontend/src/components/SpiderChart.vue Ver fichero

@@ -1,6 +1,6 @@
1 1
 <template lang="pug">
2
-div
3
-    canvas(id='spiderChart')
2
+.spider-chart
3
+    canvas(id='spider-chart-canvas')
4 4
 </template>
5 5
 <script>
6 6
 import {Chart, registerables} from 'chart.js'
@@ -16,25 +16,19 @@ const data = {
16 16
         'Ordered'
17 17
     ],
18 18
     datasets:[{
19
-        label: 'First dataset',
19
+        label: 'Lucy',
20
+        data: [5.7,5.2,4.8,5.2,4.9,4.9],
20 21
         fill: true,
21
-        backgroundColor: 'rgb(255, 33, 33)',
22
-        borderColor: 'rgb(255, 99, 132)',
23
-        data: [1,2,3,4,5,6],
24
-        pointBackgroundColor: 'rgb(255, 99, 132)',
25
-        pointBorderColor: '#fff',
26
-        pointHoverBackgroundColor: '#fff',
27
-        pointHoverBorderColor: 'rgb(255, 99, 132)'
22
+        backgroundColor: 'rgba(242, 205, 92, 0.3)',
23
+        borderColor: '#F2CD5C',
24
+        borderWidth: '1px',
28 25
     }, {
29
-        label: 'My Second Dataset',
30
-        data: [6,5,4,3,2,1],
26
+        label: 'Role',
27
+        data: [5.3,4.8,5.7,4.8,5.6,4.8],
31 28
         fill: true,
32
-        backgroundColor: 'rgba(54, 162, 235, 0.2)',
33
-        borderColor: 'rgb(54, 162, 235)',
34
-        pointBackgroundColor: 'rgb(54, 162, 235)',
35
-        pointBorderColor: '#fff',
36
-        pointHoverBackgroundColor: '#fff',
37
-        pointHoverBorderColor: 'rgb(54, 162, 235)'
29
+        backgroundColor: 'rgba(3, 136, 166, 0.30)',
30
+        borderColor: '#0388A6',
31
+        borderWidth: '1px',
38 32
     }]
39 33
 }
40 34
 
@@ -42,9 +36,32 @@ const config = {
42 36
     type: 'radar',
43 37
     data: data,
44 38
     options: {
45
-        elements:{
46
-            line:{
47
-                borderWidth: 3
39
+        plugins:{
40
+            legend: {
41
+                position: 'bottom',
42
+                labels:{
43
+                    color: '#FFFFFF',
44
+                    boxWidth: 10,
45
+                }
46
+            },
47
+        },
48
+        scales:{
49
+            r:{
50
+                angleLines:{
51
+                    color: '#FFFFFF'
52
+                },
53
+                grid:{
54
+                    color: '#EAF0F4',
55
+                    lineWidth: 1,
56
+                },
57
+                pointLabels:{
58
+                    color: '#FFFFFF',
59
+                },
60
+                suggestedMax: 6,
61
+                ticks: {
62
+                    display: false,
63
+                    stepSize: 1.6,
64
+                },
48 65
             }
49 66
         }
50 67
     }
@@ -58,8 +75,13 @@ export default{
58 75
         }
59 76
     },
60 77
     mounted() {
61
-        const ctx = document.getElementById('spiderChart');
78
+        const ctx = document.getElementById('spider-chart-canvas');
62 79
         new Chart(ctx, this.spiderChartData);
63 80
     }
64 81
 }
65
-</script>
82
+</script>
83
+<style lang="sass">
84
+.spider-chart
85
+    display: flex
86
+    margin: 3vw auto
87
+</style>

+ 27
- 30
frontend/src/views/HomeView.vue Ver fichero

@@ -1,35 +1,34 @@
1 1
 <template lang="pug">
2
-SpiderChart
3
-//- main.view--home
4
-    //- article(v-if='cards.length && !loading')
5
-    //-     ProfileCardList(:pid='pid' :cards='cards' @reload='getCards')
2
+main.view--home
3
+    article(v-if='cards.length && !loading')
4
+        ProfileCardList(:pid='pid' :cards='cards' @reload='getCards')
6 5
 
7
-    //- p(v-else-if='cards.length === 0') No profiles in match_queue.
8
-    //- w-spinner(v-else bounce)
6
+    p(v-else-if='cards.length === 0') No profiles in match_queue.
7
+    w-spinner(v-else bounce)
9 8
 
10
-    //- footer
11
-    //-     w-form
12
-    //-         w-input.mb2(
13
-    //-             inner-icon-left='mdi mdi-account'
14
-    //-             label='Full Name'
15
-    //-             label-position='inside'
16
-    //-             outline
17
-    //-         )
18
-    //-         w-input.mb2(
19
-    //-             inner-icon-left='mdi mdi-mail'
20
-    //-             label='E-mail'
21
-    //-             label-position='inside'
22
-    //-             outline
23
-    //-         )
24
-    //-         w-input.mb2(
25
-    //-             inner-icon-left='mdi mdi-lock'
26
-    //-             label='Password'
27
-    //-             label-position='inside'
28
-    //-             outline
29
-    //-             type='password'
30
-    //-         )
9
+    footer
10
+        w-form
11
+            w-input.mb2(
12
+                inner-icon-left='mdi mdi-account'
13
+                label='Full Name'
14
+                label-position='inside'
15
+                outline
16
+            )
17
+            w-input.mb2(
18
+                inner-icon-left='mdi mdi-mail'
19
+                label='E-mail'
20
+                label-position='inside'
21
+                outline
22
+            )
23
+            w-input.mb2(
24
+                inner-icon-left='mdi mdi-lock'
25
+                label='Password'
26
+                label-position='inside'
27
+                outline
28
+                type='password'
29
+            )
31 30
 
32
-    //- MainNav
31
+    MainNav
33 32
 </template>
34 33
 
35 34
 <script>
@@ -39,7 +38,6 @@ import TagList from '../components/TagList.vue'
39 38
 import AspectBar from '../components/AspectBar.vue'
40 39
 import SummaryBar from '../components/SummaryBar.vue'
41 40
 import PairingButton from '../components/PairingButton.vue'
42
-import SpiderChart from '../components/SpiderChart.vue'
43 41
 
44 42
 import { Card } from '../entities'
45 43
 
@@ -87,7 +85,6 @@ export default {
87 85
         TagList,
88 86
         SummaryBar,
89 87
         PairingButton,
90
-        SpiderChart,
91 88
     },
92 89
     mixins: [mixins.pidMixin, mixins.cardMixin],
93 90
     methods: {

Loading…
Cancelar
Guardar