-
-
Notifications
You must be signed in to change notification settings - Fork 197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bugfix/fix input example #256
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -138,7 +138,7 @@ let make = | |
computed styles | ||
*/ | ||
|
||
let viewStyles = | ||
let allStyles = | ||
Style.( | ||
merge( | ||
~source=[ | ||
|
@@ -147,14 +147,14 @@ let make = | |
justifyContent(`FlexStart), | ||
overflow(LayoutTypes.Hidden), | ||
cursor(MouseCursors.text), | ||
...defaultStyles, | ||
], | ||
~target=style, | ||
) | ||
); | ||
|
||
/* | ||
TODO: convert this to a getter utility function | ||
*/ | ||
let viewStyles = Style.extractViewStyles(allStyles); | ||
|
||
let inputHeight = | ||
List.fold_left( | ||
(default, s) => | ||
|
@@ -166,6 +166,17 @@ let make = | |
style, | ||
); | ||
|
||
let inputFontSize = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also tried generalising this as it seems like a much more common use case to get the specific value of an item in the style list if you want to do some internal logic based on it. I tried something along the lines of the above but /* Inside a fold_left */
switch(valueIWant, variantType) {
| ("marginTop", MarginTop(mt)) => mt
/* ....etc */
} the compiler doesn't seem to be able to narrow down the return type this way, could have been a question type annotating it properly but I couldn't work out how There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe for some of these - it'd be worth just calling Like:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this issue with that approach is that since |
||
List.fold_left( | ||
(default, s) => | ||
switch (s) { | ||
| `FontSize(fs) => fs | ||
| _ => default | ||
}, | ||
20, | ||
style, | ||
); | ||
|
||
let inputColor = | ||
List.fold_left( | ||
(default, s) => | ||
|
@@ -181,7 +192,7 @@ let make = | |
Style.[ | ||
color(hasPlaceholder ? placeholderColor : inputColor), | ||
fontFamily("Roboto-Regular.ttf"), | ||
fontSize(20), | ||
fontSize(inputFontSize), | ||
alignItems(`Center), | ||
justifyContent(`FlexStart), | ||
marginLeft(6), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to generalise this but can't figure out how, its that or create one whenever we need a utility to separate a certain subset of styles from another. Say you create a custom component comprised of
text
andview
components so it will take a style list ofcoreStyleProps
+ extrafontProps
but then as the view is not allowed to havefontProps
they need to be split out in the implementation part of the custom component.Its very possible this isn't something we might need a lot 🤷♂️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question, I'm not sure this would work either 🤔