1.0.8 • Published 11 months ago

wc-message v1.0.8

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

Message Web Component

A UI friendly message web component.

Usage

Step 1:

Reference component in the page:

<script src="https://unpkg.com/wc-message@latest/dist/index.js"></script>

Step 2:

Using custom element wc-message:

<wc-message id="message"></wc-message>

Step 3:

Get an element and change its properties:

<script>
  const el = document.querySelector('#message')

  el.textContent = 'Oops.'
  el.type = 'error'
  el.show = true
</script>

Component Properties

Controlling the state of a component using properties.

PropertiesTypeDefault valueOptional value
showbooleanfalsetrue / false
durationnumber3000number of milliseconds
typestringsuccessinfo / success / error / warning

Note ⚠️

Please use properties to change the state of the component instead of attributes, so that the state of the reactivity can be maintained.

<script>
  const el = document.querySelector('#message')
  
  // Good
  el.duration = 1000
  el.type = 'error'
  el.show = true

  // Bad
  el.setAttribute('duration', '1000')
  el.setAttribute('type', 'error')
  el.setAttribute('show', 'true')
</script>

License

MIT.

1.0.8

11 months ago

1.0.7

11 months ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

0.0.1

1 year ago