All Projects → abraham → Nutmeg

abraham / Nutmeg

Licence: mit
Build, test, and publish vanilla Web Components with a little spice

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to Nutmeg

Omi
Front End Cross-Frameworks Framework - 前端跨框架跨平台框架
Stars: ✭ 12,153 (+10848.65%)
Mutual labels:  web-components, webcomponents, custom-elements, shadow-dom
svelte-webcomponents
A ready-to-use project template to build custom elements (web components) with Svelte 3 with support and examples for web components, jest, sass, nested components with props, eslinting, stylelinting, Github actions, propagating custom events from shadow-DOM to real-DOM etc.
Stars: ✭ 22 (-80.18%)
Mutual labels:  web-components, custom-elements, shadow-dom
Vanilla Hamburger
Animated hamburger menu icons for modern web apps (1.8 KB) 🍔
Stars: ✭ 110 (-0.9%)
Mutual labels:  web-components, webcomponents, custom-elements
Switzerland
🇨🇭Switzerland takes a functional approach to Web Components by applying middleware to your components. Supports Redux, attribute mutations, CSS variables, React-esque setState/state, etc… out-of-the-box, along with Shadow DOM for style encapsulation and Custom Elements for interoperability.
Stars: ✭ 261 (+135.14%)
Mutual labels:  webcomponents, custom-elements, shadow-dom
toggle-icon
toggle-icon is a custom element created with Polymer. It provides an extremely powerful and customizable switch that looks like a paper-icon-button.
Stars: ✭ 21 (-81.08%)
Mutual labels:  webcomponents, web-components, custom-elements
cwco
Powerful and Fast Web Component Library with a Simple API
Stars: ✭ 27 (-75.68%)
Mutual labels:  webcomponents, web-components, custom-elements
Aybolit
Lightweight web components library built with LitElement.
Stars: ✭ 90 (-18.92%)
Mutual labels:  web-components, webcomponents, custom-elements
element
Fast and simple custom elements.
Stars: ✭ 65 (-41.44%)
Mutual labels:  web-components, custom-elements, shadow-dom
Remount
Mount React components to the DOM using custom elements
Stars: ✭ 522 (+370.27%)
Mutual labels:  web-components, custom-elements, shadow-dom
Xy Ui
🎨面向未来的原生 web components UI组件库
Stars: ✭ 603 (+443.24%)
Mutual labels:  web-components, custom-elements, shadow-dom
Crab
JavaScript library for building user interfaces with Custom Elements, Shadow DOM and React like API
Stars: ✭ 22 (-80.18%)
Mutual labels:  webcomponents, custom-elements, shadow-dom
lit-components
Moved to https://github.com/vaadin/component-mixins
Stars: ✭ 59 (-46.85%)
Mutual labels:  webcomponents, web-components, custom-elements
focus-trap
A lightweight web component that traps focus within a DOM node
Stars: ✭ 44 (-60.36%)
Mutual labels:  web-components, custom-elements, shadow-dom
custom-elements-manifest
Custom Elements Manifest is a file format that describes custom elements in your project.
Stars: ✭ 81 (-27.03%)
Mutual labels:  webcomponents, web-components, custom-elements
lego
🚀 Web-components made lightweight & Future-Proof.
Stars: ✭ 69 (-37.84%)
Mutual labels:  webcomponents, web-components, custom-elements
anywhere-webcomponents
A UI work in progress based on custom elements (web components) for use in anywhere.
Stars: ✭ 17 (-84.68%)
Mutual labels:  webcomponents, web-components, custom-elements
Custom Elements Ts
Create native custom elements using Typescript
Stars: ✭ 52 (-53.15%)
Mutual labels:  web-components, custom-elements, shadow-dom
crab
JavaScript library for building user interfaces with Custom Elements, Shadow DOM and React like API
Stars: ✭ 22 (-80.18%)
Mutual labels:  webcomponents, custom-elements, shadow-dom
modulor-html
Missing template engine for Web Components
Stars: ✭ 36 (-67.57%)
Mutual labels:  webcomponents, web-components, custom-elements
Vanilla Colorful
A tiny color picker custom element for modern web apps (2.7 KB) 🎨
Stars: ✭ 467 (+320.72%)
Mutual labels:  web-components, webcomponents, custom-elements
Nutmeg icon Nutmeg logo

