Skip to content

Commit 34fa1a4

Browse files
committed
init
0 parents  commit 34fa1a4

19 files changed

+457
-0
lines changed

.editorconfig

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# http://editorconfig.org
2+
3+
root = true
4+
5+
[*]
6+
charset = utf-8
7+
indent_style = space
8+
indent_size = 2
9+
end_of_line = lf
10+
insert_final_newline = true
11+
trim_trailing_whitespace = true
12+
13+
[*.md]
14+
insert_final_newline = false
15+
trim_trailing_whitespace = false

.gitignore

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
dist/
2+
www/
3+
loader/
4+
5+
*~
6+
*.sw[mnpcod]
7+
*.log
8+
*.lock
9+
*.tmp
10+
*.tmp.*
11+
log.txt
12+
*.sublime-project
13+
*.sublime-workspace
14+
15+
.stencil/
16+
.idea/
17+
.vscode/
18+
.sass-cache/
19+
.versions/
20+
node_modules/
21+
$RECYCLE.BIN/
22+
23+
.DS_Store
24+
Thumbs.db
25+
UserInterfaceState.xcuserstate
26+
.env

.prettierrc.json

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"arrowParens": "avoid",
3+
"bracketSpacing": true,
4+
"jsxBracketSameLine": false,
5+
"jsxSingleQuote": false,
6+
"quoteProps": "consistent",
7+
"printWidth": 180,
8+
"semi": true,
9+
"singleQuote": true,
10+
"tabWidth": 2,
11+
"trailingComma": "all",
12+
"useTabs": false
13+
}

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2018
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

package-lock.json

+13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "map-viewer",
3+
"version": "0.0.1",
4+
"description": "Stencil Component Starter",
5+
"main": "dist/index.cjs.js",
6+
"module": "dist/custom-elements/index.js",
7+
"es2015": "dist/esm/index.mjs",
8+
"es2017": "dist/esm/index.mjs",
9+
"types": "dist/custom-elements/index.d.ts",
10+
"collection": "dist/collection/collection-manifest.json",
11+
"collection:main": "dist/collection/index.js",
12+
"unpkg": "dist/map-viewer/map-viewer.js",
13+
"files": [
14+
"dist/",
15+
"loader/"
16+
],
17+
"scripts": {
18+
"build": "stencil build --docs",
19+
"start": "stencil build --dev --watch --serve",
20+
"test": "stencil test --spec --e2e",
21+
"test.watch": "stencil test --spec --e2e --watchAll",
22+
"generate": "stencil generate"
23+
},
24+
"dependencies": {
25+
"@stencil/core": "^2.0.1"
26+
},
27+
"license": "MIT"
28+
}

