Skip to content

Instantly share code, notes, and snippets.

View jonpitch's full-sized avatar

Jon Pitcherella jonpitch

View GitHub Profile
@jonpitch
jonpitch / new-build-notifier.js
Created September 28, 2018 01:16
new build notifier - component - medium
import Component from '@ember/component';
import layout from '../templates/components/new-build-notifier';
import { MDCSnackbar } from '@material/snackbar';
import { inject as service } from '@ember/service';
import { set } from '@ember/object';
import { task, timeout } from 'ember-concurrency';
import config from 'ember-get-config';
import { isEmpty } from '@ember/utils';
export default Component.extend({
@jonpitch
jonpitch / sw-registration.js
Created September 28, 2018 01:15
new build notification - service worker registration - medium
import { addSuccessHandler } from 'ember-service-worker/service-worker-registration';
window.isUpdateAvailable =
'Promise' in window
? new Promise(function(resolve) {
addSuccessHandler(function(reg) {
reg.onupdatefound = function() {
const { installing } = reg;
installing.onstatechange = function() {
if (installing.state === 'activated') {
@jonpitch
jonpitch / new-build-notifier.hbs
Last active September 28, 2018 00:34
new build notifier
<div class="mdc-snackbar mdc-snackbar--align-start" aria-live="assertive" aria-atomic="true" aria-hidden="true">
<div class="mdc-snackbar__text"></div>
<div class="mdc-snackbar__action-wrapper">
<button type="button" class="mdc-snackbar__action-button"></button>
</div>
</div>
@jonpitch
jonpitch / asset-map.js
Last active August 29, 2016 01:39
asset-map
// app/initializers/asset-map.js
import Ember from 'ember';
export function initialize(application) {
let assetMap = Ember.Object.extend();
application.register('impact:assets', assetMap);
application.inject('component:i18n-image', 'assets', 'impact:assets');
}
@jonpitch
jonpitch / demo.json
Created August 29, 2016 00:48
ember-i18n-json
// app/locales/en/translations.json
{
"app": {
"hello": "Hello"
}
}
// app/locales/es/translations.json
{
"app": {
@jonpitch
jonpitch / demo.js
Created August 29, 2016 00:38
ember-i18n
// app/locales/en/translations.js
export default {
app: {
hello: 'Hello'
}
}
// app/locales/es/translations.js
export default {
app: {
@jonpitch
jonpitch / translate.php
Created August 26, 2016 18:26
Translation config
<?php
/**
* Translation definitions of what data is pushed to Crowdin.
* The languages table drives what languages are supported.
*
* Expected format:
* 'base table name' => [
* 'tl' => 'the translation content table',
* 'path' => 'where the content should live in Crowdin'
@jonpitch
jonpitch / ember-page.js
Created July 28, 2016 22:05
write better ember tests - ember page object
// page.js
import PageObject, {
text,
isVisible
} from 'frontend/tests/page-object';
export default PageObject.create({
// some button
button: {
scope: '#some-button-id',
@jonpitch
jonpitch / basic-page-object.js
Created July 28, 2016 22:05
write better ember tests - page object
// without page object - bad
test('here is a test that does not use a page object', function(assert) {
this.render(hbs`{{my-component}}`);
const $button = this.$('#some-button-id');
const $description = this.$('p');
assert.ok($button.is(':visible'), 'I see the button');
assert.equal($description.text().trim(), 'Some text', 'The text is shown correctly');
});
@jonpitch
jonpitch / assertion-message.js
Created July 28, 2016 22:04
write better ember tests - be verbose
test('this is a dummy test', function(assert) {
const a = true;
const b = true;
// a developer can quickly scan these messages to understand what
// needs to happen and why.
assert.ok(a, 'A is true when X');
assert.equal(a, b, 'A and B are equal when X');
});