Skip to content

Instantly share code, notes, and snippets.

Avatar

Chris Garrett pzuraq

View GitHub Profile
@pzuraq
pzuraq / components.checkbox-list\.js
Last active Jul 31, 2020
Yielded Nested Checkboxes
View components.checkbox-list\.js
import Component from '@glimmer/component';
import { action } from '@ember/object';
export default class extends Component {
}
View controllers.application\.js
import Controller from '@ember/controller';
import { inject as service } from '@ember/service';
export default class ApplicationController extends Controller {
appName = 'Ember Twiddle';
transitionToQp = () => {
this.router.transitionTo({ queryParams: { foo: 123 } });
}
View getter-only-remote-data.js
class FetchTask {
@tracked isLoading = true;
@tracked result;
constructor(url) {
this.run(url);
}
async run(url) {
let response = await fetch(url);
View components.filter-bar\.js
import Component from '@glimmer/component';
import { action } from '@ember/object';
import { tracked } from '@glimmer/tracking';
export default class extends Component {
@tracked showDD = false;
@tracked selectedFilters = [];
get unselectedFilters() {
return this.args.options.filter(f => !this.selectedFilters.includes(f));
View decorator-with-autotracking-apis.js
import { createTag, dirtyTag, consumeTag } from '@glimmer/tracking/tags';
export function inLocalStorage(
target,
propertyKey,
descriptor
) {
const targetName = target.constructor.name;
const key = `${targetName}-${propertyKey}`;
View entangle-with-get-set.js
import { get, notifyPropertyChange } from '@ember/object';
export function inLocalStorage(
target,
propertyKey,
descriptor
) {
const targetName = target.constructor.name;
const { initializer } = descriptor;
View local-copy-with-decorator.js
import { TrackedWeakMap } from 'tracked-built-ins';
function localCopy(target, key) {
let values = new TrackedWeakMap();
let lastValues = new WeakMap();
return {
get() {
let incoming = this.args[key];
let lastValue = lastValues.get(this);
@pzuraq
pzuraq / script.js
Created Nov 16, 2019
VSCode Vertical Tab Bar
View script.js
let innerWidthDesc = Object.getOwnPropertyDescriptor(window, 'innerWidth');
let getOriginalInnerWidth = innerWidthDesc.get.bind(window);
let setOriginalInnerWidth = innerWidthDesc.set.bind(window);
let VERTICAL_TABS_ENABLED = false;
Object.defineProperty(window, 'innerWidth', {
get() {
if (VERTICAL_TABS_ENABLED) {
return getOriginalInnerWidth() - 200;
View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
queryParams: ['foo'],
foo: 'bar',
actions: {
You can’t perform that action at this time.