Skip to content

Commit 02eb756

Browse files
authored
Merge pull request #62 from kleros/feat/dropdown-bubble
feat: dropdown-cascader-number-bubble
2 parents 7ee7d27 + 7192553 commit 02eb756

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

src/App.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const StyledDiv = styled.div`
3232
align-items: center;
3333
flex-wrap: wrap;
3434
padding: 36px 36px;
35+
overflow: scroll;
3536
background: ${(props) => props.theme.klerosUIComponentsLightBackground};
3637
transition: background ease
3738
${(props) => props.theme.klerosUIComponentsTransitionSpeed};

src/lib/dropdown/base-item.tsx

+20
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,27 @@ const StyledDot = styled(Dot)`
5151
margin-right: 8px;
5252
`;
5353

54+
const CountDisplay = styled.label`
55+
width: 24px;
56+
height: 24px;
57+
border: 1px solid ${({ theme }) => theme.klerosUIComponentsPrimaryBlue};
58+
border-radius: 100%;
59+
60+
display: flex;
61+
align-items: center;
62+
justify-content: center;
63+
64+
font-size: 12px;
65+
color: ${({ theme }) => theme.klerosUIComponentsPrimaryBlue};
66+
`;
5467
export interface IBaseItem
5568
extends IItem,
5669
Omit<React.HTMLAttributes<HTMLDivElement>, "onClick"> {
5770
text: string;
5871
Icon?: React.FC<React.SVGAttributes<SVGElement>>;
5972
icon?: React.ReactNode;
6073
dot?: string;
74+
childrenCount?: number;
6175
onClick?: () => void;
6276
}
6377

@@ -67,6 +81,7 @@ const BaseItem: React.FC<IBaseItem> = ({
6781
icon,
6882
dot,
6983
onClick,
84+
childrenCount,
7085
...props
7186
}) => (
7287
<Item
@@ -76,6 +91,11 @@ const BaseItem: React.FC<IBaseItem> = ({
7691
{icon ?? (Icon && <Icon className="item-icon" />)}
7792
{dot && <StyledDot color={dot} />}
7893
<StyledText>{text}</StyledText>
94+
{childrenCount !== undefined ? (
95+
<CountDisplay className="count-display">
96+
<span>{childrenCount}</span>
97+
</CountDisplay>
98+
) : null}
7999
</Item>
80100
);
81101

src/lib/dropdown/cascader/item-container.tsx

+14
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,19 @@ export const StyledBaseItem = styled(BaseItem)`
1616
? theme.klerosUIComponentsPrimaryBlue
1717
: theme.klerosUIComponentsStroke};
1818
}
19+
20+
.count-display {
21+
position: absolute;
22+
right: 32px;
23+
border-color: ${({ selected, theme }) =>
24+
selected
25+
? theme.klerosUIComponentsPrimaryBlue
26+
: theme.klerosUIComponentsStroke};
27+
color: ${({ selected, theme }) =>
28+
selected
29+
? theme.klerosUIComponentsPrimaryBlue
30+
: theme.klerosUIComponentsStroke};
31+
}
1932
`;
2033

2134
export interface IItem {
@@ -42,6 +55,7 @@ const ItemContainer: React.FC<IItemContainer> = ({
4255
text={item.label}
4356
Icon={item.children && LightArrow}
4457
onClick={() => onChange(item)}
58+
childrenCount={item.children?.length}
4559
selected={item.value === layer.selected}
4660
/>
4761
))}

0 commit comments

Comments
 (0)