Skip to content
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

Creating Components via JavaScript #466

Open
3 tasks done
wuda-io opened this issue Mar 22, 2024 · 4 comments
Open
3 tasks done

Creating Components via JavaScript #466

wuda-io opened this issue Mar 22, 2024 · 4 comments
Labels
build discussion documentation Improvements or additions to documentation javascript

Comments

@wuda-io
Copy link
Member

wuda-io commented Mar 22, 2024

Before submitting...

Context

Parsing components from the DOM Tree is at the moment the only direction to go. What do you think of the other direction, and create Components via JS. Also we can then make like Configurators for each Component in the Documentation.
What do you think?
I will try to inplement a proof of concept for the Button Component soon.

First i thought to implement this via webcomponents, but i think it should always work without javascript too. And as far as i know, webcomponents do not work without JS. So this would be a good compromise i think.

Looking forward for your feedback!
Thank you guys

Current Behavior

Only parsing components from the Dom is possible.

Expected behavior

Going both directions would be awesome. Parsing from Dom and creating Dom Elements.

Possible Solutions or Causes

const btn = M.Button.create();

Your Environment

  • Version used:
  • Browser Name and version:
  • Operating System and version (desktop or mobile):
  • Additional information you want to tell us:
@wuda-io wuda-io added documentation Improvements or additions to documentation discussion javascript build labels Mar 22, 2024
@warrenspe
Copy link

It's funny because I often find myself irked when I need to access some bit of configuration (like accordion mode for collapsibles) that can only be accessed by initializing an element via JS; where there's no way to set it via the DOM.

But I'm sure that some folks would find this useful

@wuda-io
Copy link
Member Author

wuda-io commented Mar 27, 2024

Hey, thanks for your comment. Yes, the current process via initializing it after the html is a bit complicated and often creates additional confusion. I think of it in 2 ways:

  1. parsing/init from the DOM and reconfigurating
  2. Creating DOMElements from JS Side
    I think it also would be cool for generating Templates.

@danice
Copy link

danice commented Mar 28, 2024

Some thoughts:

I think we should be very cautious with webcomponents, as they completely change the look of html. Most of materialize components could be thought as extesions of existing html elements as <button> and I don't think is a good idea to create webcomponents for that (for example AFAIK "Angular material" does not use components for button)

Said that we need to attach the problem of using materializecss in ShadowDOM, as asked in #53

Also this would be a good moment to consider integration with frameworks, and prepare examples as in fast components and in Kickstand UI. Of course, as we use standart html elements there is the usual bindings, but maybe we need to check how methods and events work in some frameworks.

@wuda-io
Copy link
Member Author

wuda-io commented Apr 3, 2024

@danice yes, I mean to not use webcomponents at all, just to generate the html for the Components via Js.

The problem with webcomponents is, that we depend on JS, so thats not what we should aim for. We should always prefer a CSS Solution over JS.

So i mean an opposite of the Init function. Like a Create function or so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build discussion documentation Improvements or additions to documentation javascript
Projects
None yet
Development

No branches or pull requests

3 participants