Comments (5)
As a workaround for now, to make things done, I'd try to define an sx
-prop extension overload that takes an obj
, and then use this overload to pass it JS object that fits the schema that MUI expects.
An example of such extension (that could be defined in any F# module in your code before the place where it is intended to be used):
type Feliz.MaterialUI.appBar with
static member inline sx (stylesObj: obj) = Feliz.Interop.mkAttr "sx" stylesObj
Actually, there is no need to define it for each component type. Instead, it could be done just once on some other type, as Feliz's prop
, for example:
type Feliz.prop with
static member inline sx (stylesObj: obj) = Feliz.Interop.mkAttr "sx" stylesObj
Or define it in a new erased type:
[<Erase>]
type muiProp =
static member inline sx (stylesObj: obj) = Feliz.Interop.mkAttr "sx" stylesObj
It totally doesn't matter for the output JS.
from feliz.materialui.
@Zolomon hello. Good to know that it's working good 👌
Referring to Emotion, do you mean Emotion as a whole library itself, or only some Material UI related part?
from feliz.materialui.
Sorry for the delayed response.
Basically, I am trying to port the following snippet from TypeScript from the MUIv5 Drawer docs:
Specifically, I am getting stuck on how to express the style for this snippet:
<Drawer
variant="permanent"
sx={{
display: { xs: 'none', sm: 'block' },
'& .MuiDrawer-paper': { boxSizing: 'border-box', width: drawerWidth },
}}
open
>
{drawer}
</Drawer>
I have the following so far:
Mui.drawer [ drawer.variant.permanent
drawer.open' true
drawer.children [ drawer' ]
drawer.sx (
xs =
[ style.display.none
style.innerSlot
MuiClasses.drawer.paper
[ style.boxSizing.borderBox
style.width
Components.drawerWidth ] ],
sm =
[ style.display.block
style.innerSlot
MuiClasses.drawer.paper
[ style.boxSizing.borderBox
style.width
Components.drawerWidth ] ]
) ] ] ]
The breakpoints do not appear to function as intended on Firefox v118.0.2 (64-bits), but I am quite sure it is a failure on my part and has nothing to do with your code.
Do you have any suggestions? I have searched through the repository for similar usages and this is what led me to this result.
from feliz.materialui.
@Zolomon, understood. Unfortunately, sx
-prop bindings I made are not so flexible as they are in TS/JS API. I tried to cover the most common scenarios, but it still lacks some features as, e.g., breakpoints per prop (this one is tricky to be expressed via current Feliz API and in terms of F# type system at all).
It easily could be a failure on my side because there are no automated tests for the bindings. Therefore, I haven't tested a lot of things simply because I haven't used them yet. And breakpoint styling is on of them, I suppose.
Regarding the provided example, it seems to me correct, that is how I expected it to work. So, I need to test it to find out what's wrong. Thank you for reporting it 👍
from feliz.materialui.
@Zolomon I've made a simple test. Seems like I made a mistake assuming that it's possible to set breakpoints-based styles in other than a per-prop manner. I.e. these aren't actually the equal definitions:
<AppBar
sx={{
width: { sm: `calc(100% - ${drawerWidth}px)` },
ml: { sm: `${drawerWidth}px` }
}}>
<AppBar
sx={{
sm: {
width: `calc(100% - ${drawerWidth}px)`,
ml: `${drawerWidth}px`
}
}}>
Probably, the 1st one is the correct option and the 2nd one is not. At least I don't see anything similar to the 2nd option in the MUI Docs article about sx-prop
usage. I suppose, I misunderstood this thing while I was writing the bindings last year 😕 Summing up, seems like the current bindings don't provide a way to set breakpoints-based styles, and it's necessary to come up with an appropriate solution.
from feliz.materialui.
Related Issues (6)
- `anchorPosition` prop (e.g. of Menu, Popover) should accept `float`s, not just `int`s
- Generated `box` type shadows implicitly imported FSharp.Core's `box` (`FSharp.Core.Operators.box`) function
- Unauthorized error trying to install the package HOT 8
- Did you try to become the maintainer of the origin repository? HOT 1
- Incorrect binding to the `renderOption` prop of the `Autocomplete` component
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from feliz.materialui.