Giter VIP home page Giter VIP logo

ionic-team / stencil Goto Github PK

View Code? Open in Web Editor NEW
12.3K 179.0 763.0 76.66 MB

A toolchain for building scalable, enterprise-ready component systems on top of TypeScript and Web Component standards. Stencil components can be distributed natively to React, Angular, Vue, and traditional web developers from a single, framework-agnostic codebase.

Home Page: https://stenciljs.com

License: Other

JavaScript 0.67% TypeScript 98.36% HTML 0.55% CSS 0.36% Shell 0.03% SCSS 0.03%
webcomponents custom-elements typescript stencil stenciljs ionic ssr ssg static-site-generator

stencil's Introduction

stencil-logo

Stencil

A compiler for generating Web Components using technologies like TypeScript and JSX, built by the Ionic team.

StencilJS is released under the MIT license. StencilJS is released under the MIT license. PRs welcome! Follow @stenciljs Official Ionic Discord

Getting Started

Start a new project by following our quick Getting Started guide. We would love to hear from you! If you have any feedback or run into issues using Stencil, please file an issue on this repository.

Examples

A Stencil component looks a lot like a class-based React component, with the addition of TypeScript decorators:

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

@Component({
  tag: 'my-component',            // the name of the component's custom HTML tag
  styleUrl: 'my-component.css',   // css styles to apply to the component
  shadow: true,                   // this component uses the ShadowDOM
})
export class MyComponent {
  // The component accepts two arguments:
  @Prop() first: string;
  @Prop() last: string;

   //The following HTML is rendered when our component is used
  render() {
    return (
      <div>
        Hello, my name is {this.first} {this.last}
      </div>
    );
  }
}

The component above can be used like any other HTML element:

<my-component first="Stencil" last="JS"></my-component>

Since Stencil generates web components, they work in any major framework or with no framework at all. In many cases, Stencil can be used as a drop in replacement for traditional frontend framework, though using it as such is certainly not required.

Contributing

Thanks for your interest in contributing! Please take a moment to read up on our guidelines for contributing. Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

stencil's People

Contributors

adamdbradley avatar alicewriteswrongs avatar arjunyel avatar bodinaren avatar brandyscarney avatar christian-bromann avatar claviska avatar danbucholtz avatar dependabot[bot] avatar fionawhim avatar github-actions[bot] avatar imhoffd avatar jgw96 avatar jthoms1 avatar kensodemann avatar ltm avatar manucorporat avatar mattdsteele avatar mhartington avatar mlynch avatar pengbouestc avatar renovate[bot] avatar rwaskiewicz avatar sean-perkins avatar simonhaenisch avatar splitinfinities avatar tanner-reits avatar tja4472 avatar tricki avatar yigityuce avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

stencil's Issues

