DavidDarnes, to random
@DavidDarnes@mastodon.design avatar

TIL you can use on Micro.blog

DavidDarnes, to random
@DavidDarnes@mastodon.design avatar

This was probably made just to throw together UI for prototyping, however it might work quite nicely as a blog theme https://wiredjs.com

cirrus, to webdev
@cirrus@mstdn.social avatar

Went down a rabbit hole today trying to share some CSS between a document (i.e. "light DOM") and the shadow DOMs of some #HTML custom elements (aka #WebComponents).

This article by Eisenberg Effect was super useful: https://eisenbergeffect.medium.com/

I ended up building something along similar lines, but customised for my specific needs. Needs a bit of polish, but it works.

It really shouldn't be that hard to do though. Really hope a native way to do this ends up in the #web platform someday.

DavidDarnes, to random
@DavidDarnes@mastodon.design avatar

🆕 <link-peek> 1.1.0 is out!

You can now use multiple custom templates on the same page by referencing the template id using the new template attribute ✨

📦 https://www.npmjs.com/package/@daviddarnes/link-peek
✍🏻 https://darn.es/link-peek-web-component/

DavidDarnes, to random
@DavidDarnes@mastodon.design avatar

🆕 <mastodon-post> 1.3.0 is out!

  • You can now use multiple custom templates on the same page by referencing the template id using the new template attribute
  • You can now reference multiple data points within the data-key attribute when creating custom templates
  • Also made a minor refactor to hopefully make things more readable

📦 https://www.npmjs.com/package/@daviddarnes/mastodon-post
✍🏻 https://darn.es/mastodon-post-web-component/

cferdinandi, to random
@cferdinandi@mastodon.social avatar

Maybe a ridiculous question, but... are Web Components the next "design system"?

DavidDarnes,
@DavidDarnes@mastodon.design avatar

@cferdinandi I think #WebComponents are a great way to distribute parts of #DesignSystems, especially if you're dealing with varying frameworks and/or working with heavily polluted or legacy codebases.

However I do think that CSS is evolving at such a rate that Web Components will take more of a backseat when distributing design systems. They will still be present but mainly to provide JS behaviour (as they should) while more modern CSS will handle visual consistency

jrjurman, to webdev
@jrjurman@fosstodon.org avatar

Inspired by the mention of Shiki by @chriscoyier in the Codepen Newsletter, I created a Web Component for quickly and easily using Shiki in any project, no tooling or complex builds required, works with all frameworks!

Docs here: https://github.com/JRJurman/shiki-component

Live Codepen here: https://codepen.io/JRJurman/pen/xxeQQxa

DavidDarnes, to random
@DavidDarnes@mastodon.design avatar

New release of <share-button> Web Component! Fixes an issue with Firefox mobile, thanks to @grislyeye 🙏🏻

https://github.com/daviddarnes/share-button/releases/tag/v1.1.3

joe, to javascript

In last week’s post, I said, “That is because you can not pass an array directly into a web component”. I said that I might take a moment at some point to talk about how you could do that. Well, today is the day we are doing that.

Let’s start with a basic Lit example.

See the Pen by Joe Steinbring (@steinbring)
on CodePen.

You will notice that the ArrayList class has an items property that is an array type. Lit won’t let you do something like <array-list items = ['Item 1', 'Item 2', 'Item 3']></array-list> but it is fine with you passing it in using javascript. That means that myList.items = ['Item 1', 'Item 2', 'Item 3']; does the job, fine.

So, how can we do that with a Vue.js array?

See the Pen by Joe Steinbring (@steinbring)
on CodePen.

It is the same thing except you need to set the value of the list in an onMounted() lifecycle hook.

What about if we want to do it with React?

See the Pen by Joe Steinbring (@steinbring)
on CodePen.

With React, you just set the value in a useEffect() React hook.

https://jws.news/2024/how-to-pass-an-array-as-a-property-into-a-web-component/

#JavaScript #Lit #React #VueJs #WebComponents

