-
Notifications
You must be signed in to change notification settings - Fork 66
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
Add type bindings for overflow, overflow-x and overflow-y options #175
Conversation
…ording to the css spec.
Hum, we are facing a problem here.
|
Seems like I was being a bit too eager here :). Would something like this work? static member Overflow (overflow: OverflowOptions, ?overflowY: OverflowOptions) =
let values =
match overflowY with
| Some value -> [ overflow; value ]
| None -> [ overflow ]
unbox ("overflow", keyValueList CaseRules.LowerFirst values) |
No, because it needs to return a This need to be tested static member Overflow (overflow: OverflowOptions, ?overflowY: OverflowOptions) =
unbox ("overflow", unbox overflow + " " + unbox overflowY) We can |
Right! I'll go ahead and test this one then. |
I've tested these changes in a consumer project and they work. Returning the unboxed value directly probably wasn't a good idea, and wouldn't work for the SSR code. So I ended up returning a |
I was too quick with my test and noticed that it actually didn't work when only passing a single argument (leaving out the optional value). Not unboxing the optional directly fixed that issue. |
I believe these changes could be merged. I'm planning to do more of these, and hopefully cover all the properties. It might be good to go step by step. |
I am waiting @alfonsogarciacaro feedbacks. Personally, I think if we accept changes like these we need to do all of them in one major release (can be stored in a separate branch and contribute into several PRs). Otherwise, each time someone upgrade
|
…ction, AnimationFillMode, Appearance, BoxSizing, Float, ImageRendering, WhiteSpace
Added DUs for various other CSSProps. |
static member Overflow (overflow: OverflowOptions, ?overflowY: OverflowOptions) = | ||
match overflowY with | ||
| Some value -> CSSProp.Custom ("overflow", unbox overflow + " " + unbox value) | ||
| None -> CSSProp.Custom ("overflow", unbox overflow) |
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.
Hmm, not sure if this will work on .NET side for SSR, but this makes me realize we may also have a problem with other StringEnum options. I need to look into that.
… BreakAfter, BreakBefore, BreakInside, CaptionSide, Clear, Direction
I will merge this shortly and fix the SSR issue myself because this has made me realize we have an issue with the other CSS props. However, as it's a breaking change in principle we should release it as a new major version. @MangelMaxime What's the situation with the react/react-dom split? Has something be decided for elmish/react? |
I agree but only if all the options have been converted to the typed way otherwise it will feel hacky. If not, we can just release a fix for the SSR code.
I need to take the time to do the split because it was a bit harder than planned :) You can ignore this situation, I will adapt the repos when ready. I am focusing on Nacara right now to solve several issues before starting another task. |
I concur. I'd really like to cover all the props. There's a lot of them so it's going to take a lot of time. I'm starting with the simpler ones that can be turned in a DU with a I'll also do a proposal to treat pixels/percentages/length etc as a seperate type to have them type-safe and compliant with the css spec. A proposal is not ready yet, and I'd be happy to hear your opinions. |
No worry @jannesiera my goal isn't to rush you or someone to do it for tomorrow :) But, I wasn't comfortable with shipping current version of Fable.React with various style (some type safe and some obj) so I would like to no redo it. Especially, when your PR and the code for fixing SSR are not linked together. :) |
I'm thinking about the issues with SSR: most of them happen because the special/hacky features of Fable like However, as this is causing many little issues when sharing the code with .NET maybe it's better to discard the hacks and use more standard code. This may bring a little runtime overhead but it shouldn't be noticeable. What do you think? |
About the units, it's a good idea. Though as we're using unit types, we would have to add extra cases (like HeightPx, HeightPercentage...) or mask static members as union cases (another hack). Also, @Zaid-Ajaj Feliz project is already exploring this direction. Maybe we can wait for feedback from users of that library before making similar changes here. |
Compare to today, this means that we will iterate over each list element one more time in order to check if we need to convert the As a side note, if we change the Is SSR really broken? Because I am surprised that no one complained yet about it. I think, we should move the SSR discussion to a separate issue. |
TBH, I don't know. I don't use SSR myself and probably not many people use it yet. If there's a problem, it's probably a few CSS rules not working correctly and they may be overriden by React on the frontend. That's maybe the reason nobody has noticed it yet. |
Ok, I'll merge this PR so I don't forget and I'll try to see what can I do about the SSR thing :) |
To get my feet wet regarding the strengthening of the type-safety of the CSS dsl.
I've added options for overflow and its cousins overflow-x and overflow-y, accoding to the spec. All comments on the options are directly copied from their description in the spec.