mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-01 19:48:08 +00:00
# Pull Request Template ## Description Fixes https://linear.app/chatwoot/issue/CW-4091/accessibility-improvement-support-bigger-font-size-for-the-dashboard ## Type of change - [x] New feature (non-breaking change which adds functionality) ## How Has This Been Tested? ### **Loom video** https://www.loom.com/share/1ab781859fa748a5ad54aacbacd127b4?sid=a7dd9164-a6de-462f-bff7-1b25e9c55b4f ## Checklist: - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my code - [x] I have commented on my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged and published in downstream modules
89 lines
2.4 KiB
Vue
89 lines
2.4 KiB
Vue
<script setup>
|
|
import { computed } from 'vue';
|
|
import { fileNameWithEllipsis } from '@chatwoot/utils';
|
|
|
|
import Button from 'dashboard/components-next/button/Button.vue';
|
|
|
|
const props = defineProps({
|
|
attachments: {
|
|
type: Array,
|
|
required: true,
|
|
},
|
|
});
|
|
|
|
const emit = defineEmits(['update:attachments']);
|
|
|
|
const isTypeImage = file => {
|
|
const type = file.content_type || file.type;
|
|
return type.includes('image');
|
|
};
|
|
|
|
const filteredImageAttachments = computed(() => {
|
|
return props.attachments.filter(attachment =>
|
|
isTypeImage(attachment.resource)
|
|
);
|
|
});
|
|
|
|
const filteredNonImageAttachments = computed(() => {
|
|
return props.attachments.filter(
|
|
attachment => !isTypeImage(attachment.resource)
|
|
);
|
|
});
|
|
|
|
const removeAttachment = id => {
|
|
const updatedAttachments = props.attachments.filter(
|
|
attachment => attachment.resource.id !== id
|
|
);
|
|
emit('update:attachments', updatedAttachments);
|
|
};
|
|
</script>
|
|
|
|
<template>
|
|
<div class="flex flex-col gap-4 p-4">
|
|
<div
|
|
v-if="filteredImageAttachments.length > 0"
|
|
class="flex flex-wrap gap-3"
|
|
>
|
|
<div
|
|
v-for="attachment in filteredImageAttachments"
|
|
:key="attachment.id"
|
|
class="relative group/image w-[4.5rem] h-[4.5rem]"
|
|
>
|
|
<img
|
|
class="object-cover w-[4.5rem] h-[4.5rem] rounded-lg"
|
|
:src="attachment.thumb"
|
|
/>
|
|
<Button
|
|
variant="ghost"
|
|
icon="i-lucide-trash"
|
|
color="slate"
|
|
class="absolute top-1 right-1 !w-5 !h-5 transition-opacity duration-150 ease-in-out opacity-0 group-hover/image:opacity-100"
|
|
@click="removeAttachment(attachment.resource.id)"
|
|
/>
|
|
</div>
|
|
</div>
|
|
<div
|
|
v-if="filteredNonImageAttachments.length > 0"
|
|
class="flex flex-wrap gap-3"
|
|
>
|
|
<div
|
|
v-for="attachment in filteredNonImageAttachments"
|
|
:key="attachment.id"
|
|
class="max-w-[18.75rem] inline-flex items-center h-8 min-w-0 bg-n-alpha-2 dark:bg-n-solid-3 rounded-lg gap-3 ltr:pl-3 rtl:pr-3 ltr:pr-2 rtl:pl-2"
|
|
>
|
|
<span class="text-sm font-medium text-n-slate-11">
|
|
{{ fileNameWithEllipsis(attachment.resource) }}
|
|
</span>
|
|
<Button
|
|
variant="ghost"
|
|
icon="i-lucide-x"
|
|
color="slate"
|
|
size="xs"
|
|
class="shrink-0 !h-5 !w-5"
|
|
@click="removeAttachment(attachment.resource.id)"
|
|
/>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|