Skip to content

Commit 5ff7c4c

Browse files
committed
docs(changeset): Fix props binding of the Box component
1 parent f5f69d5 commit 5ff7c4c

File tree

3 files changed

+52
-17
lines changed

3 files changed

+52
-17
lines changed

.changeset/sour-dots-study.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"rescript-ink": minor
3+
---
4+
5+
Fix props binding of the Box component

packages/ink/src/Ink_Components_Box.res

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ let makeProps = (
99
~flexBasis: option<flexBasis>=?,
1010
~flexDirection: option<flexDirection>=?,
1111
~alignItems: option<alignItems>=?,
12+
~alignSelf: option<alignSelf>=?,
1213
~justifyContent: option<justifyContent>=?,
1314
~width: option<size>=?,
1415
~minWidth: option<[#length(length)]>=?,
@@ -39,8 +40,14 @@ let makeProps = (
3940
| None => Some(#flex)
4041
| display => display
4142
},
42-
"flexGrow": flexGrow,
43-
"flexShrink": flexShrink,
43+
"flexGrow": switch flexGrow {
44+
| None => Some(0)
45+
| flexGrow => flexGrow
46+
},
47+
"flexShrink": switch flexShrink {
48+
| None => Some(1)
49+
| flexShrink => flexShrink
50+
},
4451
"flexBasis": switch flexBasis {
4552
| Some(#length(len)) => Some(string_of_int(len))
4653
| Some(#percent(pct)) => Some(Js.Float.toString(pct) ++ "%")
@@ -54,11 +61,27 @@ let makeProps = (
5461
},
5562
"flexDirection": flexDirection,
5663
"alignItems": alignItems,
64+
"alignSelf": switch alignSelf {
65+
| None => Some(#auto)
66+
| alignSelf => alignSelf
67+
},
5768
"justifyContent": justifyContent,
58-
"width": width,
59-
"minWidth": minWidth,
60-
"height": height,
61-
"minHeight": minHeight,
69+
"width": switch width {
70+
| Some(width) => Some(width->Size.unwrap)
71+
| None => None
72+
},
73+
"minWidth": switch minWidth {
74+
| Some(minWidth) => Some(minWidth->Size.unwrap)
75+
| None => None
76+
},
77+
"height": switch height {
78+
| Some(height) => Some(height->Size.unwrap)
79+
| None => None
80+
},
81+
"minHeight": switch minHeight {
82+
| Some(minHeight) => Some(minHeight->Size.unwrap)
83+
| None => None
84+
},
6285
"margin": margin,
6386
"marginX": marginX,
6487
"marginY": marginY,

packages/ink/src/Ink_Style.res

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
1+
type any
2+
external unwrap: 'a => any = "%identity"
3+
14
type length = int
25

36
type percent = float
47

5-
type size = [
6-
| #length(length)
7-
| #percent(percent)
8-
]
8+
module Size = {
9+
type t = [
10+
| #length(length)
11+
| #percent(percent)
12+
]
13+
14+
let unwrap = t => switch t {
15+
| #length(length) => length->unwrap
16+
| #percent(percent) => percent->unwrap
17+
}
18+
}
19+
20+
type size = Size.t
921

1022
type textWrap = [
1123
| #wrap
@@ -127,13 +139,8 @@ type borderStyle = [
127139
| #arrow
128140
]
129141

130-
type width = [
131-
| #auto
132-
| #percent(percent)
133-
| #length(length)
134-
]
135-
136142
type flexBasis = [
143+
| #auto
137144
| content
138-
| width
145+
| size
139146
]

0 commit comments

Comments
 (0)