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

HTML Web Component #405

Open
oskarrough opened this issue Nov 22, 2023 · 2 comments
Open

HTML Web Component #405

oskarrough opened this issue Nov 22, 2023 · 2 comments

Comments

@oskarrough
Copy link

The web component version of unpic currently requires markup like this

<unpic-img
  src="https://cdn.whatever.com/bath_grande.jpg"
  layout="constrained"
  width="{800}"
  height="{600}"
  alt="A lovely bath"
></unpic-img>

I'd like to discuss an alternative markup:

<unpic-img layout="constrained">
  <img
    src="https://cdn.whatever.com/bath_grande.jpg"
    alt="A lovely bath"
    width="800"
    height="600">
</unpic-img>

The first advantage here is that it'll work without javascript. The idea is to enhance the <img> element instead of trying to replace it. The unpic-img element would take care of any non-standard attributes and modify the child image accordingly.

This would break->change the current API. Could consider making another web component instead of breaking the current one made with LitElement.

See https://www.zachleat.com/web/a-taxonomy-of-web-component-types/#html-web-components and https://adactio.com/journal/20618 for more thoughts on this.

What do you think?

@ascorbic
Copy link
Owner

Thanks. I saw both of those posts and think this would be a good idea. We already have both webc and Lit, so I'm not sure what the best approach would be. I think a "plain" HTML web component might be the way

@oskarrough
Copy link
Author

Yes, a plain one makes sense to me, too. Don't believe Lit is needed, since it's really about rendering a single element and it looks like you have all the prop logic extracted already.

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

2 participants