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

bonn

v0.9.2

Published

Utility, style and component library for web development.

Downloads

2

Readme

Bonn

Convenient utility, style and components library for web projects:

  • JavaScript utilities
  • SCSS mixins, variables and default styles
  • SVG icon set
  • Vercel endpoint helpers
  • GitHub actions code
  • Vue and Nuxt apps
    • Vue components
    • Vue composables
    • Pinia stores
    • Nuxt head and config helpers

Utilities can be used in any JS project, including server-side. Similarly, SCSS and SVGs can be used in any project, not only Vue or Nuxt projects.

Installation

Install Bonn and (optional) dependencies:

npm i bonn lodash-es date-fns

You might need additional peer dependencies depending on the type of project and the components you use. See the relevant docs for more details.

Setup on Nuxt

Use the nuxt.config helpers to load Bonn's Nuxt module and other relevant configurations:

import {
  mergeConfigs,
  bonn,
  scss,
  svg
} from 'bonn/nuxt/config/bonn'

export default defineNuxtConfig(mergeConfigs(
  // You'll probably want to enable SCSS and SVG in your Nuxt app
  scss(),
  svg(),

  // Enable Bonn
  bonn({
    // components: false,
    // composables: false,
    // icons: false,
    // prefix: 'Bonn'
  }),

  // Add your own Nuxt config here...
  {
    // ...
  }
))

Usage

.js utilities

import formatFileSize from 'bonn/utils/formatFileSize'

formatFileSize(19238028)

.vue components

components/ are NOT built during install. You must transpile them yourself in your project.

<script>
import ClickButton from 'bonn/components/ClickButton'

export default {
  components: {
    ClickButton
  }
}
</script>

<template>
  <ClickButton />
</template>

Note that when using <script setup>, you don't have to export the components. In a Nuxt project, components are also auto imported so you can directly use them in your templates.

Vue composables

import useIsMounted from 'bonn/composables/useIsMounted'

const isMounted = useIsMounted()

export default {
  data () {
    return {
      isMounted
    }
  }
}

Pinia stores/

import useDevice from 'bonn/stores/device'

const device = useDevice()

nuxt.config helpers

import { mergeConfigs, dev, assets, scss, svg } from 'bonn/nuxt/config'

export default defineNuxtConfig(mergeConfigs(
  assets({ /*...*/ }),
  scss({
    global: 'styles/global.scss',
    shared: 'styles/shared.scss'
  }),
  svg(),
  dev({
    typescript: {
      shim: false
    }
  })
))

.svg icons

Auto imported in a Nuxt project:

<Icon>
  <IconChevronUp />
</Icon>

The Icon component renders the SVG assets in a standard size, but is not required.

.scss mixins and styles

scss/ contains useful, generic mixins and functions for developing web sites and apps. It is designed to be compatible with components/, but can be used independently.

import formatFileSize from 'bonn/utils/formatFileSize'

formatFileSize(19238028)

In your SCSS code, import everything:

@import 'bonn/scss';

Basic customisation:

@import 'bonn/scss/shared';

@import './my-variables';   // Override default SCSS variables here

@import 'bonn/scss/global'; // CSS variables, normalisation and defaults
@import 'bonn/scss/utils';   // Optional

Advanced customisation:

// shared.scss
@import 'bonn/scss/variables-scss';
@import 'bonn/scss/functions';
@import 'bonn/scss/mixins';

// Custom SCSS variables
@import './my-variables';

// Normalizations and defaults (these output CSS)
@import 'bonn/scss/variables';
@import 'bonn/scss/normalize';
@import 'bonn/scss/defaults';
@import 'bonn/scss/utils';

You can optimise your build even further by including only some defaults and utilities:

@import 'bonn/scss/defaults/body';
@import 'bonn/scss/defaults/forms';
@import 'bonn/scss/defaults/tables';

@import 'bonn/scss/utils/bodytext';

Import from a JavaScript file:

import 'bonn/scss/shared';
import 'bonn/scss/global';
import 'bonn/scss/utils';