refactor: switch to setup-sfc
This commit is contained in:
parent
6ca34cab85
commit
bbc8ed5307
10 changed files with 55 additions and 41 deletions
|
@ -59,7 +59,7 @@ function getFieldNameIcon(fieldName: string) {
|
|||
</NuxtLink>
|
||||
</div>
|
||||
<div flex flex-col>
|
||||
<ContentRich font-bold text-2xl :content="getDisplayName(account)" :emojis="account.emojis" />
|
||||
<ContentRichSetup font-bold text-2xl :content="getDisplayName(account)" :emojis="account.emojis" />
|
||||
<p op50>
|
||||
{{ getAccountHandle(account) }}
|
||||
</p>
|
||||
|
|
|
@ -18,7 +18,7 @@ const accountHandle = $(useAccountHandle(account, fullServer))
|
|||
</NuxtLink>
|
||||
</div>
|
||||
<NuxtLink flex flex-col :to="link ? getAccountPath(account) : null">
|
||||
<ContentRich font-bold :content="getDisplayName(account)" :emojis="account.emojis" />
|
||||
<ContentRichSetup font-bold :content="getDisplayName(account)" :emojis="account.emojis" />
|
||||
<p op35 text-sm>
|
||||
{{ accountHandle }}
|
||||
</p>
|
||||
|
|
|
@ -10,6 +10,6 @@ const { link = true } = defineProps<{
|
|||
<template>
|
||||
<NuxtLink :to="link ? getAccountPath(account) : undefined" flex gap-1 items-center>
|
||||
<AccountAvatar :account="account" w-5 h-5 />
|
||||
<ContentRich :content="getDisplayName(account)" :emojis="account.emojis" />
|
||||
<ContentRichSetup :content="getDisplayName(account)" :emojis="account.emojis" />
|
||||
</NuxtLink>
|
||||
</template>
|
||||
|
|
|
@ -8,6 +8,6 @@ defineProps<{
|
|||
|
||||
<template>
|
||||
<NuxtLink :to="getAccountPath(account)">
|
||||
<ContentRich font-bold :content="getDisplayName(account)" :emojis="account.emojis" />
|
||||
<ContentRichSetup font-bold :content="getDisplayName(account)" :emojis="account.emojis" />
|
||||
</NuxtLink>
|
||||
</template>
|
||||
|
|
19
components/content/ContentRich.setup.ts
Normal file
19
components/content/ContentRich.setup.ts
Normal file
|
@ -0,0 +1,19 @@
|
|||
import type { Emoji } from 'masto'
|
||||
import { emojisArrayToObject } from '~/composables/utils'
|
||||
|
||||
defineOptions({
|
||||
name: 'ContentRich',
|
||||
})
|
||||
|
||||
const props = defineProps<{
|
||||
content: string
|
||||
emojis: Emoji[]
|
||||
}>()
|
||||
|
||||
const emojiObject = emojisArrayToObject(props.emojis || [])
|
||||
|
||||
export default () => h(
|
||||
'div',
|
||||
{ class: 'rich-content' },
|
||||
contentToVNode(props.content, emojiObject),
|
||||
)
|
|
@ -1,24 +0,0 @@
|
|||
import type { Emoji } from 'masto'
|
||||
import type { PropType } from 'vue'
|
||||
import { emojisArrayToObject } from '~/composables/utils'
|
||||
|
||||
export default defineComponent({
|
||||
props: {
|
||||
content: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
emojis: {
|
||||
type: Array as PropType<Emoji[]>,
|
||||
},
|
||||
},
|
||||
setup(props) {
|
||||
const emojiObject = emojisArrayToObject(props.emojis || [])
|
||||
|
||||
return () => h(
|
||||
'div',
|
||||
{ class: 'rich-content' },
|
||||
contentToVNode(props.content, emojiObject),
|
||||
)
|
||||
},
|
||||
})
|
|
@ -11,7 +11,7 @@ const accountHandle = $(useAccountHandle(account))
|
|||
|
||||
<template>
|
||||
<NuxtLink :to="link ? getAccountPath(account) : undefined" flex gap-2 items-center>
|
||||
<ContentRich font-bold :content="getDisplayName(account)" :emojis="account.emojis" />
|
||||
<ContentRichSetup font-bold :content="getDisplayName(account)" :emojis="account.emojis" />
|
||||
<p op35 text-sm>
|
||||
{{ accountHandle }}
|
||||
</p>
|
||||
|
|
|
@ -9,6 +9,6 @@ const { translation } = useTranslation(status)
|
|||
|
||||
<template>
|
||||
<div class="status-body">
|
||||
<ContentRich :content="translation.visible ? translation.text : status.content" :emojis="status.emojis" />
|
||||
<ContentRichSetup :content="translation.visible ? translation.text : status.content" :emojis="status.emojis" />
|
||||
</div>
|
||||
</template>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue