Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(alert): make props reactive #320

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/components/FwbAlert/FwbAlert.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
</div>
</template>
<script lang="ts" setup>
import { ref, useAttrs } from 'vue'
import { computed, ref, useAttrs } from 'vue'
import { twMerge } from 'tailwind-merge'
import type { AlertType } from './types'

Expand Down Expand Up @@ -112,7 +112,7 @@ const closeButtonClasses: Record<AlertType, string> = {
success: 'text-green-500 dark:text-green-400 bg-green-50 hover:bg-green-200 focus:ring-green-400',
warning: 'text-yellow-500 dark:text-yellow-300 bg-yellow-50 hover:bg-yellow-200 focus:ring-yellow-400',
}
const closeBtnClasses = twMerge(defaultCloseButtonClasses, closeButtonClasses[props.type])
const closeBtnClasses = computed(() => twMerge(defaultCloseButtonClasses, closeButtonClasses[props.type]))
const borderColor: Record<AlertType, string> = {
danger: 'border-red-500 dark:text-red-400',
dark: 'border-gray-500 dark:text-gray-400',
Expand All @@ -127,14 +127,14 @@ const colors = {
success: [alertTextClasses.success, alertTypeClasses.success].join(' '),
warning: [alertTextClasses.warning, alertTypeClasses.warning].join(' '),
}
const wrapperClasses = twMerge(
const wrapperClasses = computed(() => twMerge(
'p-4 gap-3 text-sm dark:bg-gray-800 rounded-lg',
colors[props.type],
(props.icon || props.closable) && 'flex items-center',
borderColor[props.type],
props.border && 'border',
attrs.class as string,
)
))
const visible = ref(true)

function onCloseClick () {
Expand Down
Loading