Skip to content

<np-logout>

A button component for logging out the authenticated user.

Properties

NameFormatrequireddefaultDescription
stateStatenoundefinedThe component’s internal state.
enum State {
LOGGINGOUT = "loggingout", // revoking session
LOGGEDOUT = "loggedout", // session is revoked
ERROR = "error", // something went wrong
}

Methods

NameDescription
logout()End the current session.

Custom Events

NameDescriptionType
np:logoutThe session is closed.void
np:errorSomething went wrong.NoPwdError

The np:error custom event detail inherites from the NoPwdError.

if (event.detail instanceof NetworkError) {
// no network
}
if (event.detail instanceof UnexpectedError) {
// Something went wrong
}

Slots

NameDescription
(default)The button’s label.
loggingoutclosing the session.
loggedoutSession is closed.
errorAn error occured.

Usage:

<!-- To override the default slot-->
<np-logout></np-logout>
<!-- to override specific slots-->
<np-logout>
Logout
<span slot="loggingout">please wait</span>
<span slot="loggedout">Bye!</span>
<span slot="error">Oooooops</span>
</np-logout>

Parts

NameDescription
buttonThe component’s button wrapper.

Usage:

/* to target only the default state */
np-logout:not([state])::part(button) {
background-color: black;
color: white;
}
np-logout[state="loggingout"]::part(button) {
background-color: transparent;
color: grey;
}
np-logout[state="loggedout"]::part(button) {
background-color: green;
color: white;
}
np-logout[state="error"]::part(button) {
background-color: red;
color: white;
}