DavidDarnes, to random
@DavidDarnes@mastodon.design avatar

I want light DOM <slot>s for , but they allow WCs to insert content into light DOM elements

DavidDarnes, to random
@DavidDarnes@mastodon.design avatar

Newly added to my collection: <link-peek>!

Turn any regular anchor link into a rich preview (also known as an ‘unfurled’ link). Can be used with any JSON API and allows for custom templating.

Prefect for creating more visual interest on links without filling the page with additional HTML noise:

✍🏻 https://darn.es/link-peek-web-component/
📦 https://www.npmjs.com/package/@daviddarnes/link-peek

davatron5000,
@davatron5000@mastodon.social avatar

@DavidDarnes I love this! I feel like between you and @zachleat we're finally getting closer to what 's full potential.

DavidDarnes, to random
@DavidDarnes@mastodon.design avatar

TIL that Zapier uses to allow people to embed zaps on their web pages ⚡️

smallcircles, to webassembly
@smallcircles@social.coop avatar

@enhance_dev Backend agnostic server-side rendering (SSR) for Web Components

> https://enhance.dev is an HTML-first full-stack web framework that gives you everything you need to build standards-based multi-page web apps that perform and scale. apps and their elements are server-side rendered for incredible performance and seamless progressive enhancement.

https://begin.com/blog/posts/2024-04-08-introducing-enhance-wasm

heybran, to javascript
@heybran@mastodon.online avatar

Using inline events handlers inside vanilla side project is kinda nice, what do you think? Love the freedom and joy of writing vanilla .

https://heybran.cn/blog/web-components-inline-event-handlers/

joe, (edited ) to javascript

Earlier this week, when I wrote about how to build an autocomplete using Vue.js, it was less about exploring how to do it and more about documenting recent work that used Vuetify. I wanted to use today’s post to go in the other direction. Recently, I discovered the value of using Lit when writing Web Components. I wanted to see if we could go from the HTML / CSS example to a proper web component.

First crack at it

Lit is powerful. You can do a lot with it. Let’s start with a rewrite of Tuesday’s final example to one that uses just Lit.

See the Pen by Joe Steinbring (@steinbring)
on CodePen.

The first thing that we do in this is to import LitElement, html, css from a CDN. Our CountySelector class extends LitElement and then customElements.define('county-selector', CountySelector) at the bottom of the page is what turns our class into a tag. The static styles definition is how you style the tag. You will notice that there aren’t any styles outside of that. The markup is all defined in render() near the bottom. The async fetchCounties() method gets the list of counties from the data.jws.app site that I created last week.

This works but web components are supposed to be reusable and this isn’t reusable enough, though.

How do we increase reusability?

As you might remember from last month’s post about web components, you can use properties with a web component. This means that the placeholder and the options for the autocomplete can be passed in as properties in the markup.

See the Pen by Joe Steinbring (@steinbring)
on CodePen.

You will notice that the big difference between this version and the first one is that we dropped the API call and replaced it with a countyList property that defines the options. We can do better, though.

See the Pen by Joe Steinbring (@steinbring)
on CodePen.

In this next version, we eliminate all explicit references to counties since a person might presumably want to use the component for something other than counties. You might want to use it to prompt a user for ice cream flavors or pizza toppings.

How do you use Vue with a web component?

Unfortunately, you aren’t going to be able to use something like v-model with a web component. There are other ways to bind to form inputs, though. Let’s take a look.

See the Pen by Joe Steinbring (@steinbring)
on CodePen.

In the above example, optionsList and selectedOption are defined as Refs. The ref object is mutable (you can assign new values to .value) and it is reactive (any read operations to .value are tracked, and write operations will trigger associated effects). The options list can be passed into the web component using the :optionsList property. You might notice, though that the example is using .join(', ') to convert the array to a comma-delimited list. That is because you can not pass an array directly into a web component. That is likely going to be the subject of a future article. You might also notice that it is triggering the when you click on a suggestion and onBlur. The dispatchEvent() method sends an event to the object, invoking the affected event listeners in the appropriate order. That should trigger updateSelectedOption when you select a county or finish typing one that isn’t in the list.

