logo polydile dile-components

dile-network

Web Component to check the network status (online / offline).

Installation

npm i @dile/utils

Usage

Import the component.

import '@dile/utils/components/network/network.js';

Use the component

<dile-network></dile-network>

This component cheks the network status and can display a message in a overlay layer when the network is offline. The message can be configured by a "offLineLabel" property.

Properties

Useful methods

Custom events

The event detail is an object containing a onLine bolean property. True means online and false mean offline.

Style customization

To customize the component style (the offline message box) it is possible to use some of the dile-persistent-toast custom properties. In addition there are some specific dile-network custom properties.

Custom property Description Default
--dile-network-toast-padding Overlay layer padding 0.65rem
--dile-network-toast-background-color Overlay layer background color #e33
--dile-network-label-text-color Message text color #fff
--dile-network-warning-icon-color Color of the warning icon dsplayed on the message #fff
--dile-network-close-icon-color Close icon color #fff

dile-network demos

Default network status component

Go offline to see this component in action.

<dile-network showOffLineStatus></dile-network>
<p style="margin-bottom: 0;"><i><b>Go offline to see this component in action.</b></i></p>

It is possible to simulate offline status usign the browser developer tools. To do that go to the network tab on the developer tools and select "offline" in the throttling combo box.