Skip to content

Commit c72a19f

Browse files
spaceokasperbirch1
authored andcommitted
Expand dropdown component to use inner classes
and used that for correct BEM naming of facet line dropdowns
1 parent 5f544a6 commit c72a19f

File tree

3 files changed

+30
-4
lines changed

3 files changed

+30
-4
lines changed

src/stories/Library/dropdown/Dropdown.tsx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import clsx from "clsx";
2+
13
export type DropdownItem = {
24
title: string;
35
href?: string;
@@ -9,13 +11,15 @@ export type DropdownProps = {
911
ariaLabel: string;
1012
arrowIcon: "triangles" | "chevron";
1113
classNames?: string;
14+
innerClassNames?: { select?: string; option?: string; arrowWrapper?: string };
1215
};
1316

1417
export const Dropdown: React.FC<DropdownProps> = ({
1518
arrowIcon,
1619
ariaLabel,
1720
list,
1821
classNames,
22+
innerClassNames,
1923
}) => {
2024
const Icon = () => {
2125
if (arrowIcon === "triangles") {
@@ -48,21 +52,28 @@ export const Dropdown: React.FC<DropdownProps> = ({
4852
return null;
4953
};
5054

55+
const classes = {
56+
root: clsx("dropdown", classNames),
57+
select: clsx("dropdown__select", innerClassNames?.select),
58+
option: clsx("dropdown__option", innerClassNames?.option),
59+
arrowWrapper: clsx("dropdown__arrows", innerClassNames?.arrowWrapper),
60+
};
61+
5162
return (
52-
<div className={`dropdown ${classNames || ""}`}>
53-
<select className="dropdown__select" aria-label={ariaLabel}>
63+
<div className={classes.root}>
64+
<select className={classes.select} aria-label={ariaLabel}>
5465
{list.map(({ title, disabled }, index) => (
5566
<option
5667
key={index}
57-
className="dropdown__option"
68+
className={classes.option}
5869
value={title}
5970
disabled={disabled !== undefined ? disabled : false}
6071
>
6172
{title}
6273
</option>
6374
))}
6475
</select>
65-
<div className="dropdown__arrows">
76+
<div className={classes.arrowWrapper}>
6677
<Icon />
6778
</div>
6879
</div>

src/stories/Library/dropdown/dropdown.scss

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,14 @@
5252
margin-top: 4px;
5353
transform: rotateZ(180deg);
5454
}
55+
56+
.dropdown__select--inline {
57+
@extend %text-tags;
58+
height: 100%;
59+
padding: $s-sm $s-md;
60+
min-width: 200px;
61+
}
62+
63+
.dropdown__arrows--inline {
64+
height: 100%;
65+
}

src/stories/Library/search-result-page/FacetLine.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ const FacetLine: FC<FacetLineProps> = ({ items }) => {
3434
list={[{ title }, ...terms]}
3535
arrowIcon="chevron"
3636
classNames="dropdown--grey-borders"
37+
innerClassNames={{
38+
select: "dropdown__select--inline",
39+
arrowWrapper: "dropdown__arrows--inline ",
40+
}}
3741
/>
3842
</li>
3943
);

0 commit comments

Comments
 (0)