opt-in-element

<opt-in>

A custom element to embed third party content with user consent.

Demo

Examples

  <!-- Use a template as direct child of the component -->
  <opt-in service="youtube">
    <form data-dialog>
      <!-- Form HTML omitted for brevity -->
    </form>

    <template data-content>
      <iframe src="https://www.youtube.com/…"></iframe>
    </template>
  </opt-in>
  <!-- Use an external template element -->
  <opt-in service="youtube" template="youtube-video">
    <form data-dialog>
      <!-- Form HTML omitted for brevity -->
    </form>
  </opt-in>
  <template id="youtube-video">
      <iframe src="https://www.youtube.com/…"></iframe>
  </template>

Installation

Choose one of the following options:

  1. Install via npm: npm install @dweidner/opt-in-element
  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="opt-in-element.js"></script>
<!-- 3rd party CDN, not recommended for production use -->
<script type="module" src="https://www.unpkg.com/@dweidner/opt-in-element@1.0.0"></script>
<!-- 3rd party CDN, not recommended for production use -->
<script type="module" src="https://esm.sh/@dweidner/opt-in-element@1.0.0"></script>

Features