@use "sass:list"; @use "sass:color"; @use "styles/library" as library; $dropdown_bg: oklch(1 0 0); // #FFFFFF $dropdown_border_color: oklch(0 0 0 / 20%); $dropdown_hover: oklch(0.9702 0 0); // #F5F5F5 $dropdown_height: 40px; $dropdown_border_radius: 8px; $dropdown_animation_timing: cubic-bezier(0.4, 0, 0.2, 1); $dropdown_animation_duration: 0.2s; :host { display: inline-block; position: relative; padding: 0; margin: 0; background-color: $dropdown_bg; border-radius: $dropdown_border_radius; box-shadow: 0 0 0 1px $dropdown_border_color inset; cursor: pointer; max-width: 100%; --dropdown-duration: #{$dropdown_animation_duration}; &.reduce-motion { --dropdown-duration: 0s; } } .dropdown-box { display: flex; align-items: center; padding: 0 10px; height: $dropdown_height; box-sizing: border-box; gap: 8px; .prefix-icon { width: 24px; height: 24px; flex-shrink: 0; user-select: none; } .placeholder { flex-grow: 1; font-size: 18px; height: 24px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; user-select: none; align-content: center; } .chevron { width: 24px; height: 24px; flex-shrink: 0; transition: transform var(--dropdown-duration) $dropdown_animation_timing; user-select: none; &.open { transform: rotate(180deg); } } } .dropdown-list { position: absolute; top: calc(100% + 4px); left: 0; width: 100%; padding: 0; margin: 0; list-style: none; background-color: $dropdown_bg; border-radius: $dropdown_border_radius; z-index: 1000; max-height: 240px; overflow-y: auto; box-shadow: 0 4px 12px oklch(0 0 0 / 10%); // rgba(0, 0, 0, 0.1) animation: slideIn var(--dropdown-duration) $dropdown_animation_timing; &::after { content: ""; position: absolute; top: 0; left: 0; right: 0; bottom: 0; border-radius: $dropdown_border_radius; box-shadow: 0 0 0 1px $dropdown_border_color inset; pointer-events: none; z-index: 1001; } @keyframes slideIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } } } .dropdown-item { display: flex; align-items: center; height: 40px; padding: 0 16px; position: relative; align-content: center; transition: background-color var(--dropdown-duration) $dropdown_animation_timing; &:hover, &.focused { background-color: $dropdown_hover; } &.selected { background-color: list.nth(library.$brand_palette, 1); color: list.nth(library.$brand_palette, 5); font-weight: 600; } }