Parcourir la source

:recycle: moving spidergraph to passions card | better chat button integration

tags/0.0.2
j il y a 3 ans
Parent
révision
bf67e5551c

+ 25
- 11
frontend/src/components/ProfileCard.vue Voir le fichier

@@ -1,5 +1,5 @@
1 1
 <template lang="pug">
2
-w-card.profile-card-list--card.xs12.pa12
2
+w-card.profile-card-list--card.xs12
3 3
     header.xs12.w-flex.column.center
4 4
         NamePlate(
5 5
             :is-list='isList'
@@ -10,12 +10,17 @@ w-card.profile-card-list--card.xs12.pa12
10 10
             :role='card.role'
11 11
         )
12 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 13
         template(v-if='!isList')
18
-            SummaryBar(:is-tab='isPaired' :tab-content='card.summary')
14
+            w-button.text-upper.xs12.pa6(v-if='currentTab == 0 && isPaired')
15
+                w-icon.mr1(xl) mdi mdi-chat
16
+                | start chat
17
+
18
+            SummaryBar(
19
+                :aspects='aspects'
20
+                :is-tab='isPaired'
21
+                :tab-content='card.summary'
22
+                @tab-change='onTab'
23
+            )
19 24
             TagList(v-if='!isPaired || isList')
20 25
 
21 26
     article.xs12.w-flex.column.justify-space-between
@@ -27,12 +32,13 @@ w-card.profile-card-list--card.xs12.pa12
27 32
             v-if='!isPaired || isList'
28 33
         )
29 34
 
30
-    SpiderChart
31
-
32
-    footer(v-if='!isList && !isPaired')
33
-        .pa12
35
+    footer
36
+        .pa12(v-if='!isPaired && !isList')
34 37
             p {{ card.summary.about.tab }}
35 38
         PairingButton(@pair='onPair' @pass='onPass' v-if='!isPaired')
39
+        w-button.text-upper.xs12.pa6(v-else-if='currentTab != 0')
40
+            w-icon.mr1(xl) mdi mdi-chat
41
+            | start chat
36 42
 </template>
37 43
 
38 44
 <script setup>
@@ -48,7 +54,6 @@ import NamePlate from './NamePlate.vue'
48 54
 import AspectBar from './AspectBar.vue'
49 55
 import SummaryBar from './SummaryBar.vue'
50 56
 import TagList from './TagList.vue'
51
-import SpiderChart from './SpiderChart.vue'
52 57
 import PairingButton from './PairingButton.vue'
53 58
 
54 59
 const router = useRouter()
@@ -71,6 +76,15 @@ const props = defineProps({
71 76
     },
72 77
 })
73 78
 
