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

@npetri/alpinejs-hobbykit

v1.1.1

Published

An alpine package with some useful extensions.

Downloads

18

Readme

AlpineJS Hobby Kit

License Version

An AlpineJS Plugin with some useful extension.

Installation

Via CDN

<!-- Alpine Plugins -->
<script src="https://unpkg.com/@npetri/[email protected]/dist/plugin.min.js" defer></script>
<!-- Alpine Core -->
<script defer src="https://unpkg.com/[email protected]/dist/cdn.min.js"></script>

Via NPM

npm i @npetri/alpinejs-hobbykit

As Plugin

import Alpine from 'alpinejs'
import hobbykit from '@npetri/alpinejs-hobbykit'
Alpine.plugin(hobbykit)

window.Alpine = Alpine
window.Alpine.start()
As Single Function

All directives were available as single exports. You can use them to reduce code. Available functions:

  • AlpineTimeout
  • AlpineInterval
  • AlpineLog
  • AlpineScroll
import Alpine from 'alpinejs'
import { AlpineInterval, AlpineLog } from '@npetri/alpinejs-hobbykit'

Alpine.directive('interval', AlpineInterval)
Alpine.directive('log', AlpineLog)

window.Alpine = Alpine
window.Alpine.start()

x-interval

Evaluate the given expression at every given time-interval.

<section x-data="{ counter: 0 }">
    <span x-text="counter" x-interval.1000="counter++"></span>
</section>

x-timeout

Evaluate the given expression after the given time.

<section x-data="{ show: false }">
    <span x-show="show" x-timeout.2000="show = true">Hidden Message</span>
</section>

x-log

Logs the given expression. You can use the well known log levels warn error etcpp.

<section x-data="{
    log: 'A log message via x-log.',
    error: 'An error message via x-log.',
    info: 'An info message via x-log.',
    def: 'A message via x-log invoked as fallback.'
    }">
    <span x-log="log"></span>
    <span x-log.warn="() => { return 'A warn message via x-log.' }"></span>
    <span x-log.error="error"></span>
    <span x-log.info="info"></span>
    <span x-log.jhkj="def"></span>
</section>

x-scroll

Detects the browser scrolling and evaluates the given expression. A debounce or throttle modifier can be added. Remember, the scroll event is never triggered if a height of 100% or 100vh on the body tag was applied.

<section>
    <style>
        .fixed-scroll-indicator {
            display: inline-block;
            position: fixed;
            bottom: 0px;
            right: 0px;
            padding: 5px;
            background-color: cadetblue;
            color: white;
            font-weight: 900;
        }
    </style>
    <script>
        const compScroll = () => { return {
            isScrollUp: false,
            isScrollDown: false
        }}
    </script>

    <div class="fixed-scroll-indicator" x-data="compScroll">
        <span x-show="isScrollUp" x-scroll:up.debounce.750="isScrollUp=true; isScrollDown=false;">Up</span>
        <span x-show="isScrollDown" x-scroll:down.throttle.750="isScrollDown=true; isScrollUp=false;">Down</span>
    </div>
</section>