Browse Source

feat: implement TruncateText component

Signed-off-by: mertmit <mertmit99@gmail.com>
pull/3502/head
mertmit 2 years ago
parent
commit
965c683ff4
  1. 4
      packages/nc-gui-v2/components/dashboard/TreeView.vue
  2. 44
      packages/nc-gui-v2/components/general/TruncateText.vue
  3. 4
      packages/nc-gui-v2/components/smartsheet-toolbar/ViewActions.vue
  4. 4
      packages/nc-gui-v2/pages/[projectType]/[projectId]/index.vue
  5. 2
      packages/nc-gui-v2/pages/[projectType]/[projectId]/index/index.vue

4
packages/nc-gui-v2/components/dashboard/TreeView.vue

@ -334,7 +334,9 @@ function openTableCreateDialog() {
/>
</div>
<div class="nc-tbl-title flex-1">{{ table.title }}</div>
<div class="nc-tbl-title flex-1">
<GeneralTruncateText>{{ table.title }}</GeneralTruncateText>
</div>
<a-dropdown
v-if="!isSharedBase && !isLocked && (isUIAllowed('table-rename') || isUIAllowed('table-delete'))"

44
packages/nc-gui-v2/components/general/TruncateText.vue

@ -0,0 +1,44 @@
<script lang="ts" setup>
interface Props {
placement?:
| 'top'
| 'left'
| 'right'
| 'bottom'
| 'topLeft'
| 'topRight'
| 'bottomLeft'
| 'bottomRight'
| 'leftTop'
| 'leftBottom'
| 'rightTop'
| 'rightBottom'
length?: number
}
const props = withDefaults(defineProps<Props>(), {
placement: 'bottom',
length: 20,
})
const text = ref()
const enableTooltip = computed(() => text?.value?.textContent.length > props.length)
const shortName = computed(() =>
text?.value?.textContent.length > props.length
? `${text?.value?.textContent.substr(0, props.length - 3)}...`
: text?.value?.textContent,
)
</script>
<template>
<a-tooltip v-if="enableTooltip" :placement="props.placement">
<template #title>
<slot></slot>
</template>
<div>{{ shortName }}</div>
</a-tooltip>
<div v-else><slot></slot></div>
<div ref="text" class="hidden"><slot></slot></div>
</template>
<style scoped></style>

4
packages/nc-gui-v2/components/smartsheet-toolbar/ViewActions.vue

@ -89,7 +89,9 @@ const { isSqlView } = useSmartsheetStoreOrThrow()
class="nc-view-icon group-hover:hidden"
:style="{ color: viewIcons[selectedView?.type].color }"
/>
<span class="!text-sm font-weight-normal">{{ selectedView?.title }}</span>
<span class="!text-sm font-weight-normal"
><GeneralTruncateText>{{ selectedView?.title }}</GeneralTruncateText></span
>
<component :is="Icon" class="text-gray-500" :class="`nc-icon-${selectedView?.lock_type}`" />
<MdiMenuDown class="text-grey" />
</div>

4
packages/nc-gui-v2/pages/[projectType]/[projectId]/index.vue

@ -215,7 +215,9 @@ const copyAuthToken = async () => {
<MdiFolder class="group-hover:text-accent text-xl" />
<div class="flex flex-col">
<div class="text-lg group-hover:(!text-primary) font-semibold truncate">{{ project.title }}</div>
<div class="text-lg group-hover:(!text-primary) font-semibold">
<GeneralTruncateText>{{ project.title }}</GeneralTruncateText>
</div>
<div v-if="!isSharedBase" class="flex items-center gap-1">
<div class="group-hover:(!text-primary)">ID:</div>

2
packages/nc-gui-v2/pages/[projectType]/[projectId]/index/index.vue

@ -51,7 +51,7 @@ function onEdit(targetKey: number, action: 'add' | 'remove' | string) {
<div class="flex items-center gap-2">
<component :is="icon(tab)" class="text-sm" />
{{ tab.title }}
<GeneralTruncateText>{{ tab.title }}</GeneralTruncateText>
</div>
</template>
</a-tab-pane>

Loading…
Cancel
Save