Skip to content

Commit

Permalink
feat: dropdown-cascader-number-bubble
Browse files Browse the repository at this point in the history
  • Loading branch information
Harman-singh-waraich committed Dec 30, 2024
1 parent 7ee7d27 commit 7192553
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const StyledDiv = styled.div`
align-items: center;
flex-wrap: wrap;
padding: 36px 36px;
overflow: scroll;
background: ${(props) => props.theme.klerosUIComponentsLightBackground};
transition: background ease
${(props) => props.theme.klerosUIComponentsTransitionSpeed};
Expand Down
20 changes: 20 additions & 0 deletions src/lib/dropdown/base-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,27 @@ const StyledDot = styled(Dot)`
margin-right: 8px;
`;

const CountDisplay = styled.label`
width: 24px;
height: 24px;
border: 1px solid ${({ theme }) => theme.klerosUIComponentsPrimaryBlue};
border-radius: 100%;
display: flex;
align-items: center;
justify-content: center;
font-size: 12px;
color: ${({ theme }) => theme.klerosUIComponentsPrimaryBlue};
`;
export interface IBaseItem
extends IItem,
Omit<React.HTMLAttributes<HTMLDivElement>, "onClick"> {
text: string;
Icon?: React.FC<React.SVGAttributes<SVGElement>>;
icon?: React.ReactNode;
dot?: string;
childrenCount?: number;
onClick?: () => void;
}

Expand All @@ -67,6 +81,7 @@ const BaseItem: React.FC<IBaseItem> = ({
icon,
dot,
onClick,
childrenCount,
...props
}) => (
<Item
Expand All @@ -76,6 +91,11 @@ const BaseItem: React.FC<IBaseItem> = ({
{icon ?? (Icon && <Icon className="item-icon" />)}
{dot && <StyledDot color={dot} />}
<StyledText>{text}</StyledText>
{childrenCount !== undefined ? (
<CountDisplay className="count-display">
<span>{childrenCount}</span>
</CountDisplay>
) : null}
</Item>
);

Expand Down
14 changes: 14 additions & 0 deletions src/lib/dropdown/cascader/item-container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@ export const StyledBaseItem = styled(BaseItem)`
? theme.klerosUIComponentsPrimaryBlue
: theme.klerosUIComponentsStroke};
}
.count-display {
position: absolute;
right: 32px;
border-color: ${({ selected, theme }) =>
selected
? theme.klerosUIComponentsPrimaryBlue
: theme.klerosUIComponentsStroke};
color: ${({ selected, theme }) =>
selected
? theme.klerosUIComponentsPrimaryBlue
: theme.klerosUIComponentsStroke};
}
`;

export interface IItem {
Expand All @@ -42,6 +55,7 @@ const ItemContainer: React.FC<IItemContainer> = ({
text={item.label}
Icon={item.children && LightArrow}
onClick={() => onChange(item)}
childrenCount={item.children?.length}
selected={item.value === layer.selected}
/>
))}
Expand Down

0 comments on commit 7192553

Please sign in to comment.