npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@numbersprotocol/capture-eye

v1.1.1

Published

Capture Eye widget seamlessly integrates into your website, facilitating secure and transparent provenance display and purchases of digital content directly from the creator

Downloads

202

Readme

Capture Eye

Capture Eye widget seamlessly integrates into your website, facilitating secure and transparent provenance display and purchases of digital content directly from the creator.

  • Easily integrate with your digital products
    • Capture Eye effortlessly blends with your existing platforms, elevating your content's value and trustworthiness.
  • Decentralized storage of the actual media asset
    • Secure, immutable and long-lasting preservation of your original digital assets, enhancing their credibility and authenticity.

Quickstart

<head>
  <script
    type="module"
    src="https://cdn.jsdelivr.net/npm/@numbersprotocol/capture-eye@latest/dist/capture-eye.bundled.js"
  ></script>
</head>
<body>
  <capture-eye
    nid="bafybeief3yriouin54tzub5otnzka6muacrsu32tl2vxnaexgffizdxxqy"
  >
    <media-viewer
      width="600px"
      src="https://ipfs-pin.numbersprotocol.io/ipfs/bafybeief3yriouin54tzub5otnzka6muacrsu32tl2vxnaexgffizdxxqy"
    />
  </capture-eye>
</body>

The Capture Eye comes with a helper component media-viewer that could automatically detect the source url file type and display image or video respectively. It is NOT necessary to use <media-viewer> component. If you wish to use your own component to display the asset, you may use <img>, <video> or any other custom component as the child element of <capture-eye>.

Visit the interactive playground for the live demo.

Component attributes

| Attribute Name | Required | Description | Example | | -------------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- | | nid | Yes | The unique Nid of the asset. | <capture-eye nid="bafybeief3yriouin54tzub5otnzka6muacrsu32tl2vxnaexgffizdxxqy"></capture-eye> | | layout | No | Decides which layout to display. Default value is original. Additional option includes curated. | <capture-eye nid="..." layout="curated"></capture-eye> | | visibility | No | Visibility behavior. Default value is hover, showing Eye on mouse hover. Setting it to option always will make the Eye always shown. | <capture-eye nid="..." visibility="always"></capture-eye> | | eng-img | No | Override the engagement zone banner image. Recommended size is 400x200 px but any image with width >= 320px should work. | <capture-eye nid="..." eng-img="https://my.image.url/image.png"></capture-eye> | | eng-link | No | Override the engagement zone banner link. | <capture-eye nid="..." eng-link="https://my.website.url"></capture-eye> | | action-button-text | No | Override the default action button text (View More). | <capture-eye nid="..." action-button-text="Collect"></capture-eye> | | action-button-link | No | Override the default action button link to Capture website. | <capture-eye nid="..." action-button-link="https://my.website.url"></capture-eye> |

Integration with Frontend Frameworks

Capture Eye has been designed as a web component to facilitate seamless integration with both vanilla HTML and various frontend frameworks.

Vanilla HTML

The most simple way of adding Capture Eye to a webpage is by importing via CDN and add the component tag:

<head>
  <script
    type="module"
    src="https://cdn.jsdelivr.net/npm/@numbersprotocol/capture-eye@latest/dist/capture-eye.bundled.js"
  ></script>
</head>
<body>
  <capture-eye
    nid="bafybeief3yriouin54tzub5otnzka6muacrsu32tl2vxnaexgffizdxxqy"
  >
    <img
      width="600px"
      src="https://ipfs-pin.numbersprotocol.io/ipfs/bafybeief3yriouin54tzub5otnzka6muacrsu32tl2vxnaexgffizdxxqy"
    />
  </capture-eye>
</body>

For a full example, see the example html.

To run a development server and view the example HTML in your browser, execute the following command:

npm run dev

React

To add Capture Eye to a React application, first install the packages:

npm i @numbersprotocol/capture-eye @lit/react

Add the following code to define a React component for Capture Eye:

import React from 'react';
import { createComponent } from '@lit/react';
import { CaptureEye } from '@numbersprotocol/capture-eye';

const CaptureEyeComponent = createComponent({
  tagName: 'capture-eye',
  elementClass: CaptureEye,
  react: React,
  events: {
    onactivate: 'activate',
    onchange: 'change',
  },
});

