1.2.0 • Published 5 years ago

@singleware/ui-alert v1.2.0

Weekly downloads
10
License
MIT
Repository
github
Last release
5 years ago

UI-Alert

Custom HTML element used to wrap a simple alert, composed by the slots: icon, message and hide. See demo

Usage

Instantiate the component that initializes the custom element.

import * as JSX from '@singleware/jsx';
import * as Alert from '@singleware/ui-alert';

const component = (
  <Alert.Component concealable open>
    <span slot="icon">👋</span>
    <span slot="message">This is an alert example initialized by the component wrapper.</span>
    <span slot="hide" />
  </Alert.Component>
) as Alert.Element;

Show and Hide programmatically.

component.show();
component.hide();

Be informed about the hide action.

component.addEventListener('hide', (event: Event) => console.log(`Yes! It's hidden now.`));

Help

Attributes

NameDescription
concealableAssigned when the alert can be hidden by the user (requires an element in the hide slot)
openAutomatically assigned when the alert is shown and removed when hidden

Properties

NameTypeDescription
iconanyGet and set the alert icon (requires an element in the icon slot)
messageanyGet and set the alert message
concealableboolGet and set the alert conceal state
openboolGet and set the open state

Methods

NameDescription
showShows the alert setting the open state as true
hideHides the alert setting the open state as false

Slots

NameDescription
iconElement to shows the alert icon (can be omitted)
messageElement to shows the alert message
hideElement to shows the alert hide button (can be omitted)

Events

NameDescription
hideDispatched when the alert becomes hidden

Styles

NameDescription
--swe-alert-text-colorDetermines the alert text color
--swe-alert-background-colorDetermines the alert background color
--swe-alert-border-radiusDetermines the alert border radius
--swe-alert-border-sizeDetermines the alert border size
--swe-alert-border-colorDetermines the alert border color
--swe-alert-icon-margin-topDetermines the top margin of the alert icon
--swe-alert-icon-margin-rightDetermines the right margin of the alert icon
--swe-alert-icon-margin-bottomDetermines the bottom margin of the alert icon
--swe-alert-icon-margin-leftDetermines the left margin of the alert icon
--swe-alert-icon-marginDetermines all margins of the alert icon
--swe-alert-message-margin-topDetermines the top margin of the alert message
--swe-alert-message-margin-rightDetermines the right margin of the alert message
--swe-alert-message-margin-bottomDetermines the bottom margin of the alert message
--swe-alert-message-margin-leftDetermines the left margin of the alert message
--swe-alert-message-marginDetermines all margins of the alert message
--swe-alert-hide-margin-topDetermines the top margin of the alert hide button
--swe-alert-hide-margin-rightDetermines the right margin of the alert hide button
--swe-alert-hide-margin-bottomDetermines the bottom margin of the alert hide button
--swe-alert-hide-margin-leftDetermines the left margin of the alert hide button
--swe-alert-hide-marginDetermines all margins of the alert hide button
--swe-alert-hide-cross-colorDetermines the cross color of the alert hide button
--swe-alert-hide-cross-sizeDetermines the cross size of the alert hide button

These variables above are useful to customize the closed shadow DOM.

Install

Using npm:

npm i @singleware/ui-alert

License

MIT © Silas B. Domingos

1.2.0

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.8

5 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago