Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Item: improve title and info wrapping #6447

Open
wants to merge 3 commits into
base: develop-minor
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions panel/lab/components/item/1_list/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,20 @@
theme="disabled"
/>
</k-lab-example>
<k-lab-example label="Wrap for long title/info">
<k-item
:buttons="[
{
icon: 'edit'
},
{
icon: 'trash'
}
]"
:image="{ src: 'https://picsum.photos/800/600' }"
info="With some more information than usual"
text="This is a nice item with a rather long title that should wrap"
/>
</k-lab-example>
</k-lab-examples>
</template>
16 changes: 16 additions & 0 deletions panel/lab/components/item/2_cards/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,21 @@
theme="disabled"
/>
</k-lab-example>
<k-lab-example label="Wrap for long title/info">
<k-item
:buttons="[
{
icon: 'edit'
},
{
icon: 'trash'
}
]"
:image="{ src: 'https://picsum.photos/800/600' }"
info="With some more information than usual"
layout="cards"
text="This is a nice item with a rather long title that should wrap"
/>
</k-lab-example>
</k-lab-examples>
</template>
16 changes: 16 additions & 0 deletions panel/lab/components/item/3_cardlets/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,21 @@
theme="disabled"
/>
</k-lab-example>
<k-lab-example label="Wrap for long title/info">
<k-item
:buttons="[
{
icon: 'edit'
},
{
icon: 'trash'
}
]"
:image="{ src: 'https://picsum.photos/800/600' }"
info="With some more information than usual"
layout="cardlets"
text="This is a nice item with a rather long title that should wrap"
/>
</k-lab-example>
</k-lab-examples>
</template>
42 changes: 12 additions & 30 deletions panel/src/components/Collection/Item.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

<!-- Content -->
<div class="k-item-content">
<h3 class="k-item-title" :title="title">
<h3 class="k-item-title" :title="title(text)">
<k-link v-if="link !== false" :target="target" :to="link">
<!-- eslint-disable-next-line vue/no-v-html -->
<span v-html="text ?? '–'" />
Expand All @@ -33,10 +33,11 @@
<span v-else v-html="text ?? '–'" />
</h3>
<!-- eslint-disable-next-line vue/no-v-html -->
<p v-if="info" class="k-item-info" v-html="info" />
<p v-if="info" :title="title(info)" class="k-item-info" v-html="info" />
</div>

<div
v-if="buttons?.length || options || $slots.options"
class="k-item-options"
:data-only-option="!buttons?.length || (!options && !$slots.options)"
>
Expand Down Expand Up @@ -119,17 +120,17 @@ export default {
computed: {
hasFigure() {
return this.image !== false && this.$helper.object.length(this.image) > 0;
},
title() {
return this.$helper.string
.stripHTML(this.$helper.string.unescapeHTML(this.text))
.trim();
}
},
methods: {
onOption(event) {
this.$emit("action", event);
this.$emit("option", event);
},
title(text) {
return this.$helper.string
.stripHTML(this.$helper.string.unescapeHTML(text))
.trim();
}
}
};
Expand All @@ -148,7 +149,7 @@ export default {
background: var(--color-white);
box-shadow: var(--shadow);
border-radius: var(--rounded);
height: var(--item-height);
min-height: var(--item-height);
container-type: inline-size;
}
.k-item:has(a:focus) {
Expand Down Expand Up @@ -214,7 +215,6 @@ export default {
--item-button-width: auto;

display: grid;
height: var(--item-height);
align-items: center;
grid-template-columns: 1fr auto;
}
Expand All @@ -226,13 +226,13 @@ export default {
--ratio: 1/1;
border-start-start-radius: var(--rounded);
border-end-start-radius: var(--rounded);
height: var(--item-height);
height: 100%;
}
.k-item[data-layout="list"] .k-item-content {
display: flex;
min-width: 0;
white-space: nowrap;
gap: var(--spacing-2);
flex-wrap: wrap;
column-gap: var(--spacing-4);
justify-content: space-between;
}
.k-item[data-layout="list"] .k-item-title,
Expand All @@ -241,23 +241,6 @@ export default {
white-space: nowrap;
text-overflow: ellipsis;
}
.k-item[data-layout="list"] .k-item-title {
flex-shrink: 1;
}
.k-item[data-layout="list"] .k-item-info {
flex-shrink: 2;
}

@container (max-width: 30rem) {
.k-item[data-layout="list"] .k-item-title {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.k-item[data-layout="list"] .k-item-info {
display: none;
}
}

.k-item[data-layout="list"] .k-sort-button {
--button-width: calc(1.5rem + var(--spacing-1));
Expand Down Expand Up @@ -306,7 +289,6 @@ export default {
border-start-start-radius: var(--rounded);
border-end-start-radius: var(--rounded);
aspect-ratio: auto;
height: var(--item-height);
}
.k-item[data-layout="cardlets"] .k-item-content {
grid-area: content;
Expand Down
Loading