Build, test, and publish vanilla Web Components with a little spice

Version Status macOS Build Status Linux Build Status Windows Build Status Dependency Status

🚧 Nutmeg is in active development and it's APIs are still in flux.

👌 Overview

Nutmeg is here to help you build, test, and publish Web Components in minutes.

By default you get the following:

  • Custom Elements v1
  • Shadow DOM v1
  • TypeScript
  • lit-html
  • Webpack
  • Karma test runner with headless browser launchers
  • Git
  • MIT license
  • Web Component best practices

🌱 Build

Generating a Nutmeg Web Component skeleton with npm init has the API <element-name> [property:type...].

npm init @nutmeg hello-world name:string

This will create a hello-world directory, stub out a base Web Component class HelloWorld that extends the Nutmeg Seed base class, and install the default dependencies. You can use either fullName or full-name for multi-word properties and full-name will be used for HTML attributes and fullName will be used in JavaScript.

Note: Yarn is not supported but may work.

🏡 Properties

Properties must be valid TypeScript types. For example string, boolean, number, string[], Element.

npm init @nutmeg grilled-cheese quantity:number pickles:boolean cheese:string[]

Properties are the public API of your Web Component and external code can set/get them.

export class GrilledCheese extends Seed {
  @property() public bread: string;
  @property() public cheese: string[];
  @property() public pickles: boolean;
  @property() public quantity: number;
  ...
}

The @property() decorator provides some nice features out of the box. There are two kinds of properties.

  • Primitive: boolean, string, and number.
  • Complex: any types that are not primitive.

✍️ Automatic rendering

Any properties decorated with @property will automatically render when set.

📟 Primitive properties are reflected to the DOM

  • boolean: grilledCheese.pickle = true; => <grilled-cheese pickle></grilled-cheese>
  • number: grilledCheese.quantity = 5; => <grilled-cheese quantity="5"></grilled-cheese>
  • string: grilledCheese.bread = 'sourdough'; => <grilled-cheese bread="sourdough"></grilled-cheese>

📱 One-time complex property loading from attributes

On instantiation of a Web Component a one-time loading and JSON parsing happens of complex properties. In the following example cheese has the type of string[]. When connected the component will have the attribute removed and the value set as a property after JSON.parse.

The following example:

<grilled-cheese cheese="[\"sharp cheddar\"]"></grilled-cheese>

Yields:

grilledCheese.cheese.includes('sharp cheddar') === true;
<grilled-cheese></grilled-cheese>

$ and $$

$ and $$ are shortcuts provided for quickly selecting elements within the shadowRoot.

  • $ is a shortcut for this.shadowRoot.querySelector.
  • $$ is a shortcut for this.shadowRoot.querySelectorAll.

🍽️ Serve

You can now serve the component for development on http://localhost:8080 by running:

npm start

With start running you can make edits to the component and see the changes take effect automatically without manually refreshing.

🧪 Test

Running the tests from within hello-world.

npm test

🔭 Continuous Integration

Components are generated with AppVeyor, CircleCI, and TravisCI pre-configured to run tests on Windows, macOS, and Linux respectively.

🗞️ Publish

Publishing to NPM is easy but make sure you are logged in first with npm login. Be sure to fill out package.json values like author and update the name in readme.md if you change it.

npm publish

📇 Dependencies

Once published, it's recommended that you set up Renovate to keep your dependencies current. Nutmeg has already setup a default renovate config for you, you just have to install the free GitHub app.

😎 Best practices

Out of the box many of the Google Web Fundamentals Custom Element Best Practices are handled automatically.

🔍 Examples

👔 License

Nutmeg is released under an MIT license.

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].