Skip to content

Instantly share code, notes, and snippets.

View freshcutdevelopment's full-sized avatar

Sean Hunter freshcutdevelopment

View GitHub Profile
@freshcutdevelopment
freshcutdevelopment / info-card-v3.js
Created September 6, 2017 10:27
Info card v3 snippet (Blog)
import {useShadowDOM} from 'aurelia-framework'; //import the useShadowDOM decorator
@useShadowDOM() //decorator provided by the Aurelia framework to use the Shadow DOM
export class InfoCard{
}
@freshcutdevelopment
freshcutdevelopment / info-card-v3.html
Last active September 10, 2017 08:24
Info card v3 snippet (Blog)
<template>
<style>
.card-content {
border:1px solid grey;
width: 500px;
height: 150px;
margin-bottom:10px;
padding:20px;
color: #777;
background-color: #F7F7F7;
@freshcutdevelopment
freshcutdevelopment / scoped-css.html
Created September 6, 2017 10:26
Scoped CSS Snippet (Blog)
<template>
<require from="./card-styles.css" as="scoped"></require> //only works in Firefox at the time of writing
<template id="info-card">
<div class="card-content">
<slot name="header">To be replaced with header</slot>
<div class="card-body">
<slot name="body"><p>To be replaced with body </p></slot>
</div>
</div>
</template>
@freshcutdevelopment
freshcutdevelopment / info-card-v2.html
Created September 6, 2017 10:24
Info card custom element template (Blog)
<template id="info-card">
<slot name="header"><h1>To be replaced with header</h1></slot>
<slot name="body"><p>To be replaced with body </p></slot>
</template>
@freshcutdevelopment
freshcutdevelopment / shadow-dom-card-1.html
Created September 6, 2017 10:24
Shadow DOM Card v1 - (Blog)
<template id="info-card">
</template>
<script>
class XInfoCard extends HTMLElement {
// Monitor the 'message' attribute for changes.
static get observedAttributes() { return ['message']; }
// Respond to attribute changes.
attributeChangedCallback(attr, oldValue, newValue) {
@freshcutdevelopment
freshcutdevelopment / vanilla-shadow-dom.html
Created September 6, 2017 10:21
Vanilla shadow DOM HTML snippet (Blog)
<html>
<head></head>
<body>
<p id="component-host"></p>
<script>
var shadowElement = document.querySelector('#component-host')
.attachShadow({mode: 'open'});
shadow.innerHTML = '<span>DOM subtree</span>';
</script>
@freshcutdevelopment
freshcutdevelopment / shadow-dom-slots.html
Created September 5, 2017 23:20
Shadow DOM slots - Blog Gist
<head>
</head>
<body>
<template id="info-card">
<style>
.card-content {
border:1px solid grey;
width: 500px;
height: 150px;
@freshcutdevelopment
freshcutdevelopment / shadow-dom-basics.html
Created September 5, 2017 23:19
Shadow DOM basics - blog Gist
<head>
</head>
<body>
<template id="info-card">
<style>
.card-content {
border:1px solid grey;
width: 500px;
height: 150px;
@freshcutdevelopment
freshcutdevelopment / app.html
Created September 3, 2017 04:16
Using the x-info-card custom element
<x-info-card message="basic info card content"></x-info-card>
@freshcutdevelopment
freshcutdevelopment / info-card.js
Last active September 3, 2017 04:26
Aurelia info-card view-model
import {bindable} from 'aurelia-framework'; //import bindable decorator to allow message to be passed down from parent component
export class InfoCard{
@bindable message;
}