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

vue-business-hours-wilcity-exnteded

v1.2.7

Published

Vue component for selecting business hours created by sbarry50. This package is extended version that helps to fit Wilcity theme

Downloads

3

Readme

Vue Business Hours

Vue component for setting business hours in an administration panel. Option to use a text <input> and <datalist> component with 'autocomplete' functionality for greater flexbility to define business hours. Or a <select> component to limit options to predetermined times in 15, 30 and 60 minute increments.

Demo

Install

NPM

Install with NPM

npm install vue-business-hours

Then in your main.js or other entry point register as a plugin.

import BusinessHours from 'vue-business-hours'

Vue.use(BusinessHours)

Or register as a component.

import BusinessHours from 'vue-business-hours'

Vue.component('BusinessHours', BusinessHours)

CDN

You can also add this component straight to an HTML page with a <script> tag along with Vue and Moment.js.

<script src='https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.js'></script>
<script src='https://cdn.jsdelivr.net/npm/[email protected]/moment.min.js'></script>
<script src='https://unpkg.com/vue-business-hours'></script>

Usage

This component can be used for regular business hours, holiday hours and/or other special hours with simple configuration changes.

<div id="app">
    <!-- default -->
    <h2>Business Hours</h2>
    <business-hours :days='days'></business-hours>

    <!-- with options -->
    <h2>Holiday Hours</h2>
    <business-hours
    :days='holidays'
    name='holidayHours'
    type='select'
    :time-increment='60'
    color='#00af0b'
    ></business-hours>
</div>

In your main.js, App.vue or in <script> tags on your HTML page.

new Vue({
    el: "#app",
    data() {
        return {
            days: yourDaysObject,
            holidays: yourHolidaysObject
        }
    }
});

Here's an example in an App.vue file fetching the days object with an Axios API call.

<template>
    <h1>Business Hours</h1>
    <section v-if="errored">
        <p>Oops, something went wrong. Please check the console for more details.</p>
    </section>
    <section v-else>
        <div v-if="loading">Loading...</div>
        <business-hours v-else :days="businessHours"></business-hours>
    </section>
</template>

<script>
import axios from 'axios';

export default {
  data() {
    return {
      businessHours: {},
      loading: true,
      errored: false
    };
  },
  created() {
    this.getData('https://example.com/api/business-hours-endpoint')
      .then(data => (this.businessHours = data));
  },
  methods: {
    getData: function(endpoint) {
      return axios
        .get(endpoint)
        .then(response => {
          return response.data;
        })
        .catch(error => {
          // eslint-disable-next-line
          console.log(error);
          this.errored = true;
        })
        .finally(() => (this.loading = false));
    }
  }
};
</script>

Properties

| Name | Type | Required | Default | Description | | -------------- | ------ | -------- | --------------- | -------------------------------------------------------------------------------------------------------- | | days | Object | yes | | An object with days and business hours to be set by the component. See below for format. | | name | String | no | businessHours | The name of the key which will correspond to the saved business hours. | | time-increment | Number | no | 30 | The number of minutes to increment the dropdown time options. Allowed values: 15, 30 or 60 minutes | | type | String | no | datalist | The type of input component used. Allowed values: datalist' or 'select' | | color | String | no | #2779bd | The color of the toggle switch and Add hours button. Must be in hex color format leading with a#` |

Data

The days property should be supplied with a JSON object in the following format. The open and close time values must be in the 24 hour format with no colon. Midnight can be designated by 2400. 24hrs is also valid. The id property must be unique for each entry. The isOpen property should only be false if both open and close are empty.

{
  sunday: [
    {
      open: '',
      close: '',
      id: '5ca5578b0c5c7',
      isOpen: false
    }
  ],
  monday: [
    {
      open: '0800',
      close: '1700',
      id: '5ca5578b0c5d1',
      isOpen: true
    }
  ],
  tuesday: [
    {
      open: '0800',
      close: '1700',
      id: '5ca5578b0c5d8',
      isOpen: true
    }
  ],
  wednesday: [
    {
      open: '0800',
      close: '1700',
      id: '5ca5578b0c5df',
      isOpen: true
    }
  ],
  thursday: [
    {
      open: '0800',
      close: '1700',
      id: '5ca5578b0c5e6',
      isOpen: true
    }
  ],
  friday: [
    {
      open: '0800',
      close: '1700',
      id: '5ca5578b0c5ec',
      isOpen: true
    },
    {
      open: '1900',
      close: '2200',
      id: '5ca5578b0c5f2',
      isOpen: true
    }
  ],
  saturday: [
    {
      open: '24hrs',
      close: '24hrs',
      id: '5ca5578b0c5f8',
      isOpen: true
    }
  ]
}