Notices fixes and support for titles (#3508)

* Notices fixes and support for titles

* Lint
This commit is contained in:
Prospector
2025-04-14 16:58:31 -07:00
committed by GitHub
parent 6c16688ca9
commit 04659a8198
6 changed files with 52 additions and 6 deletions

View File

@@ -1,7 +1,15 @@
<template>
<Admonition :type="NOTICE_TYPE[props.level]">
<template #header>
{{ formatMessage(heading) }}
<template v-if="!hideDefaultTitle">
{{ formatMessage(heading) }}
</template>
<template v-if="title">
<template v-if="hideDefaultTitle">
{{ title.substring(1) }}
</template>
<template v-else> - {{ title }}</template>
</template>
</template>
<template #actions>
<ButtonStyled v-if="dismissable" circular>
@@ -36,12 +44,18 @@ const props = withDefaults(
message: string
dismissable: boolean
preview?: boolean
title?: string
}>(),
{
preview: false,
title: undefined,
},
)
const hideDefaultTitle = computed(
() => props.title && props.title.length > 1 && props.title.startsWith('\\'),
)
const messages = defineMessages({
info: {
id: 'servers.notice.heading.info',
@@ -71,3 +85,8 @@ const NOTICE_TYPE: Record<string, 'info' | 'warning' | 'critical'> = {
const heading = computed(() => NOTICE_HEADINGS[props.level] ?? messages.info)
</script>
<style scoped lang="scss">
.markdown-body > *:first-child {
margin-top: 0;
}
</style>