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

smile-to-unlock

v0.0.7

Published

Smile To Unlock

Downloads

38

Readme

Smile To Unlock

Want to give away free content on your site? How about asking for a smile in return 😁

Demo

IMAGE ALT TEXT HERE

You can also see it working on my site here: https://codecraft.tv/courses/angular/es6-typescript/decorators/

What is it?

Smile To Unlock is a Web Component built using the StencilJS compiler, so is framework agnostic, can be used in an Angular, Vue, React or even in a vanilla web application.

Smile To Unlock captures an image from the users camera and uses the Azure Cognitive Services Emotive API to figure out how happy the person is.

  • NOTE: On the FREE tier you get 30,000 API requests a month.

Getting Started

  1. Include smiletounlock.js in your HTML file
  • via a script tag (quickest)
<script src="https://unpkg.com/smile-to-unlock@latest/dist/smiletounlock.js"></script>
  • or via a node module
npm install smile-to-unlock --save

Then add a script tag to your HTML like so:

 <script src='node_modules/smile-to-unlock/dist/smiletounlock.js></script>
  1. Grab an API Key from Azure
  • NOTE: On the FREE tier you get 30,000 API requests a month.
  1. Add this tag to your HTML
<smile-to-unlock api-key="<YOUR_API_KEY_HERE>"></smile-to-unlock>
  1. Add this code to trigger the component
var locker = document.querySelector('smile-to-unlock');
locker.start();

This opens the component full screen and starts asking the user to smile.

  1. Add this code to check to see if the user has smiled
locker.addEventListener("userSmiled", function (ev) {
    // --> Add the code to show the free content here <--
    
    locker.end(); // End the locker so the camera is shutdown
})

Using the helper hider

As a shortcut if you just have a video or part of the page you want to hide from the user unless they smile you can use the helper <smile-to-unlock-hider></smile-to-unlock-hider> component.

  1. Place the hider inside the component you want to hide.

NOTE: The element you want to hide should have the style position: relative;

<div class="this-is-what-want-to-hide" style="position: relative;">
    <!-- This will add a black overlay to any content with some text and a button to start the smiling process -->
    <smile-to-unlock-hider></smile-to-unlock-hider>

    <!-- This is the actual unlocker component  -->
    <smile-to-unlock api-key="<YOUR_API_KEY_HERE>"></smile-to-unlock>
</div>
  1. Then make sure to add this code at the end of your html file somewhere:
  • This code shows the hider overlay over the content you want to hide (so the user can't see it or click on any buttons if it's a video).
(function() {
    var hider = document.querySelector('smile-to-unlock-hider');
    var locker = document.querySelector('smile-to-unlock');

    // This event is called when the user has clicked Smile To Unlock
    hider.addEventListener("readyToSmile", function (ev) {
    // Starts the locker full screen
    locker.start();

    // This event is sent when the user has smiled
    locker.addEventListener("userSmiled", function (ev) {
        console.log(ev.detail.score);

        // Hide the hider so we show the content
        hider.hide();

        // End the locker so the camera is shutdown
        locker.end();
    })
    })
})();

Working on Smile To Unlock

To setup run:

npm install
npm start

To view the build, start an HTTP server inside of the /www directory.

To watch for file changes during develop, run:

npm run dev

To build the app for production, run:

npm run build