readme.md

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
![Built With Stencil](https://img.shields.io/badge/-Built%20With%20Stencil-16161d.svg?logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPCEtLSBHZW5lcmF0b3I6IEFkb2JlIElsbHVzdHJhdG9yIDE5LjIuMSwgU1ZHIEV4cG9ydCBQbHVnLUluIC4gU1ZHIFZlcnNpb246IDYuMDAgQnVpbGQgMCkgIC0tPgo8c3ZnIHZlcnNpb249IjEuMSIgaWQ9IkxheWVyXzEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4IgoJIHZpZXdCb3g9IjAgMCA1MTIgNTEyIiBzdHlsZT0iZW5hYmxlLWJhY2tncm91bmQ6bmV3IDAgMCA1MTIgNTEyOyIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI%2BCjxzdHlsZSB0eXBlPSJ0ZXh0L2NzcyI%2BCgkuc3Qwe2ZpbGw6I0ZGRkZGRjt9Cjwvc3R5bGU%2BCjxwYXRoIGNsYXNzPSJzdDAiIGQ9Ik00MjQuNywzNzMuOWMwLDM3LjYtNTUuMSw2OC42LTkyLjcsNjguNkgxODAuNGMtMzcuOSwwLTkyLjctMzAuNy05Mi43LTY4LjZ2LTMuNmgzMzYuOVYzNzMuOXoiLz4KPHBhdGggY2xhc3M9InN0MCIgZD0iTTQyNC43LDI5Mi4xSDE4MC40Yy0zNy42LDAtOTIuNy0zMS05Mi43LTY4LjZ2LTMuNkgzMzJjMzcuNiwwLDkyLjcsMzEsOTIuNyw2OC42VjI5Mi4xeiIvPgo8cGF0aCBjbGFzcz0ic3QwIiBkPSJNNDI0LjcsMTQxLjdIODcuN3YtMy42YzAtMzcuNiw1NC44LTY4LjYsOTIuNy02OC42SDMzMmMzNy45LDAsOTIuNywzMC43LDkyLjcsNjguNlYxNDEuN3oiLz4KPC9zdmc%2BCg%3D%3D&colorA=16161d&style=flat-square)
2+
3+
# Stencil Component Starter
4+
5+
This is a starter project for building a standalone Web Component using Stencil.
6+
7+
Stencil is also great for building entire apps. For that, use the [stencil-app-starter](https://github.com/ionic-team/stencil-app-starter) instead.
8+
9+
# Stencil
10+
11+
Stencil is a compiler for building fast web apps using Web Components.
12+
13+
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.
14+
15+
Stencil components are just Web Components, so they work in any major framework or with no framework at all.
16+
17+
## Getting Started
18+
19+
To start building a new web component using Stencil, clone this repo to a new directory:
20+
21+
```bash
22+
git clone https://github.com/ionic-team/stencil-component-starter.git my-component
23+
cd my-component
24+
git remote rm origin
25+
```
26+
27+
and run:
28+
29+
```bash
30+
npm install
31+
npm start
32+
```
33+
34+
To build the component for production, run:
35+
36+
```bash
37+
npm run build
38+
```
39+
40+
To run the unit tests for the components, run:
41+
42+
```bash
43+
npm test
44+
```
45+
46+
Need help? Check out our docs [here](https://stenciljs.com/docs/my-first-component).
47+
48+
49+
## Naming Components
50+
51+
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!
52+
53+
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`.
54+
55+
56+
## Using this component
57+
58+
There are three strategies we recommend for using web components built with Stencil.
59+
60+
The first step for all three of these strategies is to [publish to NPM](https://docs.npmjs.com/getting-started/publishing-npm-packages).
61+
62+
### Script tag
63+
64+
- Put a script tag similar to this `<script src='https://unpkg.com/[email protected]/dist/mycomponent.js'></script>` in the head of your index.html
65+
- Then you can use the element anywhere in your template, JSX, html etc
66+
67+
### Node Modules
68+
- Run `npm install my-component --save`
69+
- Put a script tag similar to this `<script src='node_modules/my-component/dist/mycomponent.js'></script>` in the head of your index.html
70+
- Then you can use the element anywhere in your template, JSX, html etc
71+
72+
### In a stencil-starter app
73+
- Run `npm install my-component --save`
74+
- Add an import to the npm packages `import my-component;`
75+
- Then you can use the element anywhere in your template, JSX, html etc

src/components.d.ts

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/* eslint-disable */
2+
/* tslint:disable */
3+
/**
4+
* This is an autogenerated file created by the Stencil compiler.
5+
* It contains typing information for all components that exist in this project.
6+
*/
7+
import { HTMLStencilElement, JSXBase } from "@stencil/core/internal";
8+
export namespace Components {
9+
interface MyComponent {
10+
/**
11+
* The first name
12+
*/
13+
"first": string;
14+
/**
15+
* The last name
16+
*/
17+
"last": string;
18+
/**
19+
* The middle name
20+
*/
21+
"middle": string;
22+
}
23+
}
24+
declare global {
25+
interface HTMLMyComponentElement extends Components.MyComponent, HTMLStencilElement {
26+
}
27+
var HTMLMyComponentElement: {
28+
prototype: HTMLMyComponentElement;
29+
new (): HTMLMyComponentElement;
30+
};
31+
interface HTMLElementTagNameMap {
32+
"my-component": HTMLMyComponentElement;
33+
}
34+
}
35+
declare namespace LocalJSX {
36+
interface MyComponent {
37+
/**
38+
* The first name
39+
*/
40+
"first"?: string;
41+
/**
42+
* The last name
43+
*/
44+
"last"?: string;
45+
/**
46+
* The middle name
47+
*/
48+
"middle"?: string;
49+
}
50+
interface IntrinsicElements {
51+
"my-component": MyComponent;
52+
}
53+
}
54+
export { LocalJSX as JSX };
55+
declare module "@stencil/core" {
56+
export namespace JSX {
57+
interface IntrinsicElements {
58+
"my-component": LocalJSX.MyComponent & JSXBase.HTMLAttributes<HTMLMyComponentElement>;
59+
}
60+
}
61+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
:host {
2+
display: block;
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { newE2EPage } from '@stencil/core/testing';
2+
3+
describe('my-component', () => {
4+
it('renders', async () => {
5+
const page = await newE2EPage();
6+
7+
await page.setContent('<my-component></my-component>');
8+
const element = await page.find('my-component');
9+
expect(element).toHaveClass('hydrated');
10+
});
11+
12+
it('renders changes to the name data', async () => {
13+
const page = await newE2EPage();
14+
15+
await page.setContent('<my-component></my-component>');
16+
const component = await page.find('my-component');
17+
const element = await page.find('my-component >>> div');
18+
expect(element.textContent).toEqual(`Hello, World! I'm `);
19+
20+
component.setProperty('first', 'James');
21+
await page.waitForChanges();
22+
expect(element.textContent).toEqual(`Hello, World! I'm James`);
23+
24+
component.setProperty('last', 'Quincy');
25+
await page.waitForChanges();
26+
expect(element.textContent).toEqual(`Hello, World! I'm James Quincy`);
27+
28+
component.setProperty('middle', 'Earl');
29+
await page.waitForChanges();
30+
expect(element.textContent).toEqual(`Hello, World! I'm James Earl Quincy`);
31+
});
32+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { newSpecPage } from '@stencil/core/testing';
2+
import { MyComponent } from './my-component';
3+
4+
describe('my-component', () => {
5+
it('renders', async () => {
6+
const { root } = await newSpecPage({
7+
components: [MyComponent],
8+
html: '<my-component></my-component>',
9+
});
10+
expect(root).toEqualHtml(`
11+
<my-component>
12+
<mock:shadow-root>
13+
<div>
14+
Hello, World! I'm
15+
</div>
16+
</mock:shadow-root>
17+
</my-component>
18+
`);
19+
});
20+
21+
it('renders with values', async () => {
22+
const { root } = await newSpecPage({
23+
components: [MyComponent],
24+
html: `<my-component first="Stencil" last="'Don't call me a framework' JS"></my-component>`,
25+
});
26+
expect(root).toEqualHtml(`
27+
<my-component first="Stencil" last="'Don't call me a framework' JS">
28+
<mock:shadow-root>
29+
<div>
30+
Hello, World! I'm Stencil 'Don't call me a framework' JS
31+
</div>
32+
</mock:shadow-root>
33+
</my-component>
34+
`);
35+
});
36+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { Component, Prop, h } from '@stencil/core';
2+
import { format } from '../../utils/utils';
3+
4+
@Component({
5+
tag: 'my-component',
6+
styleUrl: 'my-component.css',
7+
shadow: true,
8+
})
9+
export class MyComponent {
10+
/**
11+
* The first name
12+
*/
13+
@Prop() first: string;
14+
15+
/**
16+
* The middle name
17+
*/
18+
@Prop() middle: string;
19+
20+
/**
21+
* The last name
22+
*/
23+
@Prop() last: string;
24+
25+
private getText(): string {
26+
return format(this.first, this.middle, this.last);
27+
}
28+
29+
render() {
30+
return <div>Hello, World! I'm {this.getText()}</div>;
31+
}
32+
}

src/components/my-component/readme.md

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# my-component
2+
3+
4+
5+
<!-- Auto Generated Below -->
6+
7+
8+
## Properties
9+
10+
| Property | Attribute | Description | Type | Default |
11+
| -------- | --------- | --------------- | -------- | ----------- |
12+
| `first` | `first` | The first name | `string` | `undefined` |
13+
| `last` | `last` | The last name | `string` | `undefined` |
14+
| `middle` | `middle` | The middle name | `string` | `undefined` |
15+
16+
17+
----------------------------------------------
18+
19+
*Built with [StencilJS](https://stenciljs.com/)*

0 commit comments

Comments
 (0)