feat(core): limit visible doc inline stack tags (#12647)
 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Tag lists now display a maximum of three tags, with an additional "+N Tags" indicator if more tags are present. - The "+N Tags" indicator label is localized based on your language settings. - **Style** - Improved spacing for the "+N Tags" indicator in tag lists. - **Bug Fixes** - Icons in certain property views are now only shown when available, preventing empty icon placeholders. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -10,7 +10,7 @@ export const StackProperty = ({
|
|||||||
return (
|
return (
|
||||||
<div className={styles.stackItem}>
|
<div className={styles.stackItem}>
|
||||||
<div className={styles.stackItemContent}>
|
<div className={styles.stackItemContent}>
|
||||||
<div className={styles.stackItemIcon}>{icon}</div>
|
{icon ? <div className={styles.stackItemIcon}>{icon}</div> : null}
|
||||||
<div className={styles.stackItemLabel}>{children}</div>
|
<div className={styles.stackItemLabel}>{children}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -27,3 +27,6 @@ export const groupHeaderLabel = style({
|
|||||||
export const filterValueMenu = style({
|
export const filterValueMenu = style({
|
||||||
top: 'calc(var(--radix-popper-anchor-height) - 18px) !important',
|
top: 'calc(var(--radix-popper-anchor-height) - 18px) !important',
|
||||||
});
|
});
|
||||||
|
export const moreTagsLabel = style({
|
||||||
|
marginLeft: 4,
|
||||||
|
});
|
||||||
|
|||||||
@@ -209,19 +209,31 @@ const TagIcon = ({ tag, size = 8 }: { tag: Tag; size?: number }) => {
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const TagsDocListProperty = ({ doc }: { doc: DocRecord }) => {
|
export const TagsDocListProperty = ({ doc }: { doc: DocRecord }) => {
|
||||||
|
const max = 3;
|
||||||
|
const t = useI18n();
|
||||||
const tagList = useService(TagService).tagList;
|
const tagList = useService(TagService).tagList;
|
||||||
const tags = useLiveData(tagList.tagsByPageId$(doc.id));
|
const tags = useLiveData(tagList.tagsByPageId$(doc.id));
|
||||||
|
|
||||||
|
const showRest = tags.length > max + 1;
|
||||||
|
const visibleTags = tags.length === max + 1 ? max + 1 : max;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{tags.map(tag => {
|
{tags.slice(0, visibleTags).map(tag => {
|
||||||
return (
|
return (
|
||||||
<StackProperty icon={<TagIcon tag={tag} />} key={tag.id}>
|
<StackProperty icon={<TagIcon tag={tag} />} key={tag.id}>
|
||||||
<TagName tag={tag} />
|
<TagName tag={tag} />
|
||||||
</StackProperty>
|
</StackProperty>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
{showRest ? (
|
||||||
|
<StackProperty icon={null}>
|
||||||
|
<span>+{tags.length - max}</span>
|
||||||
|
<span className={styles.moreTagsLabel}>{t['Tags']()}</span>
|
||||||
|
</StackProperty>
|
||||||
|
) : null}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user