So, what do you think? Do you have any questions? Feel free to drop a comment, below.

https://jws.news/2024/how-to-implement-an-autocomplete-using-web-components/

#JavaScript #Lit #VueJs #WebComponents

enhance_dev, to webassembly

🎉 Introducing Enhance WASM

Say hello to Enhance WASM — backend agnostic server-side rendering for web components.

by @brianleroux

https://begin.com/blog/posts/2024-04-08-introducing-enhance-wasm

DavidDarnes, to random
@DavidDarnes@mastodon.design avatar

New version of <mastodon-post> Web Component just dropped!

You can now access nested data returned from the Mastodon public API using dot notation, e.g. account.display_name or account.avatar.

📦 https://www.npmjs.com/package/@daviddarnes/mastodon-post
✍🏻 https://darn.es/mastodon-post-web-component/

DavidDarnes,
@DavidDarnes@mastodon.design avatar

Turned on sponsoring via Buy Me a Coffee so you can donate for my work

https://buymeacoffee.com/daviddarnes

pablolarah, to random
@pablolarah@mastodon.social avatar

🟢Custom pseudo-classes for web components with the CustomStateSet API
by Ollie Williams @hypeddev

https://fullystacked.net/custom-pseudo-classes/

DavidDarnes, to random
@DavidDarnes@mastodon.design avatar

Been working on an update to my <mastodon-post> Web Component to allow you to target nested data within a post using dot notation.

If you have a moment I'd appreciate a check over what I've changed just to make sure there isn't a regression and I'm not over engineering it. Thanks!

https://github.com/daviddarnes/mastodon-post/pull/2

khalidabuhakmeh, to webdev
@khalidabuhakmeh@mastodon.social avatar
DavidDarnes, to random
@DavidDarnes@mastodon.design avatar

My friend from my Nord design system days @WickyNilliams has created a set of for displaying calendars called ‘cally’.

You should definitely check it out:
https://wicky.nillia.ms/cally/

stuffbreaker, to random

Storybook Helpers 2.0 have landed!

https://www.npmjs.com/package/wc-storybook-helpers

Changes include:

  • Storybook 8 support
  • Removed v6 support
  • A new sandbox for testing
  • Improved syntax and formatting when showing code
  • Updated configuration API

Check it out!

joe, to javascript

Yesterday, we looked at how to define our own web components and how to use web components that were defined using Shoelace. Today, I figured that we should take a quick look at Lit. Lit is a simple library for building fast, lightweight web components.

Let’s see what yesterday’s “hello world” demo would look like with Lit.

See the Pen by Joe Steinbring (@steinbring)
on CodePen.

The syntax is a lot more pleasing in my humble opinion. Let’s see how to do something a little more complex, though.

See the Pen by Joe Steinbring (@steinbring)
on CodePen.

This example defines <blog-feed></blog-feed> with a json parameter. Lit has a <a href="https://lit.dev/docs/components/lifecycle/#connectedcallback">connectedCallback()</a> lifecycle hook that is invoked when a component is added to the document’s DOM. Using that, we are running this.fetchBlogFeed() which in turn running await fetch(). It is then using https://lit.dev/docs/components/rendering/ to render the list items.

I am kind of digging Lit.

https://jws.news/2024/playing-more-with-web-components/

  • All
  • Subscribed
  • Moderated
  • Favorites
  • JUstTest
  • mdbf
  • ngwrru68w68
  • modclub
  • magazineikmin
  • thenastyranch
  • rosin
  • khanakhh
  • InstantRegret
  • Youngstown
  • slotface
  • Durango
  • kavyap
  • DreamBathrooms
  • megavids
  • GTA5RPClips
  • ethstaker
  • normalnudes
  • tester
  • osvaldo12
  • everett
  • cubers
  • tacticalgear
  • anitta
  • Leos
  • provamag3
  • cisconetworking
  • lostlight
  • All magazines