A pure Vue component submit button with a Ladda-style spinner

Related tags

Loader vue-submit
Overview

vue-submit npm package

A pure Vue component submit button with a Ladda-style spinner.

Based on NxtChg/pieces vue-submit but with a different approach, using vue-cli 3 and published as a component, plugin and vue cli 3 plugin.

Installation

Using npm:

$ npm install vue-submit

Usage

Using Vue (with Webpack) in your src/main.js or other webpack entry file:

// Load the Vue plugin globally to compile via Babel in Webpack (using vue-cli-3).
import Vue from 'vue'
import { Plugin } from 'vue-submit'

// To use the default options: { defaultButtonType = 'submit', tagName = 'vue-submit' }
Vue.use(Plugin)

// Or choose a different tag name for the component
Vue.use(Plugin, { tagName: 'an-alternative-vue-submit-tag-name' })

// Or choose the default button type for the button created. By default this is 'submit',
//  but you may want 'button' to use the spin functionality without submitting a form
Vue.use(Plugin, { defaultButtonType: 'button' })

And in your SFC (with the plugin activated):

">
<template>
    <vue-submit :disabled='disabled'>A disabled buttonvue-submit>
    <vue-submit type='button' :disabled='disabled'>A disabled button that behaves like a normal button instead of a submit buttonvue-submit>

    <form method='GET' @submit.prevent='onSubmitDummy'>
        <vue-submit :started='siblingStarted' @started='siblingStarted=true'> {{ siblingStopPrimaryText }}vue-submit>
        <button type='button' :disabled='!siblingStarted' @click='onSiblingStop'> {{ siblingStopSecondaryText }}button>
    <form>
template>

<script>
export default {
    data() {
        return {
            disabled: true,
            siblingStarted: false,
            siblingStopPrimaryText: 'Click to confide in me',
            siblingStopSecondaryText: 'Waiting for my sibling to start spinning'
        }
    }.
    watch: {
        siblingStarted(started) {
        if (started) {
            this.siblingStopPrimaryText = "I'm spinning around, get out of my way!"
            this.siblingStopSecondaryText = 'Click me to stop my sibling'
        } else {
            this.siblingStopPrimaryText = 'Click to confide in me'
            this.siblingStopSecondaryText = 'Waiting for my sibling to start spinning'
        }
        }
    },
    methods: {
        onSubmitDummy() {
            // a dummy function to prevent actual form submission
        },
        onSiblingStop() {
            this.siblingStarted = false
        }
    }
}
script>

Or to use in your SFC as above, but with the component and not the plugin:

<template>
 ...
template>

<script>
import VueSubmit from 'vue-submit'

export default {
    ...,
    components: {
        'vue-submit': VueSubmit
    }
}
script>

To use the ES6 module outside of vue-cli-3, but within webpack (with Babel), try the webpack-babel-env-deps Babel plugin to ensure the imports are imported as-is.

If (for some reason) you don't want to use the raw ES Vue component, there is also:

// The UMD version ">
// The common-js version
<script src="https://unpkg.com/vue-submit/dist/vue-submit.common.js"></script>

// The UMD version
<script src="https://unpkg.com/vue-submit/dist/vue-submit.umd.min.js"></script>
You might also like...
💅 Vue style loader module for webpack

This is a fork based on style-loader. Similar to style-loader, you can chain it after css-loader to dynamically inject CSS into the document as style tags. However, since this is included as a dependency and used by default in vue-loader, in most cases you don't need to configure this loader yourself.

💅Vue style loader module for webpack

vue-style-loader This is a fork based on style-loader. Similar to style-loader, you can chain it after css-loader to dynamically inject CSS into the d

Vue cli plugin to support style-resources-loader

Introduction Add style-resources-loader to your project easier. Installation vue add style-resources-loader Config Define your resource's patterns un

A Vue.js component to create beautiful animated circular progress bars. https://vue-ellipse-progress-demo.netlify.com/
A Vue.js component to create beautiful animated circular progress bars. https://vue-ellipse-progress-demo.netlify.com/

vue-ellipse-progress A dependency-free Vue.js plugin to create beautiful and animated circular progress bars, implemented with SVG. The purpose of thi

Radial progress bar component for Vue.js

vue-radial-progress A radial progress bar component for Vue.js. Uses SVG and javascript to animate a radial progress bar with a gradient. Live Demo Re

Vue.js component for full screen loading indicator :cyclone:

Vue Loading Overlay Component Vue.js component for full screen loading indicator Demo or JSFiddle Installation # yarn yarn add vue-loading-overlay #

a vue component about toy bricks of skeleton screen loading

tb-skeleton a vue component about toy bricks of skeleton screen loading install $ npm i tb-skeleton -s use npm import Vue from 'vue' import skelet

Youtube Like Loading Bar Component for Vue.js

vue-loading-bar Loading Bar Component for Vue.Js DEMO Need Vue 2 Version? Click Here... Intro Vue Loading Bar is a Youtube like loading bar component

Vue component to easily build (or use presets) SVG loading cards Facebook like.
Vue component to easily build (or use presets) SVG loading cards Facebook like.

Vue component to easily build (or use presets) SVG loading cards Facebook like.

Owner
null
A GSAP powered, spinner component for Vue.js. Pretty and silky smooth.

A GSAP powered, spinner component for Vue.js. Pretty and silky smooth.

Christopher Gomez 0 Jul 16, 2019
A spinner component library for Vue.js

A spinner component library for Vue.js

Amit Khonde 0 Aug 27, 2019
A simple, flexible spinner for Vue.js

vue-simple-spinner A simple, flexible spinner for Vue.js vue-simple-spinner is designed to be a lightweight Vue.js spinner requiring minimal configura

Dave Williams 418 Nov 13, 2022
Full overlay loading with spinner for Vue

Full overlay loading with spinner for Vue

Pygmy Slow Loris 162 Nov 6, 2022
🚗 A 3D product spinner for Vue.js with no dependencies

The product spinner that Vue.js was missing. Sponsors Become a sponsor Live Demo Try it on CodeSandbox! Installation npm npm i vue-product-spinner yar

Michele Riva 91 Nov 10, 2022
💫 A collection of loading spinner components for Vuejs

Vue Spinners A Vue.js port of react-spinners. ?? Installation npm install --save @saeris/vue-spinners # or yarn add @saeris/vue-spinners ?? Usage Ther

Drake Costa 310 Oct 25, 2022
Vue Spinners CSS Loaders - Amazing collection of Vue spinners components with pure css.

Vue Spinners CSS Loaders - Amazing collection of Vue spinners components with pure css.

Josh Kuttler 51 Nov 24, 2022
Lightweight Vue wrapper for Loaders.css, delightful and performance-focused pure css loading animations

Vue Loaders CSS Vue wrapper for Loaders.css, the delightful and performance-focused pure css loading animations Demo The live demo is available here:

DigiQode 7 Nov 27, 2022
Delightful, performance-focused pure css loading animations.

Loaders.css Delightful and performance-focused pure css loading animations. What is this? See the demo A collection of loading animations written enti

Connor Atherton 10.2k Nov 25, 2022
👇 Vue button with slideout loading indicator

vue-loading-button Straightforward Vue button with slideout loading indicator Props Prop Type Required Default Description loading boolean false false

William Lindvall 38 Nov 24, 2022