logo polydile dile-components

dile-inline-feedback

Web component to show feedback messages to the user.

Installation

npm i @dile/ui

Usage

Import the component.

import '@dile/ui/components/inline-feedback/dile-inline-feedback.js';

Use the component.

<dile-inline-feedback></dile-inline-feedback>

Methods

dile-inline-feedback demo

<script type="module">
import { LitElement, html, css } from 'lit';

class MyComponent extends LitElement {

  render() {
    return html`
     
      <p>
        <button id="positive" @click=${this.positive}>Positive feedback</button>
        <button id="negative" @click=${this.negative}>Negative feedback</button>
        <button id="clear" @click=${this.clear}>Clear feedback</button>
      </p>
      <dile-inline-feedback></dile-inline-feedback>
    `
  }
  firstUpdated() {
    this.feedback = this.shadowRoot.querySelector('dile-inline-feedback');
  }

  positive() {
    this.feedback.positiveFeedback('This is a positive feedback');
  }

  negative() {
    this.feedback.negativeFeedback('Oh no!!! this is a negative feedback');
  }

  clear() {
    this.feedback.clear();
  }
    
}
customElements.define('my-component', MyComponent);
</script>
<my-component></my-component>