Преглед на файлове

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

tags/0.0.2
j преди 3 години
родител
ревизия
bf67e5551c
променени са 3 файла, в които са добавени 146 реда и са изтрити 100 реда
  1. 25
    11
      frontend/src/components/ProfileCard.vue
  2. 81
    77
      frontend/src/components/SpiderChart.vue
  3. 40
    12
      frontend/src/components/SummaryBar.vue

+ 25
- 11
frontend/src/components/ProfileCard.vue Целия файл

1
 <template lang="pug">
1
 <template lang="pug">
2
-w-card.profile-card-list--card.xs12.pa12
2
+w-card.profile-card-list--card.xs12
3
     header.xs12.w-flex.column.center
3
     header.xs12.w-flex.column.center
4
         NamePlate(
4
         NamePlate(
5
             :is-list='isList'
5
             :is-list='isList'
10
             :role='card.role'
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
         template(v-if='!isList')
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
             TagList(v-if='!isPaired || isList')
24
             TagList(v-if='!isPaired || isList')
20
 
25
 
21
     article.xs12.w-flex.column.justify-space-between
26
     article.xs12.w-flex.column.justify-space-between
27
             v-if='!isPaired || isList'
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
             p {{ card.summary.about.tab }}
37
             p {{ card.summary.about.tab }}
35
         PairingButton(@pair='onPair' @pass='onPass' v-if='!isPaired')
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
 </template>
42
 </template>
37
 
43
 
38
 <script setup>
44
 <script setup>
48
 import AspectBar from './AspectBar.vue'
54
 import AspectBar from './AspectBar.vue'
49
 import SummaryBar from './SummaryBar.vue'
55
 import SummaryBar from './SummaryBar.vue'
50
 import TagList from './TagList.vue'
56
 import TagList from './TagList.vue'
51
-import SpiderChart from './SpiderChart.vue'
52
 import PairingButton from './PairingButton.vue'
57
 import PairingButton from './PairingButton.vue'
53
 
58
 
54
 const router = useRouter()
59
 const router = useRouter()
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
  * Attempt to pair with target profile
89
  * Attempt to pair with target profile
76
  * Creates a grouping, and a membership
90
  * Creates a grouping, and a membership

+ 81
- 77
frontend/src/components/SpiderChart.vue Целия файл

1
 <template lang="pug">
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
 </template>
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
 </script>
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 Целия файл

1
 <template lang="pug">
1
 <template lang="pug">
2
 section.w-flex.column.pb5
2
 section.w-flex.column.pb5
3
     nav.fill-width.w-flex.column.justify-space-between
3
     nav.fill-width.w-flex.column.justify-space-between
4
-
5
         // Tabbed Layout
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
                 .w-flex.column.justify-start
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
                     p(v-else) &nbsp;
15
                     p(v-else) &nbsp;
11
                     p {{ item }}
16
                     p {{ item }}
12
             // About Tab
17
             // About Tab
13
-            template(#item-content.1="{ item }")
18
+            template(#item-content.1='{ item }')
14
                 .tab--about
19
                 .tab--about
15
                     p {{ tabContent[item].tab }}
20
                     p {{ tabContent[item].tab }}
16
                     br
21
                     br
17
                     p {{ tabContent[item].tab }}
22
                     p {{ tabContent[item].tab }}
18
                     br
23
                     br
19
                     hr
24
                     hr
20
-            
25
+
21
             // Passion Tab
26
             // Passion Tab
22
-            template(#item-content.2="{ item }")
27
+            template(#item-content.2='{ item }')
23
                 .tab--passion
28
                 .tab--passion
24
                     p {{ tabContent[item].tab }}
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
             // Aspirations Tab
38
             // Aspirations Tab
27
-            template(#item-content.3="{ item }")
39
+            template(#item-content.3='{ item }')
28
                 .tab--aspirations
40
                 .tab--aspirations
29
                     p {{ tabContent[item].tab }}
41
                     p {{ tabContent[item].tab }}
30
 
42
 
31
             // Skills Tab
43
             // Skills Tab
32
-            template(#item-content.4="{ item }")
44
+            template(#item-content.4='{ item }')
33
                 .tab--skills
45
                 .tab--skills
34
                     p {{ tabContent[item].tab }}
46
                     p {{ tabContent[item].tab }}
35
 
47
 
36
         // Untabbed Layout
48
         // Untabbed Layout
37
         ul.w-flex.row.justify-space-between(v-else)
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
                     .w-flex.column.justify-start
56
                     .w-flex.column.justify-start
42
                         p {{ tabContent[item].matchPerc }}%
57
                         p {{ tabContent[item].matchPerc }}%
43
                         p {{ item }}
58
                         p {{ item }}
44
 </template>
59
 </template>
45
 
60
 
46
 <script>
61
 <script>
62
+import SpiderChart from './SpiderChart.vue'
63
+
47
 export default {
64
 export default {
65
+    components: { SpiderChart },
48
     props: {
66
     props: {
67
+        aspects: {
68
+            required: true,
69
+            type: Array,
70
+        },
49
         tabContent: {
71
         tabContent: {
50
             required: true,
72
             required: true,
51
             type: Object,
73
             type: Object,
61
             default: true,
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
 </script>
93
 </script>

Loading…
Отказ
Запис