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

@bachdx/b-vuse

v1.3.6

Published

useful self made vue3 composables

Downloads

441

Readme

@bachdx/b-vuse

Most used vue composables which I would like to make it betters to share between my projects

Prerequisites

This project requires NodeJS (version 16 or later) and NPM. Node and NPM are really easy to install. To make sure you have them available on your machine, try running the following command.

$ npm -v && node -v
9.6.5
v16.14.0

Table of contents

Getting Started

Installation

BEFORE YOU INSTALL: please read the prerequisites

Start with cloning this repo on your local machine:

To install and set up the library, run:

$ npm i @bachdx/b-vuse

Or if you prefer using Yarn:

$ yarn add @bachdx/b-vuse

Core Functions

useBreadcrumb

The breadcrumb control that can share across all components without using localStorage or any storage but still reactive

Most of my project using the same structure for breadcrumb as below

Most Used Breadcrumb and Page Title

const breadcrumb = {
  title: "Dummy title",
  items: [
    {
      text: "First Item",
      href: "/first-item",
      active: false, // should be false for all items except last one
    },
    {
      text: "Last Item",
      href: "/last-item",
      active: true,
    },
    // ...another last on your demands
  ],
};

And the component for rendering the breadcrumb

<template>
  <div class="row">
    <div class="col-12">
      <div
        class="page-title-box d-flex align-items-center justify-content-between"
      >
        <h4 class="mb-0 font-size-18">{{ breadcrumb.title }}</h4>

        <div class="page-title-right">
          <!-- I use vue bootrap here but you can you anything you want -->
          <b-breadcrumb class="m-0">
            <b-breadcrumb-item
              v-for="(item, i) in breadcrumb.items"
              :key="i"
              :text="item.text"
              :to="item.href"
              :active="item.active"
            ></b-breadcrumb-item>
          </b-breadcrumb>
        </div>
      </div>
    </div>
  </div>
</template>

So if you dont want to use the title, be my guest, just remove the breadcrumb.title

Import
import { useBreadcrumb } from "@bachdx/b-vuse";
Usage Example:
In page (component) where you need to change the breadcrumb
import { useBreadcrumb } from "@bachdx/b-vuse";
const { setBreadcrumb } = useBreadcrumb();

setBreadcrumb({
  title: "User List",
  items: [
    {
      text: "User",
      href: "/users",
    },
    {
      text: "List",
      active: true,
    },
  ],
});
In the actual breadcrumb rendering component
import { useBreadcrumb } from "@bachdx/b-vuse";
const { breadcrumb, getBreadcrumb } = useBreadcrumb();
getBreadcrumb();

after this you should be able to change the page ( components ) and will have the reactive breadcrumb on every page

Notice:

You might need to set your router setup to reset the content of breadcrumb before each route changed by doing this

setBreadcrumb({});

Data and Methods

| Type | Name | Attributes/Params | | -------- | ------------- | ----------------------------------------------------------------------------------- | | ref | breadcrumb | { 'title': String, 'items': [{'text: String, 'href': String, 'active': Boolean }] } | | function | getBreadcrumb | None | | function | setBreadcrumb | { 'title': String, 'items': [{'text: String, 'href': String, 'active': Boolean }] } |

useQuery ( use for Rails backend and pagy + ransack supported )

The query object that most of my project use for supporting query data from server and paging support

const queryInput = {
  page: 1,
  perPage: 10,
  q: {}, // this should be ransacker support object
};
Import
import { useQuery } from "@bachdx/b-vuse";
Usage Example:
In Pinia Store and components ( maybe )
const { queryInput, resetQuery, updateQuery } = useQuery();

or you can change the default params as your needs

const { queryInput, resetQuery, updateQuery } = useQuery({ perPage: 15 });
To update query ( such as page)
updateQuery({ page: page });

Data and Methods

| Type | Name | Attributes/Params | | ---------- | ----------- | ------------------------------------- | | QueryInput | queryInput | { 'page': 1, 'perPage': 10, 'q': {} } | | function | resetQuery | None | | function | updateQuery | { 'page': 1, 'perPage': 10, 'q': {} } |

useGoQuery ( use for Go backend )

The query object that most of my project use for supporting query data from server and paging support

Import
import { useGoQuery } from "@bachdx/b-vuse";
Usage Example:
In Pinia Store and components ( maybe )
const query = reactive({}); // this could be anything related to search key
const { goQueryInput, updatePage } = useGoQuery({ perPage: 10, query: query });
To update page/perPage/Query
updatePage(page, callbackFunction);

Data and Methods

| Type | Name | Attributes/Params | | ------------ | ------------- | --------------------------------------------------- | | GoQueryInput | goQueryInput | { pagyInput: {'page': , 'perPage': }, 'query': {} } | | function | updatePerPage | perPage | | function | updatePage | page, callbackFunction | | function | updateQuery | { 'page': 1, 'perPage': 10, 'q': {} } | | function | resetQuery | callbackFunction |

Contributing

  1. Clone it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Add your changes: git add .
  4. Commit your changes: git commit -am 'Add some feature'
  5. Push to the branch: git push origin my-new-feature
  6. Submit a pull request :sunglasses:

Authors

  • bachdx (https://github.com/bachdx2812)
  • Hopefully more to come here...

License

UNLICENSED