diff --git a/src/bundle/Resources/public/js/scripts/core/dropdown.js b/src/bundle/Resources/public/js/scripts/core/dropdown.js index 1818361439..9210d5e104 100644 --- a/src/bundle/Resources/public/js/scripts/core/dropdown.js +++ b/src/bundle/Resources/public/js/scripts/core/dropdown.js @@ -125,6 +125,10 @@ if (checkbox) { checkbox.checked = false; } + + if (option.classList.contains('ibexa-dropdown__item--placeholder')) { + option.setAttribute('hidden', 'hidden'); + } }); this.selectedItemsContainer.innerHTML = ''; this.selectedItemsContainer.insertAdjacentHTML('beforeend', this.selectedItemsContainer.dataset.placeholderTemplate); diff --git a/src/bundle/Resources/public/scss/_dropdown.scss b/src/bundle/Resources/public/scss/_dropdown.scss index d226bb4dba..8337e92240 100644 --- a/src/bundle/Resources/public/scss/_dropdown.scss +++ b/src/bundle/Resources/public/scss/_dropdown.scss @@ -176,7 +176,7 @@ .ibexa-input-text-wrapper { width: 100%; - padding: calculateRem(8px) calculateRem(12px); + padding: calculateRem(8px) calculateRem(8px) 0; &__actions { right: calculateRem(16px); @@ -196,7 +196,7 @@ &__items-list { list-style: none; - padding: calculateRem(8.5px); + padding: calculateRem(8px); margin: 0; overflow-y: auto; } @@ -214,11 +214,12 @@ } &__item { - padding: calculateRem(9px) calculateRem(15px); + margin-top: calculateRem(8px); + padding: calculateRem(9.5px) calculateRem(16px); line-height: calculateRem(21px); min-height: calculateRem(40px); transition: background $ibexa-admin-transition-duration $ibexa-admin-transition; - border-radius: $ibexa-border-radius; + border-radius: calculateRem(4px); cursor: pointer; display: flex; align-items: center; @@ -227,6 +228,14 @@ display: none; } + &:first-child { + margin-top: 0; + + &[hidden] + li { + margin-top: 0; + } + } + &--selected { position: relative; padding-right: calculateRem(36px); @@ -236,6 +245,10 @@ } } + &--placeholder { + pointer-events: none; + } + .ibexa-input { margin: 0 calculateRem(16px) 0 0; } @@ -245,7 +258,12 @@ } &:hover { - background-color: $ibexa-color-light-300; + background-color: $ibexa-color-light-400; + color: $ibexa-color-primary; + } + + &:active { + color: initial; } &[disabled] { @@ -272,13 +290,23 @@ } &__item-group { + padding-bottom: calculateRem(8px); + border-bottom: calculateRem(1px) solid $ibexa-color-light; + &--hidden { display: none; } + + &:last-child { + border-bottom: none; + padding-bottom: 0; + } } &__item-group-label { - font-weight: bold; + color: $ibexa-color-dark-400; + font-size: calculateRem(10px); + padding: calculateRem(8px) calculateRem(16px); } &__item-group-list { diff --git a/src/bundle/Resources/views/themes/admin/ui/component/dropdown/dropdown.html.twig b/src/bundle/Resources/views/themes/admin/ui/component/dropdown/dropdown.html.twig index 90121c5de4..c806b45cc2 100644 --- a/src/bundle/Resources/views/themes/admin/ui/component/dropdown/dropdown.html.twig +++ b/src/bundle/Resources/views/themes/admin/ui/component/dropdown/dropdown.html.twig @@ -145,6 +145,9 @@ diff --git a/src/bundle/Resources/views/themes/admin/ui/component/dropdown/dropdown_item.html.twig b/src/bundle/Resources/views/themes/admin/ui/component/dropdown/dropdown_item.html.twig index ba95fb9c86..71ca20f2b4 100644 --- a/src/bundle/Resources/views/themes/admin/ui/component/dropdown/dropdown_item.html.twig +++ b/src/bundle/Resources/views/themes/admin/ui/component/dropdown/dropdown_item.html.twig @@ -1,27 +1,45 @@ +{% trans_default_domain 'dropdown' %} +{% import "@ibexadesign/ui/component/macros.html.twig" as html %} + {% set item_label = translation_domain is same as(false) ? choice.label : choice.label|trans({}, translation_domain) %} {% set preferred_choice = preferred_choice|default(false) %} +{% set placeholder_choice = choice.placeholder|default(false) %} {% if choice.choices is defined %}
  • {% else %} {% set is_selected = custom_form ? choice.value == value : choice is selectedchoice(value) %} -
  • + {% set dropdown_item_attr = dropdown_item_attr|default({})|merge({ + 'data-value': choice.value, + 'data-filter-value': item_label, + 'data-choice-icon': choice.icon is defined ? choice.icon : null, + class: ('ibexa-dropdown__item ' + ~ (preferred_choice ? 'ibexa-dropdown__item--preferred-choice ') + ~ (is_selected ? 'ibexa-dropdown__item--selected ') + ~ (placeholder_choice ? 'ibexa-dropdown__item--placeholder '))|trim, + }) %} + + {% if placeholder_choice %} + {% set dropdown_item_attr = dropdown_item_attr|merge({ + hidden: 'hidden' + }) %} + {% endif %} + +
  • {% if multiple is defined and multiple %} {% endif %} diff --git a/src/bundle/Resources/views/themes/admin/ui/component/modal/modal.html.twig b/src/bundle/Resources/views/themes/admin/ui/component/modal/modal.html.twig index 6c7fcd38e4..27c774f7d3 100644 --- a/src/bundle/Resources/views/themes/admin/ui/component/modal/modal.html.twig +++ b/src/bundle/Resources/views/themes/admin/ui/component/modal/modal.html.twig @@ -63,7 +63,7 @@ {% set close_btn %}