1.2.0 • Published 12 days ago

@momsfriendlydevco/vitel v1.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
12 days ago

@MomsFriendlyDevCo/Vitel

Various, pickable Vue@3 / Vite modules and components.

A collection of useful Components, Directives, Filters and Services

Documentation & Demo

Glossary & Terms used

This NPM module, commit history and various other documentation surrounding it uses shorthand notation to refer to different types of export:

  • Components are referred to as a DOM like element - e.g. <widget/>
  • Directives are always single strings with a v- prefix - e.g. v-href
  • Filters are prefixed with | indicating its a pipable function - e.g. |currency
  • Services are prefixed with $ indicating that its a globally available entity - e.g. $toast

Components

Naming convention: <my-component/> Each component is a standard Vue3 SFC file with a <script/>, <template> and optional <style/> block.

Components can be imported from the @momsfriendlydevco/vitel/component/* path.

Example:

// Vue App creation preamble
import {createApp} from 'vue'
import App from './App.vue';
let app = createApp(App);

import Date from '@momsfriendlydevco/vitel/component/date';
app.component('Date', Date);

Directives

Naming convention: v-my-directive Directives are elements which can be applied in multiple to the same Vue component or DOM element.

Components can be imported from the @momsfriendlydevco/vitel/directives/* path.

Example:

// Vue App creation preamble
import {createApp} from 'vue'
import App from './App.vue';
let app = createApp(App);

import vHref from '@momsfriendlydevco/vitel/directives/v-href';
app.directive('href', vHref);

Filters

Naming convention: |myFilter Filters are pure JavaScript functions called with a single data input + options object.

Filters can be imported from the @momsfriendlydevco/vitel/filters/* path.

Example:

// Vue App creation preamble
import {createApp} from 'vue'
import App from './App.vue';
let app = createApp(App);

// Install Vitel against our app to provide `app.filter`
import Vitel from '@momsfriendlydevco/vitel';
app.use(Vitel);

// Import a filter
import List from '@momsfriendlydevco/vitel/filters/list';
app.filter('List', List);

// Use within vanilla JavaScript:
console.log( List(['Foo', 'Bar', 'Baz']) );

// Or within a Vue Component:
this.$filters.list(['Foo', 'Bar', 'Baz']);
// or within a Vue Template:
{{$filters.list(['Foo', 'Bar', 'Baz'])}}
{{$filters.pipe(['Foo', 'Bar', 'Baz'], 'list')}}

Services

Naming convention: $myService Services are very similar to standard Vue Components except that:

  • Services need loading with app.service(NAME, SPEC, OPTIONS) or wrapping in the @momsfriendlydevco/vitel/service function
  • Services are "headless" - they do not have any template or render function
  • They are singleton instances - only one of each service exists within your app at any time (by default anyway)
  • They are setup against every component automatically as $serviceName
  • If a service requires an async created() lifecycle sequence, ready (a boolean) and promise() (a function which returns when the created process has completed) are also automatically provided
  • A debug(...msg) method is injected automatically into all services, when initalizing with debug: true this will be activated to output information to the console otherwise it will be a no-op function
  • The debug() method can also accept a function which will only run if debugging is enabled - this is useful to prevent any debug specific formatting that wouldn't run in production. Any output returned by the inner function would be output as if it were called with vm.debug() directly

Services can be imported from the @momsfriendlydevco/vitel/services/* path.

Example using the Vitel extender (recommended)

// Vue App creation preamble
import {createApp} from 'vue'
import App from './App.vue';
let app = createApp(App);

// Install Vitel against our app to provide `app.service`
import Vitel from '@momsfriendlydevco/vitel';
app.use(Vitel);

// Import the $toast service
import Toast from '@momsfriendlydevco/vitel/services/toast';
app.service('$toast', Toast, {
    // options, if any
});

Example using the Service Wrapper

// Vue App creation preamble
import {createApp} from 'vue'
import App from './App.vue';
let app = createApp(App);

// Import the $toast service + pass it our app so it can install itself
import Service from '@momsfriendlydevco/vitel/services/service';
import Toast from '@momsfriendlydevco/vitel/services/toast';
Service(Toast, {app}); // Toast now available in all components as `vm.$toast`
1.2.0

12 days ago

1.1.54

23 days ago

1.1.53

25 days ago

1.1.52

26 days ago

1.1.51

1 month ago

1.1.50

1 month ago

1.1.49

1 month ago

1.1.48

2 months ago

1.1.47

2 months ago

1.1.46

2 months ago

1.1.45

2 months ago

1.1.44

3 months ago

1.1.43

3 months ago

1.1.42

3 months ago

1.1.41

3 months ago

1.1.40

3 months ago

1.1.39

4 months ago

1.1.38

5 months ago

1.1.37

5 months ago

1.1.36

6 months ago

1.1.35

6 months ago

1.1.34

6 months ago

1.1.33

6 months ago

1.1.32

6 months ago

1.1.31

6 months ago

1.1.30

6 months ago

1.1.29

6 months ago

1.1.28

6 months ago

1.1.27

6 months ago

1.1.26

7 months ago

1.1.25

7 months ago

1.1.24

7 months ago

1.1.23

7 months ago

1.1.22

7 months ago

1.1.21

7 months ago

1.1.20

7 months ago

1.1.19

7 months ago

1.1.18

7 months ago

1.1.17

7 months ago

1.1.16

7 months ago

1.1.15

7 months ago

1.1.14

7 months ago

1.1.13

7 months ago

1.1.12

8 months ago

1.1.11

8 months ago

1.1.10

8 months ago

1.1.9

8 months ago

1.1.8

8 months ago

1.1.7

9 months ago

1.1.6

9 months ago

1.1.5

9 months ago

1.1.4

9 months ago

1.1.3

9 months ago

1.1.2

9 months ago

1.1.1

9 months ago

1.1.0

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago