Coder Social home page Coder Social logo

singleware / ui-alert Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 191 KB

UI alert package.

License: MIT License

JavaScript 93.05% TypeScript 6.27% CSS 0.52% HTML 0.16%
typescript javascript browser shadow-dom custom-element alert jsx singleware ui-alert

ui-alert's Introduction

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

Name Description
concealable Assigned when the alert can be hidden by the user (requires an element in the hide slot)
open Automatically assigned when the alert is shown and removed when hidden

Properties

Name Type Description
icon any Get and set the alert icon (requires an element in the icon slot)
message any Get and set the alert message
concealable bool Get and set the alert conceal state
open bool Get and set the open state

Methods

Name Description
show Shows the alert setting the open state as true
hide Hides the alert setting the open state as false

Slots

Name Description
icon Element to shows the alert icon (can be omitted)
message Element to shows the alert message
hide Element to shows the alert hide button (can be omitted)

Events

Name Description
hide Dispatched when the alert becomes hidden

Styles

Name Description
--swe-alert-text-color Determines the alert text color
--swe-alert-background-color Determines the alert background color
--swe-alert-border-radius Determines the alert border radius
--swe-alert-border-size Determines the alert border size
--swe-alert-border-color Determines the alert border color
--swe-alert-icon-margin-top Determines the top margin of the alert icon
--swe-alert-icon-margin-right Determines the right margin of the alert icon
--swe-alert-icon-margin-bottom Determines the bottom margin of the alert icon
--swe-alert-icon-margin-left Determines the left margin of the alert icon
--swe-alert-icon-margin Determines all margins of the alert icon
--swe-alert-message-margin-top Determines the top margin of the alert message
--swe-alert-message-margin-right Determines the right margin of the alert message
--swe-alert-message-margin-bottom Determines the bottom margin of the alert message
--swe-alert-message-margin-left Determines the left margin of the alert message
--swe-alert-message-margin Determines all margins of the alert message
--swe-alert-hide-margin-top Determines the top margin of the alert hide button
--swe-alert-hide-margin-right Determines the right margin of the alert hide button
--swe-alert-hide-margin-bottom Determines the bottom margin of the alert hide button
--swe-alert-hide-margin-left Determines the left margin of the alert hide button
--swe-alert-hide-margin Determines all margins of the alert hide button
--swe-alert-hide-cross-color Determines the cross color of the alert hide button
--swe-alert-hide-cross-size Determines 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

ui-alert's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.