|
| 1 | +<template> |
| 2 | + <div class="container"> |
| 3 | + <div class="wrapper"> |
| 4 | + <div class="contributions-graph"> |
| 5 | + <div class="user" |
| 6 | + v-for="(user, index) in |
| 7 | + contributionsCollection.contribution_collections.slice(0, displayUsersNumber)" |
| 8 | + v-bind:key="user.name" |
| 9 | + v-bind:style="{ transform: 'rotateY(' + 360 / displayUsersNumber * index + 'deg)' }"> |
| 10 | + <div class="user-info" v-bind:style= |
| 11 | + "{ 'animation-delay': -60 / displayUsersNumber * index + 's' }"> |
| 12 | + <img v-bind:src="user.user.icon_url"> |
| 13 | + <dl> |
| 14 | + <dt>USER NAME</dt> |
| 15 | + <dd class="user-name">{{ user.user.github_user_name }}</dd> |
| 16 | + <dt>TOTAL CONTRIBUTIONS</dt> |
| 17 | + <dd class="total-contributions">{{ user.total_count }}</dd> |
| 18 | + </dl> |
| 19 | + </div> |
| 20 | + <div class="graph" v-bind:style= |
| 21 | + "{ stroke: 'hsl(' + 360 / displayUsersNumber * index + ', 70%, 45%)' }"> |
| 22 | + <svg viewbox="0 0 25 300" width="25" height="300"> |
| 23 | + <line x1=0 v-bind:y1="300 - (dayIndex * 5 + 2)" |
| 24 | + v-bind:x2="item.count" v-bind:y2="300 - (dayIndex * 5 + 2)" |
| 25 | + stroke-width="4" v-bind:opacity="item.count / 5" |
| 26 | + v-for="(item, dayIndex) in user.days" |
| 27 | + v-bind:key="item.date"></line> |
| 28 | + </svg> |
| 29 | + </div> |
| 30 | + </div> |
| 31 | + </div> |
| 32 | + </div> |
| 33 | + </div> |
| 34 | +</template> |
| 35 | + |
| 36 | +<script> |
| 37 | +import { mapState, mapActions } from 'vuex'; |
| 38 | +
|
| 39 | +export default { |
| 40 | + name: 'GitHubContributionsGraph', |
| 41 | + props: ['displayUsersNumber'], |
| 42 | + computed: mapState( |
| 43 | + 'contributionsCollection', ['contributionsCollection'], |
| 44 | + ), |
| 45 | + methods: { |
| 46 | + ...mapActions( |
| 47 | + 'contributionsCollection', ['getContributionsCollection'], |
| 48 | + ), |
| 49 | + }, |
| 50 | + async created() { |
| 51 | + this.getContributionsCollection(); |
| 52 | + }, |
| 53 | +}; |
| 54 | +</script> |
| 55 | + |
| 56 | +<style scoped> |
| 57 | +@keyframes rotate { |
| 58 | + from { transform: rotateY(0deg); } |
| 59 | + to { transform: rotateY(360deg); } |
| 60 | +} |
| 61 | +@keyframes fukan { |
| 62 | + from { transform: rotateX(0deg); } |
| 63 | + to { transform: rotateX(-30deg); } |
| 64 | +} |
| 65 | +@keyframes dash { |
| 66 | + from { stroke-dashoffset: 50; } |
| 67 | + to { stroke-dashoffset: 0; } |
| 68 | +} |
| 69 | +.container { |
| 70 | + perspective: 1000px; |
| 71 | +} |
| 72 | +.wrapper { |
| 73 | + font-family: 'Barlow'; |
| 74 | + font-weight: bold; |
| 75 | + height: 700px; |
| 76 | + animation: fukan 10s ease-in-out; |
| 77 | + transform-style: preserve-3d; |
| 78 | + width: 60%; |
| 79 | + margin: 100px auto; |
| 80 | + transform: rotateX(-30deg); |
| 81 | +} |
| 82 | +dl { |
| 83 | + letter-spacing: 1px; |
| 84 | +} |
| 85 | +dt { |
| 86 | + font-size: 0.7em; |
| 87 | + line-height: 1px; |
| 88 | +} |
| 89 | +.user { |
| 90 | + width: 50%; |
| 91 | + margin-left: 50%; |
| 92 | + position: absolute; |
| 93 | + transform-origin: 0; |
| 94 | + transform-style: preserve-3d; |
| 95 | +} |
| 96 | +.user-info { |
| 97 | + margin-left: 70%; |
| 98 | + animation: rotate 60s infinite reverse linear; |
| 99 | + border-top: 1px solid black; |
| 100 | + padding-top: 20px; |
| 101 | + font-size: 16px; |
| 102 | +} |
| 103 | +.user-info img { |
| 104 | + width: 64px; |
| 105 | + height: 64px; |
| 106 | + object-fit: contain; |
| 107 | + position: absolute; |
| 108 | + left: -85px; |
| 109 | + top: 16px; |
| 110 | + border: 1px solid black; |
| 111 | +} |
| 112 | +.user-name, .total-contributions{ |
| 113 | + font-size: 3em; |
| 114 | +} |
| 115 | +.contributions-graph { |
| 116 | + animation: rotate 60s infinite linear; |
| 117 | + transform-style: preserve-3d; |
| 118 | +} |
| 119 | +.graph { |
| 120 | + transform-style: preserve-3d; |
| 121 | + padding-top: 20px; |
| 122 | +} |
| 123 | +svg { |
| 124 | + width: 100%; |
| 125 | + transform-origin: top left; |
| 126 | + transform: scale(30, 2); |
| 127 | +} |
| 128 | +svg line { |
| 129 | + stroke-dasharray: 50; |
| 130 | + animation: dash 10s ease-in-out; |
| 131 | +} |
| 132 | +@media screen and (max-width: 480px) { |
| 133 | + .user-info { |
| 134 | + font-size: 6px; |
| 135 | + } |
| 136 | +} |
| 137 | +</style> |
0 commit comments