3.0.1 • Published 5 years ago

@elifent/app-cookies v3.0.1

Weekly downloads
2
License
ISC
Repository
github
Last release
5 years ago

\<app-cookies>

Element to manage cookies across your app. app-cookies read values from cookie data automatically and serves it to client. Settting and resetting of values are not automatic and need to be triggered by code.

Installation

npm install --save @elifent/app-cookies

In an html file

<html>
  <head>
    <script type="module">
      import "@elifent/app-cookies/app-cookies.js";
    </script>
  </head>
  <body>
    <app-cookies key="location" data="US"></app-cookies>
  </body>
</html>

In a Polymer 3 element

import { PolymerElement, html } from "@polymer/polymer";
import "@elifent/app-cookies/app-cookies.js";
class SampleElement extends PolymerElement {
  static get template() {
    return html`
      <app-cookies id="location" key="location" data="{{location}}"></app-cookies>
      <span>{{location}}</span>
      <input type="text" value="{{newvalue}}">
      <input type="button" value"Set Location" on-click="set">
      <input type="button" value="Unset Location" on-click="unset">
    `;
  }
  static get properties() {
    return {
      location: {
        type: String,
        value: "US"
      },
      newvalue:{
        type: String,
        value: null
      }
    };
  }
  setLocation(){
      this.$.location.set(this.newvalue);
  }
  unsetLocation(){
      this.$.location.unset();
  }
}
customElements.define("sample-element", SampleElement);

Installation

  git clone https://github.com/elifent/app-cookies
  cd paper-avatar
  npm install
  npm install -g polymer-cli

Running the demo locally

  polymer serve --npm
  open http://127.0.0.1:<port>/components/app-cookies/demo/

Found issues? Let me know