Skip to content

Commit c26fde7

Browse files
committed
fix input field
1 parent e569e9f commit c26fde7

File tree

3 files changed

+41
-5
lines changed

3 files changed

+41
-5
lines changed

pgml-dashboard/src/components/inputs/range_group_v_2/range_group_v_2.scss

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,31 @@ div[data-controller="inputs-range-group-v-2"] {
55
}
66

77
input[type="text"] {
8-
padding-right: 30px;
8+
padding-right: 0;
9+
border-right: 0;
10+
border-top-right-radius: 0;
11+
border-bottom-right-radius: 0;
912
}
1013

1114
.inputs-range-group-v-2-unit {
12-
margin-left: -33px;
1315
color: #{$gray-400};
16+
background: #{$input-bg};
17+
height: 100%;
18+
padding: #{$input-padding-y} #{$input-padding-x};
19+
border: #{$input-border-width} solid #{$input-border-color};
20+
21+
border-top-right-radius: var(--bs-border-radius);
22+
border-bottom-right-radius: var(--bs-border-radius);
23+
border-top-left-radius: 0;
24+
border-bottom-left-radius: 0;
25+
border-left: 0;
26+
transition: #{$input-transition};
27+
28+
&.focused {
29+
background: #{$input-focus-bg};
30+
box-shadow: #{$input-focus-box-shadow};
31+
border-color: #{$input-focus-border-color};
32+
border-width: #{$input-border-width};
33+
}
1434
}
1535
}

pgml-dashboard/src/components/inputs/range_group_v_2/range_group_v_2_controller.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Controller } from "@hotwired/stimulus";
22

33
export default class extends Controller {
4-
static targets = ["input", "range"];
4+
static targets = ["input", "range", "unit"];
55

66
onInputInput(e) {
77
const value = parseInt(e.currentTarget.value);
@@ -14,6 +14,18 @@ export default class extends Controller {
1414
}
1515
}
1616

17+
onInputFocusIn(e) {
18+
this.unitTarget.classList.add("focused");
19+
}
20+
21+
onInputBlur(e) {
22+
this.unitTarget.classList.remove("focused");
23+
}
24+
25+
onUnitClick(e) {
26+
this.inputTarget.focus();
27+
}
28+
1729
onRangeInput(e) {
1830
this.inputTarget.value = e.currentTarget.value;
1931
}

pgml-dashboard/src/components/inputs/range_group_v_2/template.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,15 @@
1616
<input
1717
type="text"
1818
class="form-control"
19-
data-action="input->inputs-range-group-v-2#onInputInput <%= actions %>"
19+
data-action="input->inputs-range-group-v-2#onInputInput focusin->inputs-range-group-v-2#onInputFocusIn blur->inputs-range-group-v-2#onInputBlur <%= actions %>"
2020
data-inputs-range-group-v-2-target="input"
2121
value="<%= value %>"
2222
>
23-
<span class="inputs-range-group-v-2-unit fw-semibold">
23+
<span
24+
class="inputs-range-group-v-2-unit fw-semibold"
25+
data-inputs-range-group-v-2-target="unit"
26+
data-action="click->inputs-range-group-v-2#onUnitClick"
27+
>
2428
<%= input_unit %>
2529
</span>
2630
</div>

0 commit comments

Comments
 (0)