0.0.2 • Published 3 years ago

bawes-stencil v0.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Built With Stencil

Stencil Component Starter

This is a starter project for building a standalone Web Component using Stencil.

Stencil is also great for building entire apps. For that, use the stencil-app-starter instead.

Stencil

Stencil is a compiler for building fast web apps using Web Components.

Stencil combines the best concepts of the most popular frontend frameworks into a compile-time rather than run-time tool. Stencil takes TypeScript, JSX, a tiny virtual DOM layer, efficient one-way data binding, an asynchronous rendering pipeline (similar to React Fiber), and lazy-loading out of the box, and generates 100% standards-based Web Components that run in any browser supporting the Custom Elements v1 spec.

Stencil components are just Web Components, so they work in any major framework or with no framework at all.

Getting Started

To start building a new web component using Stencil, clone this repo to a new directory:

git clone https://github.com/ionic-team/stencil-component-starter.git my-component
cd my-component
git remote rm origin

and run:

npm install
npm start

To build the component for production, run:

npm run build

To run the unit tests for the components, run:

npm test

Need help? Check out our docs here.

Naming Components

When creating new component tags, we recommend not using stencil in the component name (ex: <stencil-datepicker>). This is because the generated component has little to nothing to do with Stencil; it's just a web component!

Instead, use a prefix that fits your company or any name for a group of related components. For example, all of the Ionic generated web components use the prefix ion.

Using this component

There are three strategies we recommend for using web components built with Stencil.

The first step for all three of these strategies is to publish to NPM.

Script tag

  • Put a script tag similar to this <script type='module' src='https://unpkg.com/bawes-stencil@0.0.1/dist/bawes-stencil/bawes-stencil.esm.js'></script> in the head of your index.html
  • Then you can use the element anywhere in your template, JSX, html etc ` <plugn-stores storeSelected="storeSelected(this, event)" endpoint="http://localhost/plugn/api/web/v2"

    `

Node Modules

  • Run npm install my-component --save
  • Put a script tag similar to this <script type='module' src='node_modules/my-component/dist/my-component.esm.js'></script> in the head of your index.html
  • Then you can use the element anywhere in your template, JSX, html etc

In a stencil-starter app

  • Run npm install my-component --save
  • Add an import to the npm packages import my-component;
  • Then you can use the element anywhere in your template, JSX, html etc

stencil

Build: Build components for development or production.

$ stencil build [--dev] [--watch] [--prerender] [--debug]

  --dev ............. Development build
  --watch ........... Rebuild when files update
  --serve ........... Start the dev-server
  --prerender ....... Prerender the application
  --docs ............ Generate component readme.md docs
  --config .......... Set stencil config file
  --stats ........... Write stencil-stats.json file
  --log ............. Write stencil-build.log file
  --debug ........... Set the log level to debug

Test: Run unit and end-to-end tests.

$ stencil test [--spec] [--e2e]

  --spec ............ Run unit tests with Jest
  --e2e ............. Run e2e tests with Puppeteer

Generate: Bootstrap components.

$ stencil generate or stencil g

Telemetry: Opt in or our of telemetry. Information about the data we collect is available on our website: https://stenciljs.com/telemetry

Status: Enabled. Thank you for helping to make Stencil better! 💖

$ stencil telemetry [off|on]

    off ............. Disable sharing anonymous usage data
    on .............. Enable sharing anonymous usage data

Examples:

$ stencil build --dev --watch --serve $ stencil build --prerender $ stencil test --spec --e2e $ stencil telemetry on $ stencil generate $ stencil g my-component

Plugn store components

`<plugn-stores storeSelected="storeSelected(this, event)" endpoint="https://api.plugn.io/v2"

var elem = document.querySelector('plugn-stores');

elem.addEventListener('storeSelected', (e) => {

//var url = e.detail.restaurant_domain;

window.open(e.detail.restaurant_domain, "_blank");

}, false);

Jira components

List jira users

`<jira-team userSelected="userSelected(this, event)" endpoint="https://staff.api.studenthub.co/v1"

></jira-team>

var elem = document.querySelector('jira-team');

elem.addEventListener('userSelected', (e) => {

var url;

switch (e.detail.action) {
  case "jira-profile":
    url = "https://bawes-studenthub.atlassian.net/jira/people/" + e.detail.accountId;

    break;
    
  case "studenthub-profile":
    url = "https://staff.studenthub.co/team-view/" + e.detail.staff_id;

    break;

  default:
    url = "https://bawes-studenthub.atlassian.net/issues/?jql=assignee%20in%20(" + e.detail.accountId +")%20and%20status%20in%20(%22In%20Progress%22)%20%20ORDER%20BY%20updated%20DESC";

    break;
}

window.open(url, "_blank");

}, false); `

List Issues by account_id and status

<jira-issues account_id="" status="" endpoint="https://staff.api.studenthub.co/v1"></jira-issues>

Wallet

Get token from

http://localhost/wallet/api/web/v1/auth/login

List user transactions

<wallet-balance transactionSelected="transactionSelected(this, event)" token="2DLLw-UfI8YLouyLPWlMW-KsmKU6Sq1D" endpoint="http://localhost/wallet/api/web/v1"></wallet-balance>

Transfer wallet balance

<wallet-send-money transactionComplete="transactionComplete(this, event)" transactionError="transactionError(this, event)" token="2DLLw-UfI8YLouyLPWlMW-KsmKU6Sq1D" endpoint="http://localhost/wallet/api/web/v1"></wallet-send-money>

0.0.2

3 years ago

0.0.1

3 years ago