Code Monkey home page Code Monkey logo

svelte-tag's Introduction

Svelte-tag

Node.js Package

A webcomponet wrapper for svelte.

This embeds your svelte app inside a single component. It also forwards all slots and attributes into your svelte app.

Why?

Svelte already allows you to create webcomponents. However it has a couple of flaws:

  • All of your nested components have to be webcomponents as the render flag applies to everything.
  • You have to use shadow dom.
  • You have to deal with lots of bugs.
  • You loose many features svelte has for inter-component communication.

How do I use it?

npm install svelte-tag
import component from "svelte-tag"
import App from "your-app.svelte"
new component({component:App,tagname:"hello-world",href="/your/stylesheet.css",attributes:["name"]})

Now anywhere you use the <hello-world> tag you'll get a svelte app. Obviously you can set your tag name to anything containing a dash.

<hello-world name="Cris"></hello-world>
Option Description
component Your svelte component
tagname The webcomponent tag-name, must contain a dash
href link to your stylesheet - optional, but required with shadow dom
attributes array - attributes you like your tag to forward to your component
shadow boolean - should this component use shadow dom

Todo

  • Upload Tests
  • Setup CI

Support

Be aware, I don't have a lot of time to support this package. I've mainly open sourced it because I've noticed lots of people with similar use cases. If you open an issue I'll respond but it may not be super quick. I'll accept pull requests to fix any issues, but I'd prefer not to add additional functionality.

Attribution

Logo - Rich Harris, MIT http://opensource.org/licenses/mit-license.php, via Wikimedia Commons

svelte-tag's People

Contributors

crisward avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.