All Projects → AnalyzePlatypus → vue-unsaved-changes-dialog

AnalyzePlatypus / vue-unsaved-changes-dialog

Licence: other
Beautiful unsaved changes dialog, inspired by a component from the Squarespace admin

Programming Languages

Vue
7211 projects
javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to vue-unsaved-changes-dialog

Amazeui
Amaze UI, a mobile-first and modular front-end framework.
Stars: ✭ 13,548 (+104115.38%)
Mutual labels:  responsive, mobile-first
book-library
📚 A book library app for both Android & IOS ~ Flutter.dev project in Dart
Stars: ✭ 89 (+584.62%)
Mutual labels:  responsive
Numl
A UI Design Language, WC UI Library, and Runtime CSS Framework for rapidly building interfaces that follow your Design System 🌈
Stars: ✭ 229 (+1661.54%)
Mutual labels:  responsive
React Native Responsive Dimensions
Resposive fontSize, height and width for react-native components, that automatically adjusts itself based on screen-size of the device.
Stars: ✭ 243 (+1769.23%)
Mutual labels:  responsive
React Firebase Admin
React ⚛️ starter kit with Firebase 🔥 and Bulma for setting up an admin dashboard - Highly scalable, PWA, Serverless
Stars: ✭ 232 (+1684.62%)
Mutual labels:  responsive
Vue Product Zoomer
Zoom Prodct Image, useful for e-shop website
Stars: ✭ 248 (+1807.69%)
Mutual labels:  responsive
Portfolio Demo
A portfolio build by using flutter for web.
Stars: ✭ 224 (+1623.08%)
Mutual labels:  responsive
fhemApp
Web-App zur Steuerung deiner Smarthome Umgebung in Verbindung mit FHEM.
Stars: ✭ 25 (+92.31%)
Mutual labels:  responsive
mesh
A page builder, simplified. Get the most flexibility to display content by adding multiple content sections within Pages, Posts, or Custom Post Types.
Stars: ✭ 44 (+238.46%)
Mutual labels:  responsive
Responsive scaffold
Responsive Scaffold - On mobile it shows a list and pushes to details and on tablet it shows the List and the selected item. Maintainer: @rodydavis
Stars: ✭ 238 (+1730.77%)
Mutual labels:  responsive
React Image Crop
A responsive image cropping tool for React
Stars: ✭ 2,924 (+22392.31%)
Mutual labels:  responsive
Rfs
✩ Automates responsive resizing ✩
Stars: ✭ 2,789 (+21353.85%)
Mutual labels:  responsive
Framevuerk
Fast, Responsive, Multi Language, Both Direction Support and Configurable UI Framework based on Vue.js.
Stars: ✭ 252 (+1838.46%)
Mutual labels:  responsive
Minwiz
Minimal starter kit for under 2 KB sites
Stars: ✭ 228 (+1653.85%)
Mutual labels:  responsive
PotatoCSS
🥔 Simple CSS framework for hackers. Simple as potato.
Stars: ✭ 53 (+307.69%)
Mutual labels:  responsive
Hugo Theme M10c
A minimalistic (m10c) blog theme for Hugo
Stars: ✭ 223 (+1615.38%)
Mutual labels:  responsive
Reeddit
Minimal, elastic Reddit reader web-app client
Stars: ✭ 235 (+1707.69%)
Mutual labels:  responsive
React Native Scalable Image
React Native Image component which scales width or height automatically to keep the original aspect ratio
Stars: ✭ 241 (+1753.85%)
Mutual labels:  responsive
scalem
A jQuery plugin to make any element scalable (responsive).
Stars: ✭ 33 (+153.85%)
Mutual labels:  responsive
hugoblog
Hugoblog is responsive, simple, and clean that would fit for your personal blog based on Hugo Theme Static Site Generator (SSG)
Stars: ✭ 48 (+269.23%)
Mutual labels:  responsive

Vue Unsaved Changes Dialog

A beautiful unsaved changes dialog, inspired by a component from the Squarespace admin.

