Skip to content

Instantly share code, notes, and snippets.

View nerdic-coder's full-sized avatar
💭
Block Photos 2.0 will be out soon and is going to be great!

Johan Axelsson nerdic-coder

💭
Block Photos 2.0 will be out soon and is going to be great!
View GitHub Profile
@nerdic-coder
nerdic-coder / cli-dependecies.js
Created June 2, 2018 19:34
cli-dependecies.js
#! /usr/bin/env node
var shell = require("shelljs");
const path = require('path');
// The path to the installation directory if this tool
var cliPath = path.join(path.dirname(__filename), '..');
// Check that a command is given
if (!process.argv[2]) {
shell.echo('Please tell me what you want me todo!');
@nerdic-coder
nerdic-coder / package.json
Created June 2, 2018 19:30
stencil-cli package.json
"main": "bin/stencil-cli.js",
"bin": {
"stencil": "bin/stencil-cli.js"
}
@nerdic-coder
nerdic-coder / st-container.tsx
Created May 27, 2018 17:42
st-container.tsx
import { Component, Prop, Watch } from '@stencil/core';
@Component({
tag: 'st-container',
shadow: true
})
export class StContainer {
@Prop() private stIf: string;
@Prop({ mutable: true }) private shouldRender = true;
@nerdic-coder
nerdic-coder / st-container.spec.ts
Created May 27, 2018 15:54
st-container.spec.ts
import { TestWindow } from '@stencil/core/testing';
import { StContainer } from './st-container';
describe('st-container', () => {
it('should build', () => {
expect(new StContainer()).toBeTruthy();
});
describe('rendering', () => {
let element;
@nerdic-coder
nerdic-coder / stencil-container-package.json
Created May 25, 2018 19:21
stencil-container-package.json
{
"name": "stencil-container",
"version": "0.0.2",
"description": "Stencil Container with if-statements and for-loops",
"module": "dist/esm/index.js",
"main": "dist/index.js",
"types": "dist/types/components.d.ts",
"collection": "dist/collection/collection-manifest.json",
"files": [
"dist/"
@nerdic-coder
nerdic-coder / clone-stencil-starter.sh
Last active May 25, 2018 19:12
clone-stencil-starter.sh
git clone https://github.com/ionic-team/stencil-component-starter stencil-container
cd my-component
git remote rm origin
npm install
@nerdic-coder
nerdic-coder / hero-search.tsx
Created May 20, 2018 20:44
hero-search.tsx
import { Component, State } from '@stencil/core';
import { Hero } from '../../models/hero';
import { HeroService } from '../../services/hero.service';
import { Observable, Subject } from 'rxjs';
import {
debounceTime, distinctUntilChanged, switchMap
} from 'rxjs/operators';
@nerdic-coder
nerdic-coder / hero-search.spec.ts
Created May 20, 2018 20:43
hero-search.spec.ts
import { render } from '@stencil/core/testing';
import { HeroeSearch } from './hero-search';
describe('app-hero-search', () => {
it('should build', () => {
expect(new HeroeSearch()).toBeTruthy();
});
describe('rendering', () => {
beforeEach(async () => {
@nerdic-coder
nerdic-coder / hero-search.css
Created May 20, 2018 20:42
hero-search.css
/* HeroSearch private styles */
.search-result li {
border-bottom: 1px solid gray;
border-left: 1px solid gray;
border-right: 1px solid gray;
width:195px;
height: 16px;
padding: 5px;
background-color: white;
cursor: pointer;
@nerdic-coder
nerdic-coder / searchHeroes.ts
Created May 20, 2018 20:38
searchHeroes.ts
/* GET heroes whose name contains search term */
searchHeroes(term: string): Observable<Hero[]> {
if (!term.trim()) {
// if not search term, return empty hero array.
return of([]);
}
return Observable.create((observer) => {
const xhr = new XMLHttpRequest();
xhr.open('GET', CONFIG.SERVER_URL + `heroes/?q=${term}`);