79
+/**
80
+ * Track tab state for conditional rendering
81
+ */
82
+const currentTab = ref(0)
83
+const onTab = tabIndex => {
84
+    if (currentTab.value == tabIndex) return
85
+    currentTab.value = tabIndex
86
+}
87
+
74 88
 /**
75 89
  * Attempt to pair with target profile
76 90
  * Creates a grouping, and a membership

+ 81
- 77
frontend/src/components/SpiderChart.vue Voir le fichier

@@ -1,87 +1,91 @@
1 1
 <template lang="pug">
2
-.spider-chart
3
-    canvas(id='spider-chart-canvas')
2
+.spider-chart.w-flex.pt6.pb6
3
+    canvas#spider-chart-canvas
4 4
 </template>
5
-<script>
6
-import {Chart, registerables} from 'chart.js'
7
-Chart.register(...registerables)
8 5
 
9
-const data = {
10
-    labels: [
11
-        'Resourceful',
12
-        'Improv',
13
-        'Dynamic',
14
-        'Precise',
15
-        'Methodical',
16
-        'Ordered'
17
-    ],
18
-    datasets:[{
19
-        label: 'Lucy',
20
-        data: [5.7,5.2,4.8,5.2,4.9,4.9],
21
-        fill: true,
22
-        backgroundColor: 'rgba(242, 205, 92, 0.3)',
23
-        borderColor: '#F2CD5C',
24
-        borderWidth: '1px',
25
-    }, {
26
-        label: 'Role',
27
-        data: [5.3,4.8,5.7,4.8,5.6,4.8],
28
-        fill: true,
29
-        backgroundColor: 'rgba(3, 136, 166, 0.30)',
30
-        borderColor: '#0388A6',
31
-        borderWidth: '1px',
32
-    }]
6
+<script setup>
7
+import { Chart, registerables } from 'chart.js'
8
+import { onMounted } from 'vue'
9
+
10
+const props = defineProps({
11
+    profileName: {
12
+        required: true,
13
+        type: String,
14
+    },
15
+    profileData: {
16
+        required: true,
17
+        type: Object,
18
+    },
19
+    roleData: {
20
+        required: true,
21
+        type: Object,
22
+    },
23
+    labels: {
24
+        required: true,
25
+        type: Array,
26
+    },
27
+})
28
+
29
+const chartStyleDefaults = {
30
+    borderWidth: '1px',
31
+    fill: true,
32
+}
33
+const profile = {
34
+    label: props.profileName,
35
+    data: props.profileData,
36
+    backgroundColor: 'rgba(242, 205, 92, 0.3)',
37
+    borderColor: '#F2CD5C',
38
+    ...chartStyleDefaults,
39
+}
40
+const role = {
41
+    label: 'Role',
42
+    data: props.roleData,
43
+    backgroundColor: 'rgba(3, 136, 166, 0.30)',
44
+    borderColor: '#0388A6',
45
+    ...chartStyleDefaults,
33 46
 }
34 47
 
35
-const config = {
36
-    type: 'radar',
37
-    data: data,
38
-    options: {
39
-        plugins:{
40
-            legend: {
41
-                position: 'bottom',
42
-                labels:{
43
-                    color: '#FFFFFF',
44
-                    boxWidth: 10,
45
-                }
48
+const options = {
49
+    plugins: {
50
+        legend: {
51
+            position: 'bottom',
52
+            labels: {
53
+                color: '#FFFFFF',
54
+                boxWidth: 10,
55
+            },
56
+        },
57
+    },
58
+    scales: {
59
+        r: {
60
+            angleLines: {
61
+                color: '#FFFFFF',
62
+            },
63
+            grid: {
64
+                color: '#EAF0F4',
65
+                lineWidth: 1,
66
+            },
67
+            pointLabels: {
68
+                color: '#FFFFFF',
69
+            },
70
+            suggestedMax: 6,
71
+            ticks: {
72
+                display: false,
73
+                stepSize: 1.6,
46 74
             },
47 75
         },
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
-                },
65
-            }
66
-        }
67
-    }
68
-}
69
-
70
-export default{
71
-    name:'SpiderChart',
72
-    data(){
73
-        return {
74
-            spiderChartData:config
75
-        }
76 76
     },
77
-    mounted() {
78
-        const ctx = document.getElementById('spider-chart-canvas');
79
-        new Chart(ctx, this.spiderChartData);
80
-    }
81 77
 }
78
+
79
+onMounted(() => {
80
+    Chart.register(...registerables)
81
+    const ctx = document.getElementById('spider-chart-canvas')
82
+    new Chart(ctx, {
83
+        type: 'radar',
84
+        data: {
85
+            labels: props.labels,
86
+            datasets: [profile, role],
87
+        },
88
+        options,
89
+    })
90
+})
82 91
 </script>
83
-<style lang="sass">
84
-.spider-chart
85
-    display: flex
86
-    margin: 3vw auto
87
-</style>

+ 40
- 12
frontend/src/components/SummaryBar.vue Voir le fichier

@@ -1,51 +1,73 @@
1 1
 <template lang="pug">
2 2
 section.w-flex.column.pb5
3 3
     nav.fill-width.w-flex.column.justify-space-between
4
-
5 4
         // Tabbed Layout
6
-        w-tabs(v-if="isTab" :items="Object.keys(tabContent)" center fill-bar)
7
-            template(#item-title="{ item }")
5
+        w-tabs(
6
+            :items='Object.keys(tabContent)'
7
+            @input='onTabChanged'
8
+            center
9
+            fill-bar
10
+            v-if='isTab'
11
+        )
12
+            template(#item-title='{ item }')
8 13
                 .w-flex.column.justify-start
9
-                    p(v-if="tabContent[item].matchPerc") {{ tabContent[item].matchPerc }}%
14
+                    p(v-if='tabContent[item].matchPerc') {{ tabContent[item].matchPerc }}%
10 15
                     p(v-else) &nbsp;
11 16
                     p {{ item }}
12 17
             // About Tab
13
-            template(#item-content.1="{ item }")
18
+            template(#item-content.1='{ item }')
14 19
                 .tab--about
15 20
                     p {{ tabContent[item].tab }}
16 21
                     br
17 22
                     p {{ tabContent[item].tab }}
18 23
                     br
19 24
                     hr
20
-            
25
+
21 26
             // Passion Tab
22
-            template(#item-content.2="{ item }")
27
+            template(#item-content.2='{ item }')
23 28
                 .tab--passion
24 29
                     p {{ tabContent[item].tab }}
30
+                    SpiderChart(
31
+                        :labels='aspects.map(label => label.name)'
32
+                        :profile-data='[5.7, 5.2, 4.8, 5.2, 4.9, 4.9]'
33
+                        :role-data='[5.3, 4.8, 5.7, 4.8, 5.6, 4.8]'
34
+                        profile-name='lucy'
35
+                        v-if='isTab'
36
+                    )
25 37
 
26 38
             // Aspirations Tab
27
-            template(#item-content.3="{ item }")
39
+            template(#item-content.3='{ item }')
28 40
                 .tab--aspirations
29 41
                     p {{ tabContent[item].tab }}
30 42
 
31 43
             // Skills Tab
32
-            template(#item-content.4="{ item }")
44
+            template(#item-content.4='{ item }')
33 45
                 .tab--skills
34 46
                     p {{ tabContent[item].tab }}
35 47
 
36 48
         // Untabbed Layout
37 49
         ul.w-flex.row.justify-space-between(v-else)
38
-            template(v-for="(item, index) in Object.keys(tabContent)" :key="index")
39
-                li.w-flex.row(v-if="item !== 'about'")
40
-                    w-icon(xl).mr1 mdi mdi-heart
50
+            template(
51
+                :key='index'
52
+                v-for='(item, index) in Object.keys(tabContent)'
53
+            )
54
+                li.w-flex.row(v-if='item !== "about"')
55
+                    w-icon.mr1(xl) mdi mdi-heart
41 56
                     .w-flex.column.justify-start
42 57
                         p {{ tabContent[item].matchPerc }}%
43 58
                         p {{ item }}
44 59
 </template>
45 60
 
46 61
 <script>
62
+import SpiderChart from './SpiderChart.vue'
63
+
47 64
 export default {
65
+    components: { SpiderChart },
48 66
     props: {
67
+        aspects: {
68
+            required: true,
69
+            type: Array,
70
+        },
49 71
         tabContent: {
50 72
             required: true,
51 73
             type: Object,
@@ -61,5 +83,11 @@ export default {
61 83
             default: true,
62 84
         },
63 85
     },
86
+    emits: ['tab-change'],
87
+    methods: {
88
+        onTabChanged(tabs) {
89
+            this.$emit('tab-change', tabs)
90
+        },
91
+    },
64 92
 }
65 93
 </script>

Chargement…
Annuler
Enregistrer