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

megio-frontils

v0.0.8

Published

Frontend utils for your web-projects.

Downloads

20

Readme

Megio frontils

Frontend utils for your web-projects.

Installation

yarn add megio-frontils

Setup

Analytics (GTM)

import { useAnalytics } from 'megio-frontils'

const gtm = useAnalytics()

gtm.injectScript()
gtm.trackLeadGenerate('eventLabel')
gtm.trackNewsletterSubscribe('eventLabel')
gtm.enableGtmCookie(type)
gtm.disableGtmCookie(type)
gtm.disableAllGtmCookies()

AntiSpam

import { useAntiSpam } from 'megio-frontils'

const antispam = useAntiSpam(timeOutMs, message)
antispam.isReady() // true | false

Carousel

import { useCarousel } from 'megio-frontils'

const el = document.getElementById('carousel')
const carousel = useCarousel(el, { autoPlay: { speed: 3000, enabled: true } })

carousel.create()
carousel.next()
carousel.prev()
carousel.getStats()

<style>
    .carousel-hide { ... }
    .carousel-show { ... }
</style>

<div id="carousel">
    <button data-carousel="next"></button>
    <button data-carousel="prev"></button>
    <div data-carousel="counter">0 / 0</div>
    <div>
        <div data-carousel="item">One</div>
        <div data-carousel="item">Two</div>
    </div>
</div>

Sticky-hiding navbar like jz.strategio.dev

import { useNavbar } from 'megio-frontils'

const navbar = useNavbar(showBgFrom, stayDownFor, stayUpFor)

navbar.registerEvents()
navbar.close()
navbar.open()
<style>
    .navbar.hidden { ... }
    .navbar.active { ... }
    .navbar.show-bg { ... }
    .navbar-hamburger.active { ... }
</style>

<body>
    <div class="navbar">
        <button class="navbar-hamburger">menu</button>
        <div class="navbar-content">
            <a href="/" data-navbar-link>Home</a>
            <a href="/blog" data-navbar-link>Blog</a>
        </div>
    </div>
</body>

Scroller

import { useScroller } from 'megio-frontils'

const scroller = useScroller(menuHeight)

scroller.registerEvents()
scroller.scrollTo(selector)
scroller.scrollDirection() // get current scrollign direction

Stepper

import { useStepper } from 'megio-frontils'

const stepper = useStepper()
scroller.registerEvents()
<style>
    [data-step].active { ... }
</style>

<div>
    <div data-step="1">1. Send form</div>
    <div data-step="2">2. Get online meet</div>
    <div data-step="3">3. Sign contract</div>
</div>

Switcher (tabs)

import { useSwitcher } from 'megio-frontils'

const el = document.getElementById('switcher')
const switcher = useSwitcher(el)

switcher.registerEvents()
<style>
    [data-switcher-btn].active { ... }
    [data-switcher-wrapper] > div.active { ... }
</style>

<div id="switcher">
    <button data-switcher-btn="1">Show first</button>
    <button data-switcher-btn="2">Show second</button>
    <div data-switcher-wrapper>
        <div>First content</div>
        <div>Second content</div>
    </div>
</div>

Contentio API

import { useContentioApi } from 'megio-frontils'

const apiUri = 'https://<project>.contentio.app/api'
const api = useContentioApi(apiUri)
await api.fetchApi(uri, { body: JSON.stringify({ data: 'xyz' }) })

Contentio thumbnails

import { useContentioThumbnails } from 'megio-frontils'

function onCreated(params, src) { console.log(params, src) }

const apiUri = 'https://<project>.contentio.app/api'
const thumbs = useContentioThumbnails(onCreated, apiUri)

thumbs.registerEvents() // register auto-creation of thumbnails
thumbs.replaceDomain(src) // return string
thumbs.replacePath(src) // return string
thumbs.extractParams(src) // return Params or null
thumbs.getImagesBySameSrc(src) // return HTMLImageElement[]
thumbs.loadThumbnail(src, params) // return void & invoe onCreated callback
thumbs.requestQueue // return string[]
<!-- Works only with src or href prefix: https://cdn.contentio.app/ -->
<img src="https://cdn.contentio.app/{$thumb->getSrc()}">