Skip to content

Commit 96707a6

Browse files
author
Ibrahim Haizel
committed
style: add configurable divider padding and update item dividers for improved layout
1 parent ce9bf41 commit 96707a6

File tree

1 file changed

+33
-6
lines changed

1 file changed

+33
-6
lines changed

src/lib/components/ui/MultiSelectSearchAutocomplete.svelte

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
choicesItemBackgroundColor = "#f3f2f1",
6464
choicesItemBorderColor = "#b1b4b6",
6565
choicesItemTextColor = "black",
66+
choicesItemDividerPadding = "10px",
6667
...attributes
6768
}: {
6869
id: string;
@@ -96,6 +97,7 @@
9697
choicesItemBackgroundColor?: string;
9798
choicesItemBorderColor?: string;
9899
choicesItemTextColor?: string;
100+
choicesItemDividerPadding?: string;
99101
} & Omit<
100102
import("svelte/elements").HTMLSelectAttributes,
101103
| "id"
@@ -958,7 +960,7 @@
958960

959961
<div
960962
class="gem-c-select-with-search"
961-
style={`--cross-icon-url: url("${crossIconUrl}"); --choices-item-bg-color: ${choicesItemBackgroundColor}; --choices-item-border-color: ${choicesItemBorderColor}; --choices-item-text-color: ${choicesItemTextColor};`}
963+
style={`--cross-icon-url: url("${crossIconUrl}"); --choices-item-bg-color: ${choicesItemBackgroundColor}; --choices-item-border-color: ${choicesItemBorderColor}; --choices-item-text-color: ${choicesItemTextColor}; --choices-item-divider-padding: ${choicesItemDividerPadding};`}
962964
>
963965
{#snippet rightIcon()}
964966
<button
@@ -1703,23 +1705,48 @@
17031705
border-top-width: 2px;
17041706
border-bottom-width: 0;
17051707
}
1708+
1709+
/* Remove the full-width divider and add pseudo-element dividers */
17061710
:global(.gem-c-select-with-search .choices__list--dropdown .choices__item),
17071711
:global(
17081712
.gem-c-select-with-search .choices__list[aria-expanded] .choices__item
17091713
) {
1710-
position: relative;
1711-
border-bottom: 1px solid #b1b4b6;
1714+
border-bottom: none;
1715+
position: relative; /* for the ::after divider */
17121716
}
1717+
1718+
/* Inset divider with configurable padding */
17131719
:global(
1714-
.gem-c-select-with-search .choices__list--dropdown .choices__item:last-child
1720+
.gem-c-select-with-search .choices__list--dropdown .choices__item::after
17151721
),
17161722
:global(
17171723
.gem-c-select-with-search
17181724
.choices__list[aria-expanded]
1719-
.choices__item:last-child
1725+
.choices__item::after
17201726
) {
1721-
border-bottom: 0;
1727+
content: "";
1728+
position: absolute;
1729+
left: var(--choices-item-divider-padding, 15px);
1730+
right: var(--choices-item-divider-padding, 15px);
1731+
bottom: 0;
1732+
height: 1px;
1733+
background: var(--choices-item-border-color, #b1b4b6);
17221734
}
1735+
1736+
/* No divider on the last item */
1737+
:global(
1738+
.gem-c-select-with-search
1739+
.choices__list--dropdown
1740+
.choices__item:last-child::after
1741+
),
1742+
:global(
1743+
.gem-c-select-with-search
1744+
.choices__list[aria-expanded]
1745+
.choices__item:last-child::after
1746+
) {
1747+
display: none;
1748+
}
1749+
17231750
:global(
17241751
.gem-c-select-with-search
17251752
.choices__list--dropdown

0 commit comments

Comments
 (0)