Get an error when running the core-hn-demo PWA in mono-refactor of Ionic

    at attachListeners (app.core.js:998)
    at initLoad (app.core.js:1581)
    at HTMLElement.value (app.core.js:1546)
    at initLoad (app.core.js:1611)
    at HTMLElement.value (app.core.js:1546)
    at initLoad (app.core.js:1611)
    at HTMLElement.value (app.core.js:1546)
    at update (app.core.js:1304)
    at queueUpdateNextTick (app.core.js:1287)
    at doWork (app.core.js:1912) ```

Repro steps:
- Follow these directions https://docs.google.com/document/d/1Hmyyh-1ohB6w00gTJVkGkQDtm44FIhSi9FiArBi8x-s/edit
- run the core-hn-demo app
- see the error

Discussion: support DI or auto-connecting w/ global instances?

Do we want to support some kind of limited DI system that auto injects known singletons/objects into props?

export class MyComponent {
  @Prop({ connect: true }) nav: Navigator;
}

And then this automagically knows where to find Navigator to inject it into this prop?

ion-list has too much bottom margin

ion-list has this rule margin: -1px 0 16px 0;. This causes the list to not completely cover the ion-scroll component and leaves you with a gap at the bottom of the list where the ion-scroll shows through (the grey gap in the below screenshot)
screen shot 2017-05-26 at 11 28 52 am

Compiler should figure out all the named slots

Instead of dynamically figuring out which named slots are available at runtime, if any, let's collect an array of slot names so we can know ahead of time.

Set the namedSlotsMeta property on the ComponentMeta.

Related to #29

Buttons have outline on :focus

When a button is focused it currently has the default button outline style that browsers apply
screen shot 2017-05-11 at 1 18 57 pm

Buttons in ionic-angular do not have this outline

styleUrl isn't working properly for components

Adding the following to a Component:

@Component({
  tag: 'ion-fixed',
  styleUrl: 'fixed.scss'
})

generates the following, and doesn't get the right styles:

"tagNameMeta": "ion-fixed",
"styleMeta": {
  "$": {
    "styleUrls": [
      "components/fixed/fixed.scss"
    ]
  }
},

However, if I include styleUrls for all of the modes:

@Component({
  tag: 'ion-fixed',
  styleUrl: 'fixed.scss',
  styleUrls: {
    ios: 'fixed.scss',
    md: 'fixed.scss',
    wp: 'fixed.scss'
  }
})

it works fine and generates the following

"tagNameMeta": "ion-fixed",
"styleMeta": {
  "$": {
    "styleUrls": [
      "components/fixed/fixed.scss"
    ]
  },
  "ios": {
    "styleUrls": [
      "components/fixed/fixed.scss"
    ]
  },
  "md": {
    "styleUrls": [
      "components/fixed/fixed.scss"
    ]
  },
  "wp": {
    "styleUrls": [
      "components/fixed/fixed.scss"
    ]
  }
},

Hydrated causes issues with components using visibility style

We have some components in Ionic which override the visibility to hidden by default. For example:

ion-item-options {
  visibility: hidden;
}

The styling added by the hydrated class overrides this:

ion-item-options.hydrated {
  visibility: visible;
}

If it is possible to just add the style directly to the element and remove it once hydrated that might be the best solution. I'm up for discussion though!

Mode is not being respected when added as an attribute

If the component doesn't have:

@Prop() mode: string;

then adding the mode as an attribute will not apply the proper theme classes. An example:

<ion-searchbar mode="md">

will still add .searchbar-ios if you are viewing on iOS.

On that note, it seems there are some cases where mode and color are added as a @Prop and others where they aren't...see:

button, icon, item, modal, spinner, toggle

  @Prop() mode: string;
  @Prop() color: string;

Cannot build release package of ionic-angular 4 alpha

[14:28:06] Starting 'release.polyfill'...
core, buildBindingCore: /Users/justinwillis/Projects/ionic-core/dist/transpiled-angular/bindings/angular/src
core, buildCore: /Users/justinwillis/Projects/ionic-core/dist/compiled-ionic-angular/core/ionic.core.dev.js
core, buildCoreES5: /Users/justinwillis/Projects/ionic-core/dist/compiled-ionic-angular/core/ionic.core.es5.dev.js
core, buildAnimationsMinified: /Users/justinwillis/Projects/ionic-core/dist/compiled-ionic-angular/core/ionic.core.es5.dev.js
core, buildCoreES5Minified: /Users/justinwillis/Projects/ionic-core/dist/compiled-ionic-angular/core/ionic.core.es5.dev.js
core, buildCoreMinified: /Users/justinwillis/Projects/ionic-core/dist/compiled-ionic-angular/core/ionic.core.js
core, customElementPolyfillDev: /Users/justinwillis/Projects/ionic-core/dist/compiled-ionic-angular/core/ionic.core.ce.dev.js
core, shadyDomCustomElementPolyfillDev: /Users/justinwillis/Projects/ionic-core/dist/compiled-ionic-angular/core/ionic.core.sd.ce.dev.js
core, customElementPolyfillMin: /Users/justinwillis/Projects/ionic-core/dist/compiled-ionic-angular/core/ionic.core.ce.js
core, shadyDomCustomElementPolyfillMin: /Users/justinwillis/Projects/ionic-core/dist/compiled-ionic-angular/core/ionic.core.sd.ce.js
[14:28:14] 'core' errored after 12 s
[14:28:14] Error: task completion callback called too many times
    at finish (/Users/justinwillis/Projects/ionic/node_modules/orchestrator/lib/runTask.js:15:10)
    at cb (/Users/justinwillis/Projects/ionic/node_modules/orchestrator/lib/runTask.js:29:3)
    at ChildProcess.<anonymous> (/Users/justinwillis/Projects/ionic/scripts/gulp/tasks/core.ts:51:5)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at maybeClose (internal/child_process.js:877:16)
    at Socket.<anonymous> (internal/child_process.js:334:11)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at Pipe._handle.close [as _onclose] (net.js:498:12)
[14:28:14] 'release.prepareReleasePackage' errored after 12 s
[14:28:14] Error in plugin 'run-sequence(core)' ```

