Files
openfoodnetwork/app/webpacker/css/admin_v3/components/tom_select.scss
2023-12-14 13:33:05 +11:00

112 lines
2.2 KiB
SCSS

@mixin hide-input {
// Pretend there's no text input (it can't be hidden entirely, in order for tom-select to work)
cursor: pointer;
caret-color: transparent;
}
.ts-wrapper.single,
.ts-wrapper.multi {
min-height: 40px;
&.input-active {
.ts-control {
border-color: $orient;
background-color: $lighter-grey;
input {
&::placeholder {
color: $light-grey;
}
}
}
}
.ts-control {
box-shadow: none;
border-color: $lighter-grey;
background-color: $lighter-grey;
background-image: none;
@include border-radius($border-radius);
input {
font-size: $body-font-size;
height: auto;
&::placeholder {
color: $near-black;
}
}
.item {
margin-top: 2px; // Ensure it lines up with the input. I have no idea why it's necessary.
}
}
.ts-dropdown {
margin-top: 4px;
color: $near-black;
@include border-radius($border-radius);
border: none;
box-shadow: $shadow-dropdown;
.ts-dropdown-content {
padding: $border-radius 0;
}
.option {
padding: 8px;
border-left: 3px solid transparent;
line-height: 20px;
&.selected,
&.active {
border-left: 3px solid $orient;
background-color: $lighter-grey;
color: $near-black;
}
}
}
}
.plugin-dropdown_input .dropdown-input {
border-color: $lighter-grey;
&:focus {
border-color: $orient;
}
}
// For the "single" tom_select, be as close as possible to native select boxes
// without too many options
.ts-wrapper.single {
max-height: 40px;
max-width: 100%;
&.has-items {
@include hide-input;
}
.ts-control {
.item {
margin-right: 1rem;
}
}
}
// 'no-input' mode, like a native select (hide text input).
.ts-wrapper.single.no-input {
&.input-active .ts-control {
@include hide-input;
}
.ts-control {
padding-right: 1rem !important; // ts has a clever variable-based rule here, but it doesn't seem to work right.
}
.ts-dropdown {
position: absolute;
top: 0; // we don't need to see the currently selected option, because it's visible in the dropdown
margin-top: 0;
}
}