2.2.2 • Published 7 months ago

@profluens/solid-needle v2.2.2

Weekly downloads
-
License
AGPL
Repository
-
Last release
7 months ago

solid-needle / Profluens version

User of prettier before commit !

npx prettier --write .

Component creation without related data

import * as core from "https://cdn.skypack.dev/@startinblox/core@0.17";

core.Sib.register({
  name: "solid-component",
  attributes: {
    dataAttribute: {
      // Attribute passed as `data-attribute=""`
      type: String,
      default: null,
    },
  },
  initialState: {
    // Initiale state of component
    state: null,
  },
  created() {
    // DOM component added
  },
  attached() {
    // Attributes attached
    core.render(
      // Use lit html template https://lit.dev/docs/v1/lit-html/introduction/
      core.html`
        <!-- HTML code here -->
        <div 
          @click=${this.onClick.bind(this)}
          ></div>
    `,
      this.element
    );
  },

  onClick(e) {
    // Click callback
    // console.log("attribute passed", this.dataAttribute);
    // console.log("component state", this.state);
  },
});

Component creation with resource

import * as core from "https://cdn.skypack.dev/@startinblox/core@0.17";

core.Sib.register({
  name: "solid-component",
  use: [core.StoreMixin],
  attributes: {
    dataAttribute: {
      // Attribute passed as `data-attribute=""`
      type: String,
      default: null,
    },
  },
  initialState: {
    // Initiale state of component
    state: null,
  },

  // Triggered when resource fetched from cache or backend
  // Source defined via data-src attribute
  // Resource stored in this.resource
  async populate() {
    if (!this.resource) {
      // Dont forget this as input data source can be invalid
      return;
    }

    core.render(
      core.html`
        <!-- HTML code here -->
    `,
      this.element
    );
  },
});
2.2.2

7 months ago

2.2.1

7 months ago

2.2.0

7 months ago

2.1.0

8 months ago

2.0.0

8 months ago