raquo / laminar-shoelace-components

Laminar bindings for Shoelace.js library of web components. Contains a code generator that can be used to generate similar bindings for other libraries.
MIT License
30 stars 5 forks source link

Generators for other Web components #1

Open nghuuphuoc opened 7 months ago

nghuuphuoc commented 7 months ago

Firstly, I want to express my gratitude to @raquo for your hard work on Laminar and this generator. In the README, you mentioned the possibility of parsing other Web Component libraries, but acknowledged that it would require additional effort.

My company has been utilizing Laminar in productions for a couple of years now, and we're exploring the possibility of using Web components (specifically SAP UI) instead of building our own UI components. I'm wondering if this is the appropriate place to request the creation of Laminar wrappers for SAP UI.

If it's not feasible to create SAP UI wrappers here, it would be fantastic if this generator could be modified to work with other Web component libraries.

raquo commented 7 months ago

Oh, well I do have good news for you! Antoine already made SAP UI5 bindings for Laminar: https://github.com/sherpal/LaminarSAPUI5Bindings so for SAP UI5, this generator won't be needed, with Laminar at least.

ngbinh commented 7 months ago

@raquo I know about that bindings. But I think it still require manual modifications to cover all the web components in SAP UI5. Would be nice to have something automatic and optimized

raquo commented 7 months ago

Hm, I've only used UI5 components for the laminar demo myself, but I was under the impression that those bindings cover all of UI5 web components. Is that not the case?

Just looking at the list of components on UI5 website and in Antoine's Laminar-UI5 demo, it seems like it's the same list, counting more than 60 components, with matching names.

I haven't checked all of them them one by one, but if it's just a couple components missing, it will probably be easier to add them to the existing library than to set up generation for UI5, because generation will need to be configured to work for ALL of the components, even the ones that already work fine.

elgca commented 1 week ago

@raquo I have attempted to provide an implementation of the 'aminar' binding for the MDUI web components library using the generator related code you provided. Thanks you.

After adaptation, it works well.

The custom-elements.json file contains ample information, and Scala offers comprehensive types descriptions for them. It focuses more on basic type mapping, where providing additional information suffices to generate code. For instance, only ControlledInput and csstype are required. If these are not provided, default values can be generated.

Currently, I have replaced handwritten CommonKeys with generated code.

like this , attr: alignment, type: 'start' | 'center' | 'end', auto supported now. but like this, type : 1 | 2 | 3, not supported , will be generator HtmlAttr[Int], lost type limit.

https://github.com/elgca/laminar-mdui-components

raquo commented 1 week ago

@elgca Looks great, nice work!