Files
prestashop-entity-selector/sources/scss/components/_chips.scss
myprestarocks acbcf55b1c Feature: enhanced chips toolbar with sorting and load select
Chips toolbar improvements:
- Filter input now uses all available space (flex: 1)
- Added sort dropdown: Order added, Name A-Z, Name Z-A
- Changed "Show X more" button to select dropdown pattern
  - Load 20, 50, 100, or All
  - Shows remaining count
- Collapse button to return to default view

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 19:44:56 +00:00

733 lines
18 KiB
SCSS

/**
* Chips Component
* Entity chips, selection pills, tags
*/
@use '../variables' as *;
@use '../mixins' as *;
.target-conditions-trait,
.entity-selector-trait {
// Chips container wrapper with toolbar
.chips-wrapper {
display: flex;
flex-direction: column;
margin-top: $es-spacing-sm;
background: $es-slate-50;
border: 1px solid $es-border-color;
border-radius: $es-radius-md;
overflow: hidden;
}
// Chips toolbar - integrated filter bar inside chips area
.chips-toolbar {
display: none; // Hidden by default, shown via JS when chips exist
align-items: center;
gap: $es-spacing-xs;
padding: $es-spacing-sm $es-spacing-md;
padding-bottom: 0; // No bottom padding - chips will provide spacing
background: transparent; // Same as chips area
&.has-chips {
display: flex;
}
}
// Filter input styled as a search chip - takes available space
.chips-filter-group {
display: flex;
align-items: center;
gap: 0.25rem;
flex: 1; // Take available space
min-width: 0; // Allow shrinking
padding: 0.25rem 0.5rem;
background: $es-white;
border: 1px solid $es-border-color;
border-radius: $es-radius-full;
transition: all $es-transition-fast;
&:focus-within {
border-color: $es-primary;
box-shadow: 0 0 0 2px rgba($es-primary, 0.1);
}
// Search icon inside the pill
> i {
color: $es-text-muted;
font-size: 12px;
flex-shrink: 0;
}
}
.chips-search-input,
input.chips-search-input,
input.chips-search-input[type="text"] {
flex: 1 !important;
min-width: 60px !important;
max-width: none !important; // No max - use available space
width: 100% !important;
height: auto !important;
padding: 0.125rem 0 !important;
border: none !important;
border-radius: 0 !important;
background: transparent !important;
font-size: $es-font-size-xs !important;
color: $es-text-primary;
box-shadow: none !important;
&:focus {
outline: none !important;
border: none !important;
box-shadow: none !important;
}
&::placeholder {
color: $es-text-muted;
font-size: $es-font-size-xs;
}
}
// Sort dropdown for chips
.chips-sort-select,
select.chips-sort-select {
appearance: none;
padding: 0.25rem 1.5rem 0.25rem 0.5rem !important;
border: 1px solid $es-border-color !important;
border-radius: $es-radius-full !important;
background: $es-white url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8' viewBox='0 0 8 8'%3E%3Cpath fill='%23666' d='M0 2l4 4 4-4z'/%3E%3C/svg%3E") no-repeat right 0.5rem center !important;
background-size: 8px !important;
font-size: 11px !important;
color: $es-text-secondary;
cursor: pointer;
transition: all $es-transition-fast;
height: auto !important;
min-height: 0 !important;
line-height: 1.2 !important;
&:hover {
border-color: $es-primary !important;
}
&:focus {
outline: none !important;
border-color: $es-primary !important;
box-shadow: 0 0 0 2px rgba($es-primary, 0.1) !important;
}
}
// Count badge - smaller, pill style
.chips-count {
display: inline-flex;
align-items: center;
gap: 0.125rem;
padding: 0.125rem 0.5rem;
background: $es-slate-200;
color: $es-text-secondary;
font-size: 11px;
font-weight: $es-font-weight-semibold;
border-radius: $es-radius-full;
white-space: nowrap;
&.has-filter {
background: $es-cyan-100;
color: $es-cyan-700;
}
.count-filtered {
font-weight: $es-font-weight-bold;
}
.count-separator {
opacity: 0.6;
margin: 0 0.125rem;
}
}
.chips-actions {
display: flex;
align-items: center;
gap: $es-spacing-xs;
margin-left: auto;
}
// Clear button - subtle, chip-like
.btn-chips-clear {
@include button-reset;
display: flex;
align-items: center;
gap: 0.25rem;
padding: 0.25rem 0.5rem;
color: $es-danger;
font-size: 11px;
font-weight: $es-font-weight-medium;
background: rgba($es-danger, 0.1);
border-radius: $es-radius-full;
transition: all $es-transition-fast;
&:hover {
background: $es-danger;
color: $es-white;
}
i {
font-size: 10px;
}
.clear-text {
// Hide text on small screens, keep icon
@media (max-width: 480px) {
display: none;
}
}
}
// Chips container - flows naturally from toolbar
.entity-chips {
display: flex;
flex-wrap: wrap;
gap: $es-spacing-xs;
padding: $es-spacing-sm $es-spacing-md $es-spacing-md;
min-height: 40px;
max-height: 300px;
overflow-y: auto;
&:empty {
display: none;
}
}
// Load more section with select dropdown
.chips-load-more {
display: flex;
align-items: center;
justify-content: center;
gap: $es-spacing-sm;
padding: $es-spacing-sm $es-spacing-md;
background: transparent;
border-top: 1px dashed $es-border-color;
.load-more-label {
font-size: $es-font-size-xs;
color: $es-text-muted;
}
.load-more-select,
select.load-more-select {
appearance: none;
padding: 0.25rem 1.75rem 0.25rem 0.5rem !important;
border: 1px solid $es-border-color !important;
border-radius: $es-radius-sm !important;
background: $es-white url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8' viewBox='0 0 8 8'%3E%3Cpath fill='%23666' d='M0 2l4 4 4-4z'/%3E%3C/svg%3E") no-repeat right 0.5rem center !important;
background-size: 8px !important;
font-size: $es-font-size-xs !important;
font-weight: $es-font-weight-medium;
color: $es-primary;
cursor: pointer;
transition: all $es-transition-fast;
height: auto !important;
min-height: 0 !important;
line-height: 1.3 !important;
&:hover {
border-color: $es-primary !important;
background-color: $es-primary-light !important;
}
&:focus {
outline: none !important;
border-color: $es-primary !important;
box-shadow: 0 0 0 2px rgba($es-primary, 0.1) !important;
}
}
.load-more-remaining {
font-size: $es-font-size-xs;
color: $es-text-muted;
}
}
// Individual chip
.entity-chip {
display: inline-flex;
align-items: center;
gap: 0.375rem;
padding: 0.25rem 0.5rem;
background: $es-slate-100;
color: $es-text-secondary;
font-size: $es-font-size-xs;
font-weight: $es-font-weight-medium;
border-radius: $es-radius-full;
transition: all $es-transition-fast;
&:hover {
background: $es-slate-200;
}
// Chip with image
&.has-image {
padding-left: 0.25rem;
}
// Hidden by search filter or pagination
&.chip-filtered-out,
&.chip-paginated-out {
display: none;
}
}
.chip-image {
width: 20px;
height: 20px;
object-fit: cover;
border-radius: 50%;
flex-shrink: 0;
}
.chip-icon {
display: flex;
align-items: center;
justify-content: center;
font-size: 12px;
color: $es-text-muted;
flex-shrink: 0;
// Product/entity images inside chip
img {
width: 20px;
height: 20px;
object-fit: cover;
border-radius: $es-radius-sm;
}
}
.chip-text,
.chip-name {
// Show full name, no truncation
word-break: break-word;
}
.chip-remove {
@include button-reset;
display: flex;
align-items: center;
justify-content: center;
width: 16px;
height: 16px;
margin-left: 0.125rem;
color: $es-text-muted;
border-radius: 50%;
flex-shrink: 0;
transition: all $es-transition-fast;
&:hover {
background: rgba(0, 0, 0, 0.1);
color: $es-danger;
}
i {
font-size: 10px;
}
}
// Chip variants
.entity-chip.chip-primary {
background: $es-primary-light;
color: $es-primary;
&:hover {
background: rgba($es-primary, 0.2);
}
}
.entity-chip.chip-success {
background: $es-success-light;
color: $es-success-dark;
&:hover {
background: rgba($es-success, 0.2);
}
}
.entity-chip.chip-danger {
background: $es-danger-light;
color: $es-danger;
&:hover {
background: rgba($es-danger, 0.2);
}
}
.entity-chip.chip-warning {
background: $es-warning-light;
color: darken($es-warning, 20%);
&:hover {
background: rgba($es-warning, 0.3);
}
}
// Chip loading state
.entity-chip.loading,
.entity-chip-loading {
opacity: 0.7;
.chip-remove {
display: none;
}
.chip-icon i {
animation: spin 0.6s linear infinite;
}
}
// Hidden chip (collapsed view)
.entity-chip.chip-hidden {
display: none;
}
// Chips expanded/collapsed states
.entity-chips.chips-collapsed,
.entity-chips.chips-expanded {
position: relative;
}
// Show more/less toggle
.chips-show-more-toggle {
display: inline-flex;
align-items: center;
gap: 0.25rem;
padding: 0.25rem 0.5rem;
color: $es-primary;
font-size: $es-font-size-xs;
font-weight: $es-font-weight-medium;
cursor: pointer;
transition: color $es-transition-fast;
&:hover {
color: $es-primary-hover;
}
i {
font-size: 10px;
}
}
.chips-collapse-toggle,
.chips-expand-toggle {
// Specific variants inherit from .chips-show-more-toggle
}
// More chips indicator
.chips-more {
display: inline-flex;
align-items: center;
justify-content: center;
padding: 0.25rem 0.5rem;
background: $es-slate-200;
color: $es-text-secondary;
font-size: $es-font-size-xs;
font-weight: $es-font-weight-semibold;
border-radius: $es-radius-full;
cursor: pointer;
transition: all $es-transition-fast;
&:hover {
background: $es-slate-300;
}
}
// Add chip button
.chip-add-btn {
@include button-reset;
display: inline-flex;
align-items: center;
gap: 0.25rem;
padding: 0.25rem 0.5rem;
background: transparent;
color: $es-primary;
font-size: $es-font-size-xs;
font-weight: $es-font-weight-medium;
border: 1px dashed $es-primary;
border-radius: $es-radius-full;
transition: all $es-transition-fast;
&:hover {
background: $es-primary-light;
}
i {
font-size: 10px;
}
}
// Inline chips (compact mode)
.entity-chips.inline {
display: inline-flex;
padding: 0;
min-height: auto;
.entity-chip {
padding: 0.125rem 0.375rem;
font-size: 11px;
}
}
// Selected chips section in include/exclude
.selected-chips-container {
display: flex;
flex-direction: column;
gap: $es-spacing-xs;
}
.selected-chips-label {
font-size: $es-font-size-xs;
font-weight: $es-font-weight-medium;
color: $es-text-muted;
}
// Pattern chips (for name/reference patterns)
.entity-chip.chip-pattern {
background: #fef3c7;
color: #92400e;
font-family: monospace;
&:hover {
background: #fde68a;
}
.chip-icon {
color: #d97706;
}
}
// Range chips (price, quantity, etc.)
.entity-chip.chip-range,
.range-chip {
display: inline-flex;
align-items: center;
gap: 0.375rem;
padding: 0.25rem 0.5rem;
background: $es-cyan-50;
color: $es-cyan-600;
font-size: $es-font-size-xs;
font-weight: $es-font-weight-medium;
border-radius: $es-radius-full;
transition: all $es-transition-fast;
&:hover {
background: $es-cyan-100;
}
}
.range-chip-text {
font-family: monospace;
}
.btn-remove-range {
@include button-reset;
display: flex;
align-items: center;
justify-content: center;
width: 16px;
height: 16px;
color: $es-cyan-600;
border-radius: 50%;
transition: all $es-transition-fast;
&:hover {
background: rgba(0, 0, 0, 0.1);
color: $es-danger;
}
i {
font-size: 10px;
}
}
// Multi-range chips container
.multi-range-chips {
display: flex;
flex-wrap: wrap;
gap: $es-spacing-xs;
margin-bottom: $es-spacing-xs;
&:empty {
display: none;
}
}
// Pattern chips container
.pattern-chips {
display: flex;
flex-wrap: wrap;
gap: $es-spacing-xs;
padding: $es-spacing-sm 0;
min-height: 32px;
&:empty::before {
content: attr(data-placeholder);
color: $es-text-muted;
font-size: $es-font-size-xs;
font-style: italic;
}
}
// Pattern tag
.pattern-tag {
display: inline-flex;
align-items: center;
gap: 0.25rem;
padding: 0.25rem 0.5rem;
background: #fef3c7;
color: #92400e;
font-size: $es-font-size-xs;
font-weight: $es-font-weight-medium;
border-radius: $es-radius-sm;
transition: all $es-transition-fast;
&:hover {
background: #fde68a;
}
&.case-sensitive {
.case-icon {
color: $es-success;
font-weight: $es-font-weight-bold;
}
}
&.draft-tag {
background: $es-white;
border: 1px solid $es-border-color;
padding: 0;
flex: 1;
min-width: 150px;
&:hover {
background: $es-white;
}
.pattern-input {
flex: 1;
min-width: 100px;
padding: 0.375rem;
border: 0;
background: transparent;
font-size: $es-font-size-sm;
font-family: inherit;
&:focus {
outline: none;
}
&::placeholder {
color: $es-text-muted;
font-style: italic;
}
}
}
}
.pattern-tag-text {
font-family: monospace;
max-width: 200px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.btn-toggle-case {
@include button-reset;
display: flex;
align-items: center;
justify-content: center;
width: 24px;
height: 24px;
color: $es-text-muted;
border-radius: $es-radius-sm;
transition: all $es-transition-fast;
&:hover {
background: rgba(0, 0, 0, 0.1);
}
}
.case-icon {
font-size: 11px;
font-weight: $es-font-weight-semibold;
font-family: monospace;
}
.btn-remove-pattern {
@include button-reset;
display: flex;
align-items: center;
justify-content: center;
width: 18px;
height: 18px;
color: #d97706;
border-radius: $es-radius-sm;
transition: all $es-transition-fast;
&:hover {
background: rgba(0, 0, 0, 0.1);
color: $es-danger;
}
i {
font-size: 10px;
}
}
.btn-add-pattern {
@include button-reset;
display: flex;
align-items: center;
justify-content: center;
width: 28px;
height: 28px;
color: $es-primary;
border-radius: $es-radius-sm;
transition: all $es-transition-fast;
&:hover {
background: $es-primary-light;
}
i {
font-size: 12px;
}
}
// Pattern match count (in draft tag)
.pattern-match-count {
display: inline-flex;
align-items: center;
gap: 0.25rem;
padding: 0 0.375rem;
color: $es-text-muted;
font-size: $es-font-size-xs;
cursor: pointer;
&.count-zero {
color: $es-warning;
}
&.count-found {
color: $es-success;
}
.count-value {
font-weight: $es-font-weight-semibold;
}
}
// Pattern input row
.pattern-input-row {
display: flex;
align-items: stretch;
gap: $es-spacing-xs;
}
}