| 1 | <template> |
| 2 | <div> |
| 3 | <div v-if="grade" class="font-mono leading-none font-bold tracking-tight" :class="gradeTextClass"> |
| 4 | {{ grade }} |
| 5 | </div> |
| 6 | <div v-else class="text-tertiary font-mono leading-none font-semibold">—</div> |
| 7 | </div> |
| 8 | </template> |
| 9 | |
| 10 | <script setup lang="ts"> |
| 11 | import { computed } from "vue" |
| 12 | |
| 13 | const props = defineProps<{ |
| 14 | grade?: string | null |
| 15 | }>() |
| 16 | |
| 17 | const gradeTextClass = computed(() => { |
| 18 | const value = props.grade |
| 19 | if (!value) return "" |
| 20 | if (value === "A" || value === "A+") return "text-success" |
| 21 | if (value.startsWith("B")) return "text-info" |
| 22 | if (value.startsWith("C")) return "text-warning" |
| 23 | if (value === "D" || value === "D+" || value === "F") return "text-error" |
| 24 | return "text-tertiary" |
| 25 | }) |
| 26 | </script> |