fix: form required style adjustment (#4668)

This commit is contained in:
Vben
2024-10-17 22:40:20 +08:00
committed by GitHub
parent c432e0ac33
commit f89f4f32c7
3 changed files with 10 additions and 8 deletions

View File

@@ -278,7 +278,7 @@ function autofocus() {
cn(
'flex leading-6',
{
'mr-2 flex-shrink-0': !isVertical,
'mr-2 flex-shrink-0 justify-end': !isVertical,
'flex-row': isVertical,
},
!isVertical && labelClass,

View File

@@ -1,20 +1,22 @@
<script setup lang="ts">
import { FormLabel, VbenHelpTooltip } from '@vben-core/shadcn-ui';
import { cn } from '@vben-core/shared/utils';
interface Props {
class?: string;
help?: string;
required?: boolean;
}
defineProps<Props>();
const props = defineProps<Props>();
</script>
<template>
<FormLabel class="flex flex-row-reverse items-center">
<FormLabel :class="cn('mb-1 flex items-center', props.class)">
<span v-if="required" class="text-destructive mr-[2px]">*</span>
<slot></slot>
<VbenHelpTooltip v-if="help" trigger-class="size-3.5 ml-1">
{{ help }}
</VbenHelpTooltip>
<slot></slot>
<span v-if="required" class="text-destructive mr-[2px]">*</span>
</FormLabel>
</template>