Skip to content

Commit

Permalink
feat: add text color to char sex column
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Trost <galexrt@googlemail.com>
  • Loading branch information
galexrt committed Jan 26, 2025
1 parent 56040aa commit 3c45949
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 3 deletions.
5 changes: 4 additions & 1 deletion app/components/citizens/CitizensList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { useNotificatorStore } from '~/store/notificator';
import { NotificationType } from '~~/gen/ts/resources/notifications/notifications';
import type { User } from '~~/gen/ts/resources/users/users';
import type { ListCitizensRequest, ListCitizensResponse } from '~~/gen/ts/services/citizenstore/citizenstore';
import { sexToTextColor } from '../partials/citizens/helpers';
const { t } = useI18n();
Expand Down Expand Up @@ -336,7 +337,9 @@ defineShortcuts({
</template>

<template #sex-data="{ row: citizen }">
{{ citizen.sex?.value.toUpperCase() ?? $t('common.na') }}
<span :class="sexToTextColor(citizen.sex?.value ?? '')">
{{ citizen.sex?.value.toUpperCase() ?? $t('common.na') }}
</span>
</template>

<template #phoneNumber-data="{ row: citizen }">
Expand Down
7 changes: 5 additions & 2 deletions app/components/partials/citizens/CharSexBadge.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
<script lang="ts" setup>
import type { BadgeColor } from '#ui/types';
import { sexToColor, sexToIcon } from './helpers';
defineProps<{
sex: string;
}>();
</script>

<template>
<UBadge :color="sex === 'f' ? 'pink' : 'blue'" size="lg">
<UIcon :name="sex === 'f' ? 'i-mdi-gender-female' : 'i-mdi-gender-male'" />
<UBadge :color="sexToColor(sex) as BadgeColor" size="lg">
<UIcon :name="sexToIcon(sex)" />
</UBadge>
</template>
33 changes: 33 additions & 0 deletions app/components/partials/citizens/helpers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
export function sexToColor(sex: string): string {
if (sex === 'f') {
return 'pink';
} else if (sex === 'm') {
return 'blue';
} else if (sex === 'd') {
return 'gray';
}

return 'white';
}

export function sexToTextColor(sex: string): string {
if (sex === 'f') {
return 'text-pink-300';
} else if (sex === 'm') {
return 'text-blue-300';
} else if (sex === 'd') {
return 'text-gray-300';
}

return 'text-white-300';
}

export function sexToIcon(sex: string): string {
if (sex === 'f') {
return 'i-mdi-gender-female';
} else if (sex === 'm') {
return 'i-mdi-gender-male';
}

return 'i-mdi-gender-non-binary';
}

0 comments on commit 3c45949

Please sign in to comment.