bigandy / slot-fun

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

slot-fun

A Web Component for investigating what can be done using the <slot /> in web components.

Demo | Further reading

Examples

General usage example:

<script type="module" src="slot-fun.js"></script>

<slot-fun>
  <button>Button</button>
</slot-fun>

Example using a fallback method:

<script type="module" src="slot-fun.js"></script>

<slot-fun>
  <button>Button</button>
  <a href="#">Anchor</a>
</slot-fun>
<style>
  slot-fun:not(:defined) button,
  slot-fun:defined a {
    display: none;
  }
</style>

Example using options or additional fallback method:

<script type="module" src="slot-fun.js"></script>

<slot-fun attribute="value">
  <button>Button</button>
</slot-fun>
<style>
  slot-fun[attribute="value"] {
    outline: 1px solid red;
  }
</style>

Features

This Web Component allows you to:

  • Check for…

Installation

You have a few options (choose one of these):

  1. Install via npm: npm install @bigandy/slot-fun
  2. Download the source manually from GitHub into your project.
  3. Skip this step and use the script directly via a 3rd party CDN (not recommended for production use)

Usage

Make sure you include the <script> in your project (choose one of these):

<!-- Host yourself -->
<script type="module" src="slot-fun.js"></script>
<!-- 3rd party CDN, not recommended for production use -->
<script
  type="module"
  src="https://www.unpkg.com/@bigandy/slot-fun@1.0.0/slot-fun.js"
></script>
<!-- 3rd party CDN, not recommended for production use -->
<script type="module" src="https://esm.sh/@bigandy/slot-fun@1.0.0"></script>

Credit

With thanks to the following people:

About

License:MIT License


Languages

Language:HTML 52.6%Language:JavaScript 47.4%