Use the CaptureEyeComponent in JSX:

<CaptureEyeComponent nid="bafybeief3yriouin54tzub5otnzka6muacrsu32tl2vxnaexgffizdxxqy">
  <img src="https://ipfs-pin.numbersprotocol.io/ipfs/bafybeief3yriouin54tzub5otnzka6muacrsu32tl2vxnaexgffizdxxqy" />
</CaptureEyeComponent>

Angular

To add Capture Eye to an Angular application, first install the packages:

npm i @numbersprotocol/capture-eye @webcomponents/webcomponentsjs

Add the webcomponents loader to the script section in angular.json:

...
"scripts": [
  "node_modules/@webcomponents/webcomponentsjs/webcomponents-loader.js"
],
...

Make sure CUSTOM_ELEMENTS_SCHEMA is set in your module:

import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
@NgModule({
  schemas: [CUSTOM_ELEMENTS_SCHEMA],
  ...
})

Finally, import the Capture Eye package in your *.component.ts and add the <capture-eye nid="..."></capture-eye> template tag to your component:

import '@numbersprotocol/capture-eye';
<capture-eye nid="bafybeief3yriouin54tzub5otnzka6muacrsu32tl2vxnaexgffizdxxqy">
  <img
    width="600px"
    src="https://ipfs-pin.numbersprotocol.io/ipfs/bafybeief3yriouin54tzub5otnzka6muacrsu32tl2vxnaexgffizdxxqy"
  />
</capture-eye>

Vue

For Vue users, the usage is similar to use native HTML elements. The official Vue doc provides a guide on Using Vue with Web Components.

To add Capture Eye to a SFC, simply import the Capture Eye package in the script setup and add the component tag in the template:

<script setup>
import '@numbersprotocol/capture-eye';
</script>

<template>
  <main>
    <capture-eye
      nid="bafybeief3yriouin54tzub5otnzka6muacrsu32tl2vxnaexgffizdxxqy"
    >
      <img
        width="600"
        src="https://ipfs-pin.numbersprotocol.io/ipfs/bafybeief3yriouin54tzub5otnzka6muacrsu32tl2vxnaexgffizdxxqy"
      />
    </capture-eye>
  </main>
</template>

Controlling Capture Eye with JavaScript

The <capture-eye> web component provides several methods to control its behavior programmatically. You can interact with the component using the following public methods:

get isOpened()

Description: Returns a boolean indicating whether the modal is currently open.

Usage:

const captureEyeElement = document.querySelector('capture-eye');
console.log(captureEyeElement.isOpened); // true if modal is open, false otherwise

open()

Description: Opens the modal.

Usage:

const captureEyeElement = document.querySelector('capture-eye');
captureEyeElement.open();

close()

Description: Closes the modal.

Usage:

const captureEyeElement = document.querySelector('capture-eye');
captureEyeElement.close();

Style customization

Capture Eye utilizes shadow DOM for encapsulation as a web component. However, if needed, the encapsulated styles could still be modified for any specific customization need. The section uses vanilla HTML/JavaScript to demonstrate how it is done. For different frontend frameworks it could also be done easily following the same logic.

To customize the Capture Eye button, access and modify the shadow DOM of Capture Eye after it is loaded.

Example of changing the icon and width/height:

<script>
  document.addEventListener('DOMContentLoaded', () => {
    const captureEyeElements = document.querySelectorAll('capture-eye');

    captureEyeElements.forEach((element) => {
      const img = element.shadowRoot.querySelector('.capture-eye-button img');
      img.src =
        'https://ipfs-pin.numbersprotocol.io/ipfs/bafybeief3yriouin54tzub5otnzka6muacrsu32tl2vxnaexgffizdxxqy';
      img.style.width = '30px';
      img.style.height = '30px';
    });
  });
</script>

In contrast to Capture Eye button, the Capture Eye modal is not a child element of it, instead it is injected to document root to act as a singleton and ensure it is not affected by parent element's inheritable styles, such as CSS transform.

Example of changing the modal background color:

<script>
  document.addEventListener('DOMContentLoaded', () => {
    const captureEyeModal = document.querySelector('capture-eye-modal');
    const modalContentDiv =
      captureEyeModal.shadowRoot.querySelector('.modal-container');
    modalContentDiv.style.background = 'midnightblue';
  });
</script>