Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/bioudi/nuxt-offline-alert

🔌 Simple vue component for connection lost using nuxt helper.
https://github.com/bioudi/nuxt-offline-alert

nuxt nuxtjs offline online vue vuejs vuejs2

Last synced: 19 days ago
JSON representation

🔌 Simple vue component for connection lost using nuxt helper.

Awesome Lists containing this project

README

        

# nuxt-offline-alert

[![npm](https://img.shields.io/npm/v/nuxt-offline-alert.svg?style=for-the-badge)](https://www.npmjs.com/package/nuxt-offline-alert)
[![npm](https://img.shields.io/npm/dt/nuxt-offline-alert.svg?style=for-the-badge)](https://www.npmjs.com/package/nuxt-offline-alert)

## Preview

![](preview.gif)

## Install

`npm install nuxt-offline-alert`

## Usage

The most common use case is to register the component globally in nuxt is creating a plugin for it.

```js
// in your nuxt-offline-alert.js or similar file
import OfflineAlert from "nuxt-offline-alert";
import Vue from "vue";

Vue.use(OfflineAlert);
```

on nuxt.config.js

```js
{
...
plugins: [
{ src: 'plugins/nuxt-offline-alert.js', ssr: false }
]
...
}
```

Alternatively you can do this to register the components:

```js
// HelloWorld.vue
import OfflineAlert from "nuxt-offline-alert";

export default {
name: 'HelloWorld',
components: {
OfflineAlert
}
}
```

On your page you can now use html like this:

```html
// see props if you want to change online and offline messages

```

## CSS

You don't like the default styling of the component ...? Feel free to customize your component for example:

```css
.offline-alert{
background: grey // changing the background
}
.offline-alert-indicator--offline {
background-color: orange; // changing offline indicator color
}
.offline-alert-indicator--online {
background-color: blue; // changing online indicator color
}
```

## Props

|Prop|Type|Required|Default|Description
|-|-|-|-|-|
|onlineMessage|String|false|Back online!|Message to show when online
|offlineMessage|String|false|You're offline!|Message to show when offline