All Projects → 5t3ph → 11ty-web-component-generator

5t3ph / 11ty-web-component-generator

Licence: other
Use the power of 11ty to generate web components (custom elements).

Programming Languages

HTML
75241 projects
CSS
56736 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to 11ty-web-component-generator

file-attachment-element
Attach files via drag and drop or file input.
Stars: ✭ 97 (+90.2%)
Mutual labels:  web-components, custom-elements
11ta-template
Deeply customizable, full-featured, ready to publish blog template built with 11ty, TailwindCSS, & Alpine.js
Stars: ✭ 98 (+92.16%)
Mutual labels:  11ty, 11ty-template
CalDOM
An agnostic, reactive & minimalist (3kb) JavaScript UI library with direct access to native DOM.
Stars: ✭ 176 (+245.1%)
Mutual labels:  web-components, custom-elements
lego
🚀 Web-components made lightweight & Future-Proof.
Stars: ✭ 69 (+35.29%)
Mutual labels:  web-components, custom-elements
symbiote.js
Simple, light and very powerful library to create embedded components for any purpose, with a data flow management included.
Stars: ✭ 40 (-21.57%)
Mutual labels:  web-components, custom-elements
frontenso-11ty-starter
Production-ready 11ty+Gulp+Webpack Starter that features Nunjucks, SASS, TailwindCSS (with JIT complier), and ESNext.
Stars: ✭ 24 (-52.94%)
Mutual labels:  11ty, 11ty-template
page-title
A Polymer element for easily updating a webpage's title, such as in a SPA.
Stars: ✭ 13 (-74.51%)
Mutual labels:  web-components, custom-elements
Progressive Image Element
⚡️ <progressive-image> custom element
Stars: ✭ 231 (+352.94%)
Mutual labels:  web-components, custom-elements
grid-container
A grid for the future, CSS Grid Layout + Web Components (Custom Elements v1 + Shadow DOM v1)
Stars: ✭ 51 (+0%)
Mutual labels:  web-components, custom-elements
esl
Lightweight and flexible UI component library based on web components technology for creating basic UX modules
Stars: ✭ 53 (+3.92%)
Mutual labels:  web-components, custom-elements
web-components
A set of high-quality standards based web components for enterprise web applications. Part of Vaadin 20+
Stars: ✭ 322 (+531.37%)
Mutual labels:  web-components, custom-elements
element
Fast and simple custom elements.
Stars: ✭ 65 (+27.45%)
Mutual labels:  web-components, custom-elements
Tab Container Element
An accessible tab container element with keyboard support.
Stars: ✭ 238 (+366.67%)
Mutual labels:  web-components, custom-elements
focus-trap
A lightweight web component that traps focus within a DOM node
Stars: ✭ 44 (-13.73%)
Mutual labels:  web-components, custom-elements
Ajax Form
HTML forms on performance-enhancing drugs
Stars: ✭ 232 (+354.9%)
Mutual labels:  web-components, custom-elements
smart-webcomponents-community
Material & Bootstrap Web Components built with Smart
Stars: ✭ 30 (-41.18%)
Mutual labels:  web-components, custom-elements
Auto Complete Element
Auto-complete input values from server search results.
Stars: ✭ 213 (+317.65%)
Mutual labels:  web-components, custom-elements
Elements
Lazy load Angular Elements (or any other web components / custom elements ) with ease!
Stars: ✭ 223 (+337.25%)
Mutual labels:  web-components, custom-elements
remote-input-element
An input element that sends its value to a server endpoint and renders the response body.
Stars: ✭ 72 (+41.18%)
Mutual labels:  web-components, custom-elements
modulor-html
Missing template engine for Web Components
Stars: ✭ 36 (-29.41%)
Mutual labels:  web-components, custom-elements

⚡️ 11ty Web Component Generator

View the demo Hello World component >

Using the Generator

Eleventy (11ty) is a static site generator that makes it possible to mix templating languages. More importantly to this generator is that we can customize the output file type and composite a file from includes.

The web components are generated within a Nunjucks (.njk) template that outputs the final .js file.

This generator works with the inherent features of Eleventy, including that it expects templates and template partials to be placed in _includes.

This leads to the following file structure to create a web component with styles and additional scripting.

First, create the component template file in src/components/[component-name].njk. It is important to kebab-case the file name

Then within _includes/components/ create:

[component-name]/
  script.js
  style.css

Keep the names of script.js and style.css so that the _includes/component.njk template can successfully include their contents to generate the web component.

Using a Generated Web Component

The final web component will be output within public/components/[component-name].js and is ready to be included in another project such as:

<script type="module" src="path/to/component-name.js"></script>
<component-name></component-name>

Display a Component Within This Generator Project

Create additional pages in this project directly within src as Nunjuck (.njk) files and add the following frontmatter in addition to any HTML and Nunjuck template tags.

title: Page Title
component: component-name

Then the page.njk template will use the component value to include the relative path to the web component script.

Project Scripts

  • npm start - run Eleventy on localhost with included Browsersync hot-reload
  • npm run build - run only Eleventy for creating a production build of the generator project

Web Component Resources

First a little disclaimer - I am brand new to web components, so I know this doesn't cover all the things you may want to do, or the best way to generically composite them. Submit a PR if you want to help extend this generator!

Here are some resources that helped me put together my first web component:

11ty Resources

I'm very fond of 11ty, so here's a list of my other resources:

Learn to build an 11ty site in 20 mins with my egghead video course and see how to add a blog and custom data.

Add auto-generated social media images by following my tutorial

Explore advanced setup of custom data through my tutorial on building a community site

For a full-featured starter check out my 11ty Netlify Jumpstart (also works for hosts other than Netlify).

For a featureless Sass starter grab the template for my 11ty Sass Skeleton

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].