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

feat(CompositeBar): add icon to collapsed list #272

Merged
merged 3 commits into from
Aug 5, 2024
Merged
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
7 changes: 7 additions & 0 deletions src/components/CompositeBar/Item/Item.scss
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,20 @@ $block: '.#{variables.$ns}composite-bar-item';
}

&__collapse-item {
--_--item-icon-color: var(--g-color-text-misc);

display: flex;
padding: 0 16px;
align-items: center;
width: 100%;
height: 100%;
cursor: pointer;

&-icon {
color: var(--gn-aside-header-item-icon-color, var(--_--item-icon-color));
margin-right: 10px;
}

#{$class}__title-adornment {
margin-right: 0;
}
Expand Down
16 changes: 14 additions & 2 deletions src/components/CompositeBar/Item/Item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,10 @@ function CollapsedPopup({
sortable={false}
onItemClick={onClose}
renderItem={(collapseItem) => {
const makeCollapseNode = ({title: titleEl}: MakeItemParams) => {
const makeCollapseNode = ({
title: titleEl,
icon: iconEl,
}: MakeItemParams) => {
const res = (
<div
className={b('collapse-item')}
Expand All @@ -307,6 +310,7 @@ function CollapsedPopup({
onItemClick?.(collapseItem, true, event);
}}
>
{iconEl}
{titleEl}
</div>
);
Expand All @@ -321,7 +325,15 @@ function CollapsedPopup({
};

const titleNode = renderItemTitle(collapseItem);
const params = {title: titleNode};
const iconNode = collapseItem.icon && (
<Icon
data={collapseItem.icon}
size={14}
className={b('collapse-item-icon')}
/>
);

const params = {title: titleNode, icon: iconNode};
const opts = {
compact: Boolean(compact),
collapsed: true,
Expand Down
Loading