|
| 1 | +<script setup lang="ts"> |
| 2 | +const hackspacePoints = ref({ |
| 3 | + jcr: 0, |
| 4 | + scr: 0, |
| 5 | + qtr: 0 |
| 6 | +}); |
| 7 | +
|
| 8 | +const scaledNormalisation = computed(() => { |
| 9 | + const average = |
| 10 | + (hackspacePoints.value.jcr + |
| 11 | + hackspacePoints.value.scr + |
| 12 | + hackspacePoints.value.qtr) / |
| 13 | + 3; |
| 14 | +
|
| 15 | + if (average === 0) { |
| 16 | + return { |
| 17 | + jcr: 0.5, |
| 18 | + scr: 0.5, |
| 19 | + qtr: 0.5 |
| 20 | + }; |
| 21 | + } |
| 22 | +
|
| 23 | + const normalised = { |
| 24 | + jcr: 0.5 + (hackspacePoints.value.jcr - average) / average, |
| 25 | + scr: 0.5 + (hackspacePoints.value.scr - average) / average, |
| 26 | + qtr: 0.5 + (hackspacePoints.value.qtr - average) / average |
| 27 | + }; |
| 28 | +
|
| 29 | + const adjusted = { |
| 30 | + jcr: Math.max(0.1, Math.min(0.9, normalised.jcr)), |
| 31 | + scr: Math.max(0.1, Math.min(0.9, normalised.scr)), |
| 32 | + qtr: Math.max(0.1, Math.min(0.9, normalised.qtr)) |
| 33 | + }; |
| 34 | + return adjusted; |
| 35 | +}); |
| 36 | +
|
| 37 | +onMounted(() => { |
| 38 | + // TODO actually make the request |
| 39 | + setTimeout(() => { |
| 40 | + hackspacePoints.value = { |
| 41 | + jcr: 0, |
| 42 | + scr: 0, |
| 43 | + qtr: 0 |
| 44 | + }; |
| 45 | + }, 200); |
| 46 | +}); |
| 47 | +</script> |
| 48 | + |
| 49 | +<template> |
| 50 | + <div class="flex gap-x-10 max-lg:flex-col lg:max-h-[512px]"> |
| 51 | + <div |
| 52 | + class="flex gap-12 max-lg:aspect-[3/4] max-lg:max-h-[256px] lg:min-h-[256px] lg:w-2/3"> |
| 53 | + <div |
| 54 | + class="bar bg-red-ic" |
| 55 | + :style="`transform: scaleY(${scaledNormalisation.jcr});`"> |
| 56 | + <img |
| 57 | + src="@ui25/assets/jcr_white.svg" |
| 58 | + :style="`transform: scaleY(${1 / scaledNormalisation.jcr}) translateX(-50%)`" /> |
| 59 | + |
| 60 | + <div class="relative flex h-full w-full flex-col overflow-hidden"> |
| 61 | + <p |
| 62 | + class="z-10 self-center font-semibold" |
| 63 | + :style="`transform: scaleY(${1 / scaledNormalisation.jcr})`"> |
| 64 | + {{ hackspacePoints.jcr }} Pts |
| 65 | + </p> |
| 66 | + </div> |
| 67 | + </div> |
| 68 | + <div |
| 69 | + class="bar bg-yellow-ic" |
| 70 | + :style="`transform: scaleY(${scaledNormalisation.scr});`"> |
| 71 | + <img |
| 72 | + src="@ui25/assets/scr_white.svg" |
| 73 | + :style="`transform: scaleY(${1 / scaledNormalisation.scr}) translateX(-50%)`" /> |
| 74 | + |
| 75 | + <div class="relative flex h-full w-full flex-col overflow-hidden"> |
| 76 | + <p |
| 77 | + class="z-10 self-center font-semibold" |
| 78 | + :style="`transform: scaleY(${1 / scaledNormalisation.scr})`"> |
| 79 | + {{ hackspacePoints.scr }} Pts |
| 80 | + </p> |
| 81 | + </div> |
| 82 | + </div> |
| 83 | + <div |
| 84 | + class="bar bg-blue-ic" |
| 85 | + :style="`transform: scaleY(${scaledNormalisation.qtr});`"> |
| 86 | + <img |
| 87 | + src="@ui25/assets/qtr_white.svg" |
| 88 | + :style="`transform: scaleY(${1 / scaledNormalisation.qtr}) translateX(-50%)`" /> |
| 89 | + |
| 90 | + <div class="relative flex h-full w-full flex-col overflow-hidden"> |
| 91 | + <p |
| 92 | + class="z-10 self-center font-semibold" |
| 93 | + :style="`transform: scaleY(${1 / scaledNormalisation.qtr})`"> |
| 94 | + {{ hackspacePoints.qtr }} Pts |
| 95 | + </p> |
| 96 | + </div> |
| 97 | + </div> |
| 98 | + </div> |
| 99 | + |
| 100 | + <div class="mt-8 w-full border border-white px-4 py-3 lg:max-w-[25vw]"> |
| 101 | + <div class="flex justify-between"> |
| 102 | + <h3 class="text-2xl font-bold">Challenges</h3> |
| 103 | + <img src="@ui25/assets/crown.svg" alt="Hackspace Scores" /> |
| 104 | + </div> |
| 105 | + |
| 106 | + <div class="mt-5 flex flex-col gap-2"> |
| 107 | + <!-- Make v-for from challenges!! --> |
| 108 | + <div |
| 109 | + class="flex items-center justify-between border border-white px-3 py-2"> |
| 110 | + <p class="text-xl font-semibold"> |
| 111 | + Stay tuned to see challenge winners! |
| 112 | + </p> |
| 113 | + <!-- <img src="@ui25/assets/qtr_white.svg" alt="" class="size-10" /> --> |
| 114 | + </div> |
| 115 | + </div> |
| 116 | + </div> |
| 117 | + </div> |
| 118 | +</template> |
| 119 | + |
| 120 | +<style scoped> |
| 121 | +.bar { |
| 122 | + @apply relative w-full origin-bottom transition-transform duration-500; |
| 123 | +} |
| 124 | +
|
| 125 | +.bar img { |
| 126 | + @apply absolute -top-12 left-1/2 size-8 origin-bottom transition-transform duration-500; |
| 127 | +} |
| 128 | +
|
| 129 | +.bar p { |
| 130 | + @apply origin-top transition-transform duration-500; |
| 131 | +} |
| 132 | +</style> |
0 commit comments