discourse/app/assets/stylesheets/common/form-kit/_control-input.scss
Joffrey JAFFEUX cbc0ece6e8
DEV: <DSelect /> (#30224)
`<DSelect />` is a wrapper similar to our existing `<DButton />` over the html element `<select>`. The code is ported from form kit which is now directly using `<DSelect />`. Note this component has also been used in edit topic timer modal.

This component is recommended for a small list of text items (no icons, no rich formatting...).

Usage:

```gjs
<DSelect class="my-select" @onChange={{this.handleChange}} as |select|>
  <select.Option @value="foo" class="my-favorite-option">Foo</select.Option>
  <select.Option @value="bar">Bar</select.Option>
</DSelect>
```

This commit comes with a set of assertions:

```gjs
import dselect from "discourse/tests/helpers/d-select-helper";
import { select } from "@ember/test-helpers";

assert
  .dselect(".my-select")
  .hasOption({ value: "bar", label: "Bar" })
  .hasOption({ value: "foo", label: "Foo" })
  .hasNoOption("baz");

await select(".my-select", "foo");

assert.dselect(".my-select").hasSelectedOption({value: "foo", label: "Foo"});
```
2024-12-13 10:40:06 +01:00

55 lines
1.1 KiB
SCSS

.form-kit__control-input {
@include default-input;
z-index: 1;
margin: 0 !important;
min-width: auto !important;
.form-kit__field.has-error & {
border-color: var(--danger);
}
&.has-prefix.has-suffix {
border-radius: 0;
}
&.has-prefix:not(.has-suffix) {
border-radius: 0 var(--d-input-border-radius) var(--d-input-border-radius) 0;
}
&.has-suffix:not(.has-prefix) {
border-radius: var(--d-input-border-radius) 0 0 var(--d-input-border-radius);
}
&-wrapper {
display: flex;
flex-direction: row;
align-items: center;
width: 100%;
}
}
.form-kit__before-input,
.form-kit__after-input {
border: 1px solid var(--primary-low-mid);
padding-inline: 0.5em;
height: 2em;
box-sizing: border-box;
background: var(--primary-low);
display: flex;
align-items: center;
@include breakpoint(mobile-large) {
height: 2.25em;
}
}
.form-kit__before-input {
margin-right: -0.25em;
border-radius: var(--d-input-border-radius) 0 0 var(--d-input-border-radius);
}
.form-kit__after-input {
margin-left: -0.25em;
border-radius: 0 var(--d-input-border-radius) var(--d-input-border-radius) 0;
}