|
| 1 | +<script setup lang="ts"> |
| 2 | +import { computed } from 'vue' |
| 3 | +
|
| 4 | +const props = defineProps<{ |
| 5 | + handle: string |
| 6 | + rating: number |
| 7 | +}>() |
| 8 | +
|
| 9 | +const codeforcesTitle = computed(() => { |
| 10 | + if (props.rating >= 4000) return props.handle |
| 11 | + if (props.rating >= 3000) return 'Legendary Grandmaster' |
| 12 | + if (props.rating >= 2600) return 'International Grandmaster' |
| 13 | + if (props.rating >= 2400) return 'Grandmaster' |
| 14 | + if (props.rating >= 2300) return 'International Master' |
| 15 | + if (props.rating >= 2100) return 'Master' |
| 16 | + if (props.rating >= 1900) return 'Candidate Master' |
| 17 | + if (props.rating >= 1600) return 'Expert' |
| 18 | + if (props.rating >= 1400) return 'Specialist' |
| 19 | + if (props.rating >= 1200) return 'Pupil' |
| 20 | + return 'Newbie' |
| 21 | +}) |
| 22 | +</script> |
| 23 | + |
| 24 | +<template> |
| 25 | + <div |
| 26 | + class="font-(family-name:--font-verdana) px-3.5 py-2" :class="{ |
| 27 | + 'text-color': props.rating >= 4000, |
| 28 | + 'text-red-500': props.rating >= 2400 && props.rating < 4000, |
| 29 | + 'text-amber-500': props.rating >= 2000 && props.rating < 2400, |
| 30 | + 'text-fuchsia-600': props.rating >= 1800 && props.rating < 2000, |
| 31 | + 'text-blue-600': props.rating >= 1600 && props.rating < 1800, |
| 32 | + 'text-teal-500': props.rating >= 1400 && props.rating < 1600, |
| 33 | + 'text-green-700': props.rating >= 1200 && props.rating < 1400, |
| 34 | + 'text-neutral-500': props.rating < 1200, |
| 35 | + }" |
| 36 | + > |
| 37 | + <div class="font-semibold text-sm"> |
| 38 | + {{ codeforcesTitle }} |
| 39 | + </div> |
| 40 | + <a |
| 41 | + :href="`https://codeforces.com/profile/${props.handle}`" target="_blank" rel="noopener noreferrer" |
| 42 | + class="font-sans font-semibold hover:underline text-2xl text-inherit" |
| 43 | + > |
| 44 | + <template v-if="props.rating >= 3000"> |
| 45 | + <span |
| 46 | + :class="{ |
| 47 | + 'text-red-500': props.rating >= 4000, |
| 48 | + 'text-color': props.rating >= 3000 && props.rating < 4000, |
| 49 | + }" |
| 50 | + >{{ props.handle.slice(0, 1) }}</span>{{ props.handle.slice(1) }} |
| 51 | + </template> |
| 52 | + <template v-else>{{ props.handle }}</template> |
| 53 | + </a> |
| 54 | + <div class="mt-1"> |
| 55 | + <span class="mr-1 text-color">Contest rating:</span> |
| 56 | + <span class="font-(family-name:--font-verdana) font-bold"> {{ props.rating }}</span> |
| 57 | + </div> |
| 58 | + </div> |
| 59 | +</template> |
0 commit comments