I’m just starting out with this, and I would like ...
# compose-web
o
I’m just starting out with this, and I would like for example to use
Modifier
, the main goal is to use a Composable component that I made elsewhere, here on web
maybe I should go through the beginning tutorials first :)
h
which web api? if you want to target html dom API, mapping the modifer API to HTML API is hard. Jetbrains tried it with the web widget module, but this is now deprecated. If you want to share the UI code, you should wait for canvas API.
o
scroll to the bottom, you will see Pointer Events
it uses Modifier
how do I get there
h
That's true, but the first 3 examples are desktop only, the last 3 are web only.
o
ok what I want to do in the end, is something like this https://storybook.js.org/
for Compose
it is doable isn’t it
I’ll forget about porting my components to here, I was just trying that to see the extent of this thing’s ability
give me some hope Philip!
😛
h
I don't understand what you mean. Do you want to build your own storybook? I don't know all features, but I guess, it is technically possible. I created something similar a while ago, a form designer for surveys.
o
yes i want for example to showcase a page where you got like Composable base components, Button, Text, Whatever, and a list of props underneath each, and you modify them and see what it would render into
instead of fiddling with the code, you do it on web via the textfields i have set out for you, and I take those values and actually set them as properties in the code, and render
h
A catalog with selectable and customizable components sounds possible, as long as you don't want to support arbitrary code from users. this would require rerunning the kotlin/compose compiler.
o
yea no, just with the existing stuff that’s offered from compose-web, fine with that but then so the equivalent of Modifier here is what,
attrs
? and all the elements in
org.jetbrains.compose.web.dom.Elements
?
actually i’ll just look at the landing page sample code and ask later if anything is unclear
thanks a lot Philip
r
There are 2 APIs: • DOM (attrs, Div, span etc.. Html stuff) • Canvas (Modifier 🙂) If you want to use the
Modifier
in web you need to use Canvas API. You should download the project and go to the
experimental
folder where you'll find examples there I recommend to test both, I haven't done almost anything with them and I'm still playing with the code, from a noobie perspective that haven't done anything I'd recommend to go with DOM to build something (Take it with a grain of salt please 😄)
z
From my testing the canvas API would allow you to share code however it has a significant ways to go. The DOM API uses HTML/CSS stuff and is a little more complete but you lose the ability to share code
d
Note that I'm working on my own library, Kobweb, where I introduce my own
Modifier
class which works on top of the Compose for Web DOM API. In case you wanted to play around with it. I also wrote about it a bit more here: https://bitspittle.dev/blog/2022/kotlinsite#modifier
o
and for the available properties that are supported ?
and great job by the way
d
@oday Thanks! I'm just a single person so while I'm filling in API gaps as I can it's certainly not perfect. And in some cases, probably it will never reach parity. I'm pretty sure Compose for Web targeting the DOM will never have the same animation API that Jetpack Compose does for example. Let me know if you had any specific use-case in mind that you wanted to accomplish and I'll let you know if / how you can accomplish it in Kobweb.