https://github.com/vinayakkulkarni/s-offline
๐ Simple Svelte component to detect offline & online changes.
https://github.com/vinayakkulkarni/s-offline
detect network svelte svelte-component svelte-components svelte-js svelte-template svelte3 sveltejs
Last synced: 3 months ago
JSON representation
๐ Simple Svelte component to detect offline & online changes.
- Host: GitHub
- URL: https://github.com/vinayakkulkarni/s-offline
- Owner: vinayakkulkarni
- License: mit
- Created: 2020-05-25T22:21:56.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2024-10-30T00:19:39.000Z (8 months ago)
- Last Synced: 2024-10-30T00:32:47.557Z (8 months ago)
- Topics: detect, network, svelte, svelte-component, svelte-components, svelte-js, svelte-template, svelte3, sveltejs
- Language: JavaScript
- Homepage: https://s-offline.netlify.app/
- Size: 5.39 MB
- Stars: 70
- Watchers: 4
- Forks: 4
- Open Issues: 18
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# s-offline โก๏ธ
[](https://github.com/vinayakkulkarni/s-offline/actions/workflows/ci.yml)
[](https://github.com/vinayakkulkarni/s-offline/actions/workflows/shipjs-trigger.yml)
[](https://github.com/vinayakkulkarni/s-offline/releases)
[](https://www.npmjs.com/package/s-offline)
[](http://npm-stat.com/charts.html?package=s-offline)
[](https://bundlephobia.com/package/s-offline@latest)
[](https://github.com/vinayakkulkarni/s-offline/blob/master/package.json)
[](https://deepscan.io/dashboard#view=project&tid=9055&pid=16121&bid=339368)
[](https://snyk.io/test/github/vinayakkulkarni/s-offline)
[](https://lgtm.com/projects/g/vinayakkulkarni/s-offline/alerts/)
[](https://lgtm.com/projects/g/vinayakkulkarni/s-offline/context:javascript)
[](https://github.com/vinayakkulkarni/s-offline/graphs/contributors)
[](https://app.fossa.io/projects/git%2Bgithub.com%2Fvinayakkulkarni%2Fs-offline?ref=badge_shield)[](https://eslint.org/)
[](https://prettier.io/)
[](https://vitejs.dev/)
[](https://svelte.dev/)
[](https://www.typescriptlang.org/)## Features
- Detect offline & online events for your Svelte app, inspired from [v-offline](https://github.com/vinayakkulkarni/v-offline)
- Built from scratch using TypeScript## Table of Contents
- [s-offline โก๏ธ](#s-offline-๏ธ)
- [Features](#features)
- [Table of Contents](#table-of-contents)
- [Demo](#demo)
- [Requirements](#requirements)
- [Installation](#installation)
- [Build Setup](#build-setup)
- [Usage](#usage)
- [Example](#example)
- [API](#api)
- [Props](#props)
- [Events](#events)
- [Built with](#built-with)
- [Contributing](#contributing)
- [Author](#author)
- [License](#license)## Demo
[](https://stackblitz.com/edit/s-offline?file=src/App.svelte)
## Requirements
- [Svelte 3](https://svelte.dev/)
### Installation
```sh
npm install --save s-offline
```CDN: [UNPKG](https://unpkg.com/s-offline/dist/) | [jsDelivr](https://cdn.jsdelivr.net/npm/s-offline/dist/) (available as `window.SOffline`)
### Build Setup
```bash
# install dependencies
$ npm ci# package the library
$ npm run build
```## Usage
```javascript
import { SOffline } from 's-offline';
```#### Example
Detailed Example (refer App.svelte)
```html
import SOffline from 's-offline';
const handleNetworkChange = (status) => {
console.log('event details: ', status);
};๐
๐ค.online {
font-size: 10rem;
text-align: center;
}
.offline {
font-size: 10rem;
text-align: center;
}```
## API
### Props
| Name | Type | Required? | Default | Description |
| --------- | ------ | --------- | ------------------ | -------------------------------------------------------- |
| `pingUrl` | String | No | https://google.com | Pinging any url to double check if you're online or not. |### Events
| Name | Returns | Description |
| ------------------- | ------- | --------------------- |
| `detectedCondition` | String | Emits a boolean value |## Built with
- [TypeScript](https://www.typescriptlang.org/)
- [Svelte 3](https://svelte.dev/)## Contributing
1. Fork it ( [https://github.com/vinayakkulkarni/s-offline/fork](https://github.com/vinayakkulkarni/s-offline/fork) )
2. Create your feature branch (`git checkout -b feat/new-feature`)
3. Commit your changes (`git commit -Sam 'feat: add feature'`)
4. Push to the branch (`git push origin feat/new-feature`)
5. Create a new [Pull Request](https://github.com/vinayakkulkarni/s-offline/compare)_Note_:
1. Please contribute using [GitHub Flow](https://web.archive.org/web/20191104103724/https://guides.github.com/introduction/flow/)
2. Commits & PRs will be allowed only if the commit messages & PR titles follow the [conventional commit standard](https://www.conventionalcommits.org/), _read more about it [here](https://github.com/conventional-changelog/commitlint/tree/master/%40commitlint/config-conventional#type-enum)_
3. PS. Ensure your commits are signed. _[Read why](https://withblue.ink/2020/05/17/how-and-why-to-sign-git-commits.html)_## Author
**s-offline** ยฉ [Vinayak](https://vinayakkulkarni.dev), Released under the [MIT](./LICENSE) License.
Authored and maintained by Vinayak Kulkarni with help from contributors ([list](https://github.com/vinayakkulkarni/s-offline/contributors)).> [vinayakkulkarni.dev](https://vinayakkulkarni.dev) ยท GitHub [@vinayakkulkarni](https://github.com/vinayakkulkarni) ยท Twitter [@\_vinayak_k](https://twitter.com/_vinayak_k)
## License
[](https://app.fossa.com/projects/git%2Bgithub.com%2Fvinayakkulkarni%2Fs-offline?ref=badge_large)