@colisweb/rescript-toolkit 2.51.1 → 2.51.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@colisweb/rescript-toolkit",
3
- "version": "2.51.1",
3
+ "version": "2.51.2",
4
4
  "scripts": {
5
5
  "clean": "rescript clean",
6
6
  "build": "rescript build -with-deps",
@@ -66,24 +66,21 @@ let make = (
66
66
  let {left, top, width, height} =
67
67
  buttonRef->Browser.DomElement.getBoundingClientRect
68
68
  let dropdown = ref->Browser.DomElement.getBoundingClientRect
69
-
70
69
  let left = left +. width /. 2. -. dropdown.width /. 2.
71
70
 
72
- let left = switch left {
73
- | left if left < 0. => "0px"
71
+ let adjustmentStyle = ReactDOM.Style.make(
72
+ ~top=`${(top +. height)->Js.Float.toString}px`,
73
+ ~opacity="1",
74
+ )
75
+
76
+ let adjustmentStyle = switch left {
77
+ | left if left < 0. => adjustmentStyle(~left="8px", ())
74
78
  | left if left +. dropdown.width > Browser.innerWidth->Int.toFloat =>
75
- `${(Browser.innerWidth->Int.toFloat -. dropdown.width)->Js.Float.toString}px`
76
- | left => `${left->Js.Float.toString}px`
79
+ adjustmentStyle(~right="8px", ())
80
+ | left => adjustmentStyle(~left=`${left->Js.Float.toString}px`, ())
77
81
  }
78
82
 
79
- setAdjustmentStyle(_ => Some(
80
- ReactDOM.Style.make(
81
- ~left,
82
- ~top=`${(top +. height)->Js.Float.toString}px`,
83
- ~opacity="1",
84
- (),
85
- ),
86
- ))
83
+ setAdjustmentStyle(_ => Some(adjustmentStyle))
87
84
  }
88
85
 
89
86
  | _ => ()