Live demo ›

  • Save, Discard, and Cancel buttons
  • On desktop, popup appears precisely underneath the mouse cursor
  • Smoothly animates in and out
  • Popup intelligently avoids the window edges and responds to window resizing
  • Full responsive: renders as in full-screen on mobile
  • Keyboard navigable/accessible
  • All text is replaceable

Demo GIF

More goodies

  • Includes buttery animations for both desktop and mobile
  • Mouse listener is throttled to avoid performance issues (bundles lodash.throttle, an extra 2KB)
  • All listeners are deactivated when component is torn down
  • Darkens background
  • Clicking the background dismisses the dialog (same as cancel button)
  • Bundles desktop, mobile, popup positioning logic, and all styles and animations in 14KB
  • No dependencies

Install

npm i vue-unsaved-changes-dialog

Usage

<button @click="attemptToGoBack">Back</button>

<UnsavedChangesDialog
  :title="Unsaved Changes"
  :subtitle="['You have unsaved changes', 'Would you like to save or discard them?']"
  :show="shouldShowDialog"
  @cancel="closePopup"
  @discard="discard"
  @save="save"/>

Detailed use case:

import UnsavedChangesDialog from 'vue-unsaved-changes-dialog';

export default {
  name: 'App',
  data() {
    return {
      shouldShowDialog: false,
    }
  },
  methods: {
    attemptToGoBack() {
      this.hasUnsavedChanges ? 
        this.showPopup() :
        this.exit();
    },
    exit() {
      this.closePopup();
      // and leave the view
    },
    showPopup() {
      this.shouldShowDialog = true;
    },
    closePopup() {
      this.shouldShowDialog = false;
    },
    discard() {
      this.discardEdits();
      this.exit();
    },
    discardEdits() {
      // your code here
    },
    async save() {
      try {
        await this.saveChangesToServer();
        this.exit();
      } catch(e) {
        console.error(e);
      }
    },
    async saveChangesToServer() {
      // your code here
    }
  },
  computed: {
    hasUnsavedChanges() {
      // check for unsaved changes
    }
  },
  components: {
    UnsavedChangesDialog
  }
}

Customizing

Text

The title and body text can be customized with props:

<UnsavedChangesDialog
  :title="Unsaved Changes"
  :subtitle="['You have unsaved changes', 'Would you like to save or discard them?']"
 />

subtitle accepts both Strings and String Arrays. If an array is supplied, a <p> element will be inserted for every one.

Button text & icons

The buttons can be customized using the slots API. You can inject your own text, icons, html, etc. into any part of the dialog.

<UnsavedChangesDialog
  :title="Unsaved Changes">
  <template name="title">Destory the things?</template>
  <template name="body">Description</template>
  <template name="cancel-button"></template>
  <template name="discard-button">💀</template>
  <template name="save-button"></template>
</UnsavedChangesDialog>

Styles & Animations

To use your own styles, use the unstyled build (no-css.esm.js). You can copy the default styles (no-css.esm.css) into your project and customize it.

Builds

There are 5 files in the dist directory:

Extension Use case Notes
.esm.js Standard ES6 module Default build, for use in a Vue CLI project. Already minified for production
no-css.esm.js Standard ES6 module without styling ES6 build with all styles extracted to a separate .esm.css file for customization/overriding
no-css.esm.css CSS styles for the unstyled ES6 build Copy this into your project to customize the UI
.min.js Browser build, requires no build system. This is the file you'd get from the UNPKG cdn
.ssr.js Rollup build for use with SSR. Honestly, I'm not sure what it is, but it was in the rollup template I used.

Gallery

Still

Desktop

Mobile

Responsive

Responsive demo

Live Development

You'll need NPM and the Vue CLI.

npm install 
npm run serve

Building

You'll need to install Rollup.js to run the build script. Install it with npm install --g rollup

npm run build

Running the build script generate main (.ssr.js), module (.esm.js), and unpkg (.min.js) versions in the dist directory.

Thank you

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].