when running `gulp release.prepareReleasePackage`

Compiler to figure out if a component has slots or not

Compiler should figure out if a component has default or named slots at all. Set the hasSlotsMeta boolean on the component's meta.

This allows us to have a fast path for components that don't need to check for slots, and to speed up the runtime slot stuff.

ion-buttons

When trying to use ion-buttons slot="start" and ion-buttons slot="end" they do not get the correct css for start and end.

build --watch exits occasionally

If you run npm start and your code has an error already, the watch will output your typescript errors and then exit. It should watch anyways instead of exiting immediately

Compiler hardcode its own property names for vnode

Users can write attrs and props, so that means we can't safely property rename those. Instead, let's have the compiler rename them to vattrs and vprops so users could still write them, but our runtime can property rename them.

This will probably go along with #27

Button in a primary colored toolbar does not get colored white

<ion-header>
    <ion-toolbar color="primary">
       <ion-button class="closeButton" clear>
           close
        </ion-button>
    </ion-toolbar>
</ion-header> 

In ionic-angular a button inside a primary toolbar will have color: white on it. This does not currently happen in core

CSS in the custom web component overrides other css

The styles added in <style> tags are taking priority over all other css, this includes css that is included via a CSS file and imported in the <head>, as well as any ionic CSS that was previously imported after the (now web) component in Sass and therefore took precedence.

Some examples of this:

CSS file imported in the head

<html dir="ltr" lang="en">
<head>
   ...

  <link id="ionicLink" href="./build/main.css" rel="stylesheet">
  <link href="build/e2e.shared.css" rel="stylesheet">
</head>
<body>
  ...
</body>

screen shot 2017-05-23 at 12 23 01 pm

Because the <style> tag is injected at the end of the <head>, all of the card styles are taking precedence over the ones in the e2e.shared.css file. We could change where our style tags are injected in the head, or recommend the user moves any css imports to a specific place like the <body>.

Item styling is not applying inside of a card

screen shot 2017-05-23 at 12 27 20 pm

Previously item was imported after the card SCSS file so it would take precedence when using an item inside of a card, but now the card styling is overriding it.

There isn’t an easy fix for this - we could add more css to the styles that are now being overridden but then it wouldn’t be very decoupled (adding card css into item for example), and it might be fixed when the other component is converted to a web component itself. I tried removing the styles that were overriding the item styles but it causes issues in other places, specifically the paragraph colors when not in an item.

See this image for an example of what happens when the card color styles are removed:

screen shot 2017-05-23 at 12 32 44 pm

this.$el does not work in browsers that need the custom elements polyfill

Im using this.$el to get the element that a component is "attached to". In chrome, which does not need the polyfills it works fine, but in browsers that need the polyfilll, like edge, this.$el is undefined. After discussing this with adam this morning this is most likely caused by some async nature in the custom elements polyfill, while the real implementation in the browser is sync.

Compiler to replace runtime h()

Have the compiler hardcode exact h() arguments, so that at runtime we don’t need to figure out how h() was written and what args match up to what.

Basically have the compiler do the same thing that the runtime h() is doing to create a vnode object.

gulp e2e.prod fails

Running gulp e2e.prod --f=badge --debug on the v4-alpha branch produces:

[11:00:37] Starting 'e2e.prod'...
Compiling 1 E2E tests ...
Starting to do a prod build test /Users/brandyscarney/Documents/git/ionic/src/components/badge/test/basic/app/main.ts
[11:00:38]  build started ...
[11:00:38]  transpile started ...
[11:00:38]  build finished in 1 ms

