Skip to content

Commit

Permalink
BZ-18892: feat: add an option to include icon within select component
Browse files Browse the repository at this point in the history
    - add an option to include icon within the select component
    - implement CSS styles to ensure proper alignment and display of icon
  • Loading branch information
adarshjuspay authored and murdore committed Apr 29, 2024
1 parent df25274 commit 3653ed3
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
34 changes: 31 additions & 3 deletions src/lib/Select/Select.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@
let selectedElementDiv: HTMLDivElement | null = null;
export let alt='';
export let properties: SelectProperties = {
placeholder: '',
label: '',
allItems: [],
selectedItem: '',
selectedItemLabel: null,
showSelectedItemInDropdown: false,
selectMultipleItems: false
selectMultipleItems: false,
iconPath:''
};
const applyButtonProps: ButtonProperties = {
Expand Down Expand Up @@ -139,6 +141,11 @@
role="button"
tabindex="0"
>
{#if properties.iconPath !== null && properties.iconPath !== ""}
<div class="icon-container">
<img src={properties.iconPath} class="icon" alt={alt} />
</div>
{/if}
{#if properties.selectMultipleItems && Array.isArray(properties.selectedItemLabel) && Array.isArray(properties.selectedItem)}
{#if properties.selectedItem.length === 0}
{properties.placeholder}
Expand Down Expand Up @@ -216,8 +223,8 @@
}
.arrow {
height: 16px;
width: 16px;
height:var(--dropdown-arrow-icon-height, 16px);
width: var(--dropdown-arrow-icon-width, 16px);
transform: rotate(-0.25turn);
transition: transform 0.1s;
}
Expand Down Expand Up @@ -255,6 +262,7 @@
.non-selected-items {
display: var(--non-selected-display);
background-color: var(--non-selected-item-bgcolor, #ffffff);
color: var(--non-selected-item-color);
box-shadow: 0px 1px 8px #2f537733;
width: var(--non-selected-width, fit-content);
min-width: var(--non-selected-min-width, 100%);
Expand All @@ -264,6 +272,7 @@
z-index: 10;
word-wrap: var(--non-selected-word-break, break-word);
white-space: var(--non-selected-white-space);
font-weight: var(--non-select-font-weight, 500)
}
::-webkit-scrollbar {
Expand Down Expand Up @@ -296,4 +305,23 @@
white-space: var(--multipleSelect-btn-white-space, nowrap);
padding: var(--multipleSelect-btn-padding, 2px);
}
.icon {
width: var(--select-icon-width,16px);
height: var(--select-icon-height,16px);
}
.icon-container{
width: var(--select-icon-container-width,32px);
height: var(--select-icon-container-height,32px);
gap: var(--select-icon-container-gap,0px);
border-radius: var(--select-icon-container-border-radius,333px);
opacity: var(--select-icon-container-opacity,0px);
background: var(--select-icon-container-background,#EEEEEE);
display: flex;
align-items: center;
justify-content: center;
margin: var(--select-icon-container-margin,0px 8px 0px 0px);
padding: var(--select-icon-container-padding);
}
</style>
1 change: 1 addition & 0 deletions src/lib/Select/properties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ export type SelectProperties = {
selectedItemLabel: string | string[] | null;
showSelectedItemInDropdown: boolean;
selectMultipleItems: boolean;
iconPath:string | null;
};

0 comments on commit 3653ed3

Please sign in to comment.