2.0.0 • Published 6 years ago

stencil-props v2.0.0

Weekly downloads
2
License
(MIT OR Apache-2....
Repository
github
Last release
6 years ago

NPM

Stencil Props

A component that passes data attributes as props to Stencil components.

Example passing component inside stencil props useful for keeping classes etc.

<stencil-props data-str='"abc"' data-num='1' data-obj='{"foo":"bar"}' data-arr='[1,2,3]' data-bool='true'>
    <my-app class="foo"></my-app>
</stencil-props>

Example passing component as a string

<stencil-props component="my-app" data-str='"abc"' data-num='1' data-obj='{"foo":"bar"}' data-arr='[1,2,3]' data-bool='true'>    
</stencil-props>

passes on data to the my-app component

import { Component, Prop } from '@stencil/core';
import 'stencil-props';

export interface Obj {
  foo?: string;
}
@Component({
  tag: 'my-app'
})
export class MyApp {
  @Prop() str: string;
  @Prop() num: number;
  @Prop() obj: Obj = {};
  @Prop() arr: number[] = [];
  @Prop() bool: boolean;

  render() {
    return (
      <stencil-props>
        <div>str - {this.str}</div>
        <div>num - {this.num}</div>
        <div>obj - {this.obj.foo}</div>
        <div>arr - {this.arr[2]}</div>
        <div>boo - {this.bool ? 'true' : 'false'}</div>
      </stencil-props>
    );
  }
}

which outputs

<div>
  <div>str - abc</div>
  <div>num - 1</div>
  <div>obj - bar</div>
  <div>arr - 3</div>
  <div>boo - true</div>
</div>

Options

show-errors (default: false)

<stencil-props data-str='{x}' show-errors>

'show-errors' will log errors to the console

2.0.0

6 years ago

1.6.3

6 years ago

1.6.1

6 years ago

1.6.0

6 years ago

1.4.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.0.1

6 years ago