core, buildAnimationsMinified: /Users/brandyscarney/Documents/git/ionic-core/dist/compiled-ionic-angular/core/ionic.core.es5.dev.js
core, buildCoreMinified: /Users/brandyscarney/Documents/git/ionic-core/dist/compiled-ionic-angular/core/ionic.core.js
core, buildCoreES5Minified: /Users/brandyscarney/Documents/git/ionic-core/dist/compiled-ionic-angular/core/ionic.core.es5.dev.js
core, customElementPolyfillDev: /Users/brandyscarney/Documents/git/ionic-core/dist/compiled-ionic-angular/core/ionic.core.ce.dev.js
core, shadyDomCustomElementPolyfillDev: /Users/brandyscarney/Documents/git/ionic-core/dist/compiled-ionic-angular/core/ionic.core.sd.ce.dev.js
core, customElementPolyfillMin: /Users/brandyscarney/Documents/git/ionic-core/dist/compiled-ionic-angular/core/ionic.core.ce.js
core, shadyDomCustomElementPolyfillMin: /Users/brandyscarney/Documents/git/ionic-core/dist/compiled-ionic-angular/core/ionic.core.sd.ce.js
[11:00:45] 'core' errored after 26 s
[11:00:45] Error: task completion callback called too many times
    at finish (/Users/brandyscarney/Documents/git/ionic/node_modules/orchestrator/lib/runTask.js:15:10)
    at cb (/Users/brandyscarney/Documents/git/ionic/node_modules/orchestrator/lib/runTask.js:29:3)
    at ChildProcess.<anonymous> (/Users/brandyscarney/Documents/git/ionic/scripts/gulp/tasks/core.ts:51:5)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at maybeClose (internal/child_process.js:850:16)
    at Socket.<anonymous> (internal/child_process.js:323:11)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at Pipe._handle.close [as _onclose] (net.js:485:12)
[11:00:46]  ionic-app-scripts 1.3.7-201705101551
[11:00:46]  build dev started ... MEM: 140.6MB
[11:00:46]  clean started ... MEM: 141.2MB
[ DEBUG! ]  [Clean] clean: cleaning
            /Users/brandyscarney/Documents/git/ionic/dist/e2e/components/badge/test/basic/www/build  MEM:
            141.2MB
[11:00:46]  clean finished in 3 ms MEM: 141.2MB
[11:00:46]  copy started ... MEM: 141.2MB
[11:00:46]  ngc started ... MEM: 141.2MB
[ DEBUG! ]  [AotCompiler] compile: starting codegen ...  MEM: 220.5MB

content shows up under header

Due to a timing issue of when measurements are taken the content sometimes shows up slightly hidden under the header

Usage of unix specific commands in our build scripts

There are a few places in our build scripts where we use Unix specific commands or paths. This causes things to not work right ootb on Windows 10. Can be worked around with certain shells or the Microsoft bash on windows project, but obviously, that's not ideal.

Conditional child rendering not working

It seems like children cannot be conditionally rendered if they are specified in a parent component.

For example, I have a <ion-route> component and I only want to render the children inside of <ion-route> when the route matches.

Here's the markup I might write as the user:

          <ion-route url="/" router="#router">
            <landing-page></landing-page>
          </ion-route>
          <ion-route url="/docs" router="#router">
            <docs-page></docs-page>
          </ion-route>
          <ion-route url="/demos" router="#router">
            <demos-page></demos-page>
          </ion-route>

And <ion-route> has this render function:

  render() {
    return null;
}

Even though <ion-route> is not rendering its children, they are still rendered.

This conflicts with how this works in react. For example, this doesn't render the children even though they are written in the markup:

screen shot 2017-06-25 at 11 16 09 am

Error when opening a modal

<ion-header>
  <ion-toolbar>
  </ion-toolbar>
</ion-header>

<ion-content>
  <ion-list>
  </ion-list>
</ion-content>

When using this markup in a modal i get the following error :

  Uncaught TypeError: Cannot read property 'children' of null
    at Content.readDimensions (ionic.ion-app.md.ion-content.md.ion-title.md.ion-toolbar.md.js:256)
    at rafFlush (ionic.core.js:73)
    at rafCallback (ionic.core.js:65)

Rename repo to stencil

With the refactoring going on, it's getting confusing mentally switching between ionic, ionic-core (our UI components), and stencil

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.