mirror of
https://github.com/elk-zone/elk.git
synced 2024-09-06 12:19:08 +01:00
refactor: tidy masto icons
This commit is contained in:
parent
ef417f3ccf
commit
b14add8c83
6 changed files with 26 additions and 23 deletions
|
@ -1,5 +1,6 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Account, Field } from 'masto'
|
import type { Account, Field } from 'masto'
|
||||||
|
import { getAccountFieldIcon } from '~/composables/masto/icons'
|
||||||
|
|
||||||
const { account } = defineProps<{
|
const { account } = defineProps<{
|
||||||
account: Account
|
account: Account
|
||||||
|
|
|
@ -5,6 +5,7 @@ import { useDropZone } from '@vueuse/core'
|
||||||
import { EditorContent } from '@tiptap/vue-3'
|
import { EditorContent } from '@tiptap/vue-3'
|
||||||
import ISO6391 from 'iso-639-1'
|
import ISO6391 from 'iso-639-1'
|
||||||
import Fuse from 'fuse.js'
|
import Fuse from 'fuse.js'
|
||||||
|
import { statusVisibilities } from '~/composables/masto/icons'
|
||||||
import type { Draft } from '~/types'
|
import type { Draft } from '~/types'
|
||||||
|
|
||||||
type FileUploadError = [filename: string, message: string]
|
type FileUploadError = [filename: string, message: string]
|
||||||
|
@ -56,7 +57,7 @@ const { editor } = useTiptap({
|
||||||
})
|
})
|
||||||
|
|
||||||
const currentVisibility = $computed(() => {
|
const currentVisibility = $computed(() => {
|
||||||
return STATUS_VISIBILITIES.find(v => v.value === draft.params.visibility) || STATUS_VISIBILITIES[0]
|
return statusVisibilities.find(v => v.value === draft.params.visibility) || statusVisibilities[0]
|
||||||
})
|
})
|
||||||
|
|
||||||
let isUploading = $ref<boolean>(false)
|
let isUploading = $ref<boolean>(false)
|
||||||
|
@ -396,7 +397,7 @@ defineExpose({
|
||||||
|
|
||||||
<template #popper>
|
<template #popper>
|
||||||
<CommonDropdownItem
|
<CommonDropdownItem
|
||||||
v-for="visibility in STATUS_VISIBILITIES"
|
v-for="visibility in statusVisibilities"
|
||||||
:key="visibility.value"
|
:key="visibility.value"
|
||||||
:icon="visibility.icon"
|
:icon="visibility.icon"
|
||||||
:checked="visibility.value === draft.params.visibility"
|
:checked="visibility.value === draft.params.visibility"
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { UpdateCredentialsParams } from 'masto'
|
import type { UpdateCredentialsParams } from 'masto'
|
||||||
|
import { accountFieldIcons, getAccountFieldIcon } from '~/composables/masto/icons'
|
||||||
|
|
||||||
const { form } = defineModel<{
|
const { form } = defineModel<{
|
||||||
form: {
|
form: {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { Status } from 'masto'
|
import type { Status } from 'masto'
|
||||||
|
import { statusVisibilities } from '~/composables/masto/icons'
|
||||||
|
|
||||||
const props = withDefaults(defineProps<{
|
const props = withDefaults(defineProps<{
|
||||||
status: Status
|
status: Status
|
||||||
|
@ -17,7 +18,7 @@ const status = $computed(() => {
|
||||||
|
|
||||||
const createdAt = useFormattedDateTime(status.createdAt)
|
const createdAt = useFormattedDateTime(status.createdAt)
|
||||||
|
|
||||||
const visibility = $computed(() => STATUS_VISIBILITIES.find(v => v.value === status.visibility)!)
|
const visibility = $computed(() => statusVisibilities.find(v => v.value === status.visibility)!)
|
||||||
|
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
|
|
||||||
|
|
|
@ -13,26 +13,6 @@ export const onMastoInit = (cb: () => unknown) => {
|
||||||
}, { immediate: isMastoInitialised.value })
|
}, { immediate: isMastoInitialised.value })
|
||||||
}
|
}
|
||||||
|
|
||||||
// @unocss-include
|
|
||||||
export const STATUS_VISIBILITIES = [
|
|
||||||
{
|
|
||||||
value: 'public',
|
|
||||||
icon: 'i-ri:global-line',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: 'unlisted',
|
|
||||||
icon: 'i-ri:lock-unlock-line',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: 'private',
|
|
||||||
icon: 'i-ri:lock-line',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: 'direct',
|
|
||||||
icon: 'i-ri:at-line',
|
|
||||||
},
|
|
||||||
] as const
|
|
||||||
|
|
||||||
export function getDisplayName(account?: Account, options?: { rich?: boolean }) {
|
export function getDisplayName(account?: Account, options?: { rich?: boolean }) {
|
||||||
const displayName = account?.displayName || account?.username || ''
|
const displayName = account?.displayName || account?.username || ''
|
||||||
if (options?.rich)
|
if (options?.rich)
|
||||||
|
|
|
@ -52,3 +52,22 @@ export const getAccountFieldIcon = (value: string) => {
|
||||||
const name = value.trim().toLowerCase()
|
const name = value.trim().toLowerCase()
|
||||||
return accountFieldIconsLowercase[name] || undefined
|
return accountFieldIconsLowercase[name] || undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const statusVisibilities = [
|
||||||
|
{
|
||||||
|
value: 'public',
|
||||||
|
icon: 'i-ri:global-line',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'unlisted',
|
||||||
|
icon: 'i-ri:lock-unlock-line',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'private',
|
||||||
|
icon: 'i-ri:lock-line',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'direct',
|
||||||
|
icon: 'i-ri:at-line',
|
||||||
|
},
|
||||||
|
] as const
|
Loading…
Reference in a new issue