DEV Community

Cover image for µCE
artydev
artydev

Posted on

2 1

µCE

...µhtml based Custom Elements...

You can test it here : µCE

devuser : <input oninput="fetchUserPosts(this.value)"/>

<dev-articles id="devuser" username="artydev" />
Enter fullscreen mode Exit fullscreen mode
import {define, html} from 'https://unpkg.com/uce?module';

const urlDev = (username) =>  
  `https://dev.to/api/articles?username=${username}`

define('dev-articles', {
  callApi: username =>
    fetch(urlDev(username))
      .then(data => data.json()),

  observedAttributes: ['username'],

  async attributeChanged(key, _, value) {
    var posts = await this.callApi(value)
    this.render(posts)
  },

  fetchUser(e) {
     devuser.setAttribute("username", e.target.value)
  },

  render(posts) {
    posts && this.html
      `
        <center style="display:block">
          devUser: <input oninput="${(e) => this.fetchUser(e)}"/>
        </center>
        <ul>
          ${posts.map((t) => html`<li>${t.title}</li>`)}
        </ul>
      `
  }
});

Enter fullscreen mode Exit fullscreen mode

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (2)

Collapse
 
thepeoplesbourgeois profile image
Josh • Edited

It regularly astonishes and depresses me, how little traction Andrea Giammarchi's libraries have ever gained.

If every app built in React were using his libraries instead, even the lowest-tier smartphone specs would be able to run most web apps without any issues

Collapse
 
artydev profile image
artydev

Andrea makes awesome works, too good to be true for many.☹️

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Instrument, monitor, fix: a hands-on debugging session

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️