npm install --save s-offline
CDN: UNPKG | jsDelivr (available as window.SOffline
)
# install dependencies
$ npm ci
# package the library
$ npm run build
import { SOffline } from 's-offline';
<script>
import SOffline from 's-offline';
const handleNetworkChange = (status) => {
console.log('event details: ', status);
};
</script>
<SOffline
pingUrl="https://bitly.com"
on:detectedCondition="{handleNetworkChange}"
>
<span slot="online" class="online"> 😊 </span>
<span slot="offline" class="offline"> 🤕 </span>
</SOffline>
<style>
.online {
font-size: 10rem;
text-align: center;
}
.offline {
font-size: 10rem;
text-align: center;
}
</style>
Name | Type | Required? | Default | Description |
---|---|---|---|---|
pingUrl |
String | No | https://google.com | Pinging any url to double check if you're online or not. |
Name | Returns | Description |
---|---|---|
detectedCondition |
String | Emits a boolean value |
git checkout -b feat/new-feature
)git commit -Sam 'feat: add feature'
)git push origin feat/new-feature
)Note:
s-offline © Vinayak, Released under the MIT License.
Authored and maintained by Vinayak Kulkarni with help from contributors (list).
vinayakkulkarni.dev · GitHub @vinayakkulkarni · Twitter @_vinayak_k