Skip to content

Commit 5681449

Browse files
fix: Optimize the website name badge style. (#12538)
1 parent 88849e6 commit 5681449

2 files changed

Lines changed: 71 additions & 8 deletions

File tree

frontend/src/views/website/website/domain/index.vue

Lines changed: 71 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div class="name-row">
3-
<div>
3+
<div class="name-main">
44
<el-form :model="formData" :rules="rules" ref="formRef" v-if="isEditing" @submit.prevent>
55
<el-form-item prop="domainName" class="inline-form-item">
66
<el-input
@@ -13,12 +13,28 @@
1313
/>
1414
</el-form-item>
1515
</el-form>
16-
<el-text v-else type="primary" class="cursor-pointer" @click="openConfig(row.id)">
17-
{{ row.primaryDomain }}
18-
<span class="text-gray-400" v-if="isPunycoded(row.primaryDomain)">
19-
({{ GetPunyCodeDomain(row.primaryDomain) }})
20-
</span>
21-
</el-text>
16+
<el-tooltip
17+
v-else
18+
effect="dark"
19+
placement="bottom-start"
20+
popper-class="website-domain-tooltip"
21+
:show-after="300"
22+
:disabled="!shouldShowDomainTooltip(row.primaryDomain)"
23+
>
24+
<template #content>
25+
<div class="website-domain-tooltip__content">
26+
{{ getDisplayDomain(row.primaryDomain) }}
27+
</div>
28+
</template>
29+
<el-text type="primary" class="cursor-pointer domain-text" @click="openConfig(row.id)">
30+
<span class="domain-text__content">
31+
{{ row.primaryDomain }}
32+
<span class="text-gray-400" v-if="isPunycoded(row.primaryDomain)">
33+
({{ GetPunyCodeDomain(row.primaryDomain) }})
34+
</span>
35+
</span>
36+
</el-text>
37+
</el-tooltip>
2238
<el-popover
2339
placement="right"
2440
trigger="hover"
@@ -181,15 +197,53 @@ const getUrl = (domain: Website.Domain, website: Website.Website): string => {
181197
const favoriteWebsite = (row: Website.Website) => {
182198
emit('favoriteChange', row);
183199
};
200+
201+
const getDisplayDomain = (domain: string) => {
202+
if (!isPunycoded(domain)) {
203+
return domain;
204+
}
205+
return `${domain} (${GetPunyCodeDomain(domain)})`;
206+
};
207+
208+
const shouldShowDomainTooltip = (domain: string) => {
209+
return getDisplayDomain(domain).length > 30;
210+
};
184211
</script>
185212

186213
<style lang="css" scoped>
187214
.name-row {
188215
display: flex;
189216
align-items: center;
190217
justify-content: space-between;
218+
gap: 8px;
191219
width: 100%;
192220
}
221+
222+
.name-main {
223+
display: flex;
224+
align-items: center;
225+
flex: 1;
226+
min-width: 0;
227+
}
228+
229+
.domain-text {
230+
display: inline-flex;
231+
align-items: center;
232+
flex: 1;
233+
width: 0;
234+
min-width: 0;
235+
max-width: 100%;
236+
}
237+
238+
.domain-text__content {
239+
display: inline-block;
240+
min-width: 0;
241+
max-width: 100%;
242+
overflow: hidden;
243+
text-overflow: ellipsis;
244+
white-space: nowrap;
245+
}
246+
193247
:deep(.el-form) {
194248
margin: 0;
195249
line-height: 1;
@@ -207,4 +261,14 @@ const favoriteWebsite = (row: Website.Website) => {
207261
.domain-input {
208262
width: 200px;
209263
}
264+
265+
:deep(.website-domain-tooltip) {
266+
max-width: min(720px, calc(100vw - 120px));
267+
}
268+
269+
.website-domain-tooltip__content {
270+
white-space: normal;
271+
word-break: break-all;
272+
line-height: 1.5;
273+
}
210274
</style>

frontend/src/views/website/website/index.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@
9090
prop="primaryDomain"
9191
min-width="250px"
9292
sortable
93-
show-overflow-tooltip
9493
>
9594
<template #default="{ row, $index }">
9695
<Domain

0 commit comments

Comments
 (0)