0.9.2 • Published 4 months ago

bonn v0.9.2

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

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';
0.9.2

4 months ago

0.9.1

4 months ago

0.8.9

4 months ago

0.8.5

4 months ago

0.8.4

4 months ago

0.8.7

4 months ago

0.8.6

4 months ago

0.8.1

4 months ago

0.8.3

4 months ago

0.8.2

4 months ago

0.9.0

4 months ago

0.7.5

5 months ago

0.7.2

6 months ago

0.7.1

6 months ago

0.7.4

5 months ago

0.7.3

6 months ago

0.7.0

6 months ago

0.5.21

9 months ago

0.5.19

11 months ago

0.5.20

11 months ago

0.5.18

12 months ago

0.5.16

12 months ago

0.5.17

12 months ago

0.5.15

12 months ago

0.5.12

1 year ago

0.5.13

1 year ago

0.5.10

1 year ago

0.5.11

1 year ago

0.5.8

1 year ago

0.5.7

1 year ago

0.5.9

1 year ago

0.5.4

1 year ago

0.5.3

1 year ago

0.5.6

1 year ago

0.5.5

1 year ago

0.5.2

1 year ago

0.5.1

1 year ago

0.4.9

2 years ago

0.4.8

2 years ago

0.2.17

2 years ago

0.2.16

2 years ago

0.2.15

2 years ago

0.2.14

2 years ago

0.2.13

2 years ago

0.2.12

2 years ago

0.2.11

2 years ago

0.2.10

2 years ago

0.3.0

2 years ago

0.3.5

2 years ago

0.3.8

2 years ago

0.3.2

2 years ago

0.3.1

2 years ago

0.3.4

2 years ago

0.3.3

2 years ago

0.4.10

2 years ago

0.0.105

2 years ago

0.0.104

2 years ago

0.4.11

2 years ago

0.4.12

2 years ago

0.4.5

2 years ago

0.4.4

2 years ago

0.4.6

2 years ago

0.4.1

2 years ago

0.4.0

2 years ago

0.4.3

2 years ago

0.4.2

2 years ago

0.1.10

2 years ago

0.1.0

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.8

2 years ago

0.1.7

2 years ago

0.1.9

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.3.9

2 years ago

0.3.13

2 years ago

0.3.12

2 years ago

0.3.11

2 years ago

0.3.10

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.2.7

2 years ago

0.2.6

2 years ago

0.2.9

2 years ago

0.2.8

2 years ago

0.2.3

2 years ago

0.2.2

2 years ago

0.2.5

2 years ago

0.2.4

2 years ago

0.0.84

2 years ago

0.0.85

2 years ago

0.0.86

2 years ago

0.0.87

2 years ago

0.0.88

2 years ago

0.0.89

2 years ago

0.0.80

2 years ago

0.0.81

2 years ago

0.0.82

2 years ago

0.0.83

2 years ago

0.0.73

2 years ago

0.0.74

2 years ago

0.0.75

2 years ago

0.0.76

2 years ago

0.0.77

2 years ago

0.0.78

2 years ago

0.0.79

2 years ago

0.0.70

2 years ago

0.0.71

2 years ago

0.0.72

2 years ago

0.0.62

2 years ago

0.0.63

2 years ago

0.0.64

2 years ago

0.0.65

2 years ago

0.0.66

2 years ago

0.0.67

2 years ago

0.0.68

2 years ago

0.0.69

2 years ago

0.0.61

2 years ago

0.0.59

2 years ago

0.0.51

2 years ago

0.0.52

2 years ago

0.0.53

2 years ago

0.0.103

2 years ago

0.0.54

2 years ago

0.0.55

2 years ago

0.0.57

2 years ago

0.0.58

2 years ago

0.0.102

2 years ago

0.0.101

2 years ago

0.0.100

2 years ago

0.0.50

2 years ago

0.0.48

2 years ago

0.0.49

2 years ago

0.0.47

2 years ago

0.0.95

2 years ago

0.0.96

2 years ago

0.0.97

2 years ago

0.0.98

2 years ago

0.0.99

2 years ago

0.0.90

2 years ago

0.0.91

2 years ago

0.0.92

2 years ago

0.0.93

2 years ago

0.0.94

2 years ago

0.0.46

2 years ago

0.0.45

2 years ago

0.0.44

2 years ago

0.0.43

2 years ago

0.0.42

2 years ago

0.0.41

2 years ago

0.0.40

2 years ago

0.0.39

2 years ago

0.0.38

2 years ago

0.0.37

2 years ago

0.0.36

2 years ago

0.0.35

2 years ago

0.0.34

2 years ago

0.0.33

2 years ago

0.0.31

2 years ago

0.0.30

2 years ago

0.0.29

2 years ago

0.0.28

2 years ago

0.0.27

2 years ago

0.0.26

2 years ago

0.0.25

2 years ago

0.0.24

2 years ago

0.0.23

2 years ago

0.0.22

2 years ago

0.0.21

2 years ago

0.0.20

2 years ago

0.0.19

2 years ago

0.0.18

2 years ago

0.0.17

2 years ago

0.0.16

2 years ago

0.0.15

2 years ago

0.0.14

2 years ago

0.0.13

2 years ago

0.0.11

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago