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

material-components-web vs material-components-web-components #223

Closed
gertcuykens opened this issue Feb 10, 2019 · 7 comments
Closed

material-components-web vs material-components-web-components #223

gertcuykens opened this issue Feb 10, 2019 · 7 comments

Comments

@gertcuykens
Copy link

gertcuykens commented Feb 10, 2019

Please correct me if I am wrong, doesn't the way you use web components break things like native capabilities with other elements for example the relation with form and input if you don't use the is attribute?

Aren't you pushing it a bit to far? It's very confusing to have two repo's named material-components-web and material-components-web-components. This feels like a Python 2.x vs 3.x struggle.

I understand material-components-web doesn't use the full potential of web components, but is it really worth the mess to duplicate the effort?

Strongly recommend to use the is attribute to ensure native capabilities or if browsers don't support it, drop it and join forces improving material-components-web

@tionkje
Copy link

tionkje commented Feb 10, 2019

As far as i can tell material-components-web-components is a wrapper around material-components-web using web components. Not a reimplementation of the same thing.

@gertcuykens
Copy link
Author

gertcuykens commented Feb 10, 2019

Yes and no, for me promoting it like this would not be a reimplementation, but as far as I can tell they go far beyond this.

https://jsbin.com/lokufeqelu/edit?html,output

<!doctype html>
<html>
  <head>
    <title>Hello World</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes"/>
    <meta name="mobile-web-app-capable" content="yes">
    <style>
      html, body {
        padding: 0;
        margin: 0;
      }
    </style>
    <script src="https://unpkg.com/@webcomponents/webcomponentsjs/webcomponents-loader.js"></script>
    <script type="module">
      import {html, render} from 'https://unpkg.com/lit-html'
      import {MDCTextField} from 'https://unpkg.com/@material/textfield?module'

      const helloWorld = () => {
        class HelloWorld extends HTMLElement {
          constructor() {
            super()
          }
          connectedCallback() {
            const root = this.attachShadow({mode: 'open'});
            render(html`
              <style>
                @import url('https://unpkg.com/material-components-web/dist/material-components-web.min.css')
              </style>
              <form>
                <div class="mdc-text-field">
                  <input type="text" id="my-text-field" class="mdc-text-field__input">
                  <label class="mdc-floating-label" for="my-text-field">Hint text</label>
                  <div class="mdc-line-ripple"></div>
                </div>
              </form>
            `, root)
            MDCTextField.attachTo(root.querySelector('.mdc-text-field'))
          }
        }
        customElements.define('hello-world', HelloWorld)
      }
      helloWorld()
    </script>
  </head>
  <body>
    <hello-world></hello-world>
  </body>
</html>

@JosefJezek
Copy link
Contributor

We have many wrappers, check out the link...
https://github.com/material-components/material-components-web/blob/master/docs/framework-wrappers.md

Including the external big styles in web component is bad solution.

@gertcuykens
Copy link
Author

Agree that including the external big styles in web component is bad, was just a quick example stripping out all the extra properties and methods included by material-components-web-components. I believe if we focus on making components that can extend other elements using is we don't need framework wrappers and ensure native capabilities.

@dfreedm
Copy link
Collaborator

dfreedm commented Jul 3, 2019

material-components-web is the base implementation of Material Design, and intended to both be used as is, and extended with other libraries. This repo is for extending the base layer with Web Components, and is not intended to be a complete replacement of MDC.

Your specific concerns about form can be addressed by using Form Associated Custom Elements, or the FormData Event, both of which are useful than extending native form elements.

@dfreedm
Copy link
Collaborator

dfreedm commented Jul 3, 2019

Closing in favor of #289

@dfreedm dfreedm closed this as completed Jul 3, 2019
@jsilvermist
Copy link

jsilvermist commented Jul 4, 2019

Oh nice, I hadn't heard of Form Associated Custom Elements but I really like the idea, it really opens up a new way of creating composable elements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants