bruno/packages/grafnode-components/src/components/Sidebar/Collections/Collection/index.js

48 lines
1.4 KiB
JavaScript
Raw Normal View History

2021-12-03 20:37:38 +01:00
import React from 'react';
import { IconChevronRight } from '@tabler/icons';
import CollectionItem from './CollectionItem';
import classnames from 'classnames';
import StyledWrapper from './StyledWrapper';
const Collection = ({collection, actions, dispatch, activeRequestTabId}) => {
const iconClassName = classnames({
'rotate-90': collection.collapsed
});
const handleClick = () => {
dispatch({
type: actions.SIDEBAR_COLLECTION_CLICK,
id: collection.id
});
};
return (
<StyledWrapper className="flex flex-col">
<div className="flex py-1 collection-name items-center" onClick={handleClick}>
<IconChevronRight size={16} strokeWidth={2} className={iconClassName} style={{width:16, color: 'rgb(160 160 160)'}}/>
<span className="ml-1">{collection.name}</span>
</div>
<div>
{collection.collapsed ? (
<div>
{collection.items && collection.items.length ? collection.items.map((i) => {
return <CollectionItem
key={i.name}
item={i}
collectionId={collection.id}
actions={actions}
dispatch={dispatch}
activeRequestTabId={activeRequestTabId}
/>
}) : null}
</div>
) : null}
</div>
</StyledWrapper>
);
};
export default Collection;