Skip to content

Instantly share code, notes, and snippets.

View loganvolkers's full-sized avatar

Logan Volkers loganvolkers

View GitHub Profile
`<sqm-example hidden />`
:host([hidden]){
display: none;
}
`<sqm-example show-icon />`
:host([show-icon]) .icon{
display: block;
}

Universal Hooks

A proposal for interoperability of React-style hooks.

Problem

  • React invented the hooks approach to functional components, but they are stuck in a framework-specific environment.
  • Haunted has created a pure JS alternative to React
  • Other frameworks (https://github.com/WebReflection/uland) also introduced hooks
@loganvolkers
loganvolkers / ScriptTracker.ts
Last active November 19, 2020 23:25
Use `script` elements for web components. Inspired by @polymer/marked-element
import { getElement } from '@stencil/core';
export type ScriptTrackerProps = {
element: any;
updater: (value: unknown) => unknown;
onError?: (e: Error) => unknown;
};
export class ScriptTracker {
/**
@loganvolkers
loganvolkers / ExampleHook.ts
Last active October 19, 2020 22:47
Stencil Hooks
import { Component, h } from '@stencil/core';
import { useState } from 'haunted';
import { useHook } from './stencil-hooks';
@Component({
tag: 'example-hook',
})
export class ExampleHook {
render = useHook(this, () => {
@loganvolkers
loganvolkers / ConsumerExample.ts
Last active September 15, 2020 15:41
Context for Stencil
@Component({
tag: 'stencil-consumer',
})
export class StencilConsumer {
@Prop() renderer: any;
@State() context: Record<string, any>;
componentWillLoad(){
console.log("Will load")
}
@loganvolkers
loganvolkers / Byte Formatting for Google Sheets.md
Last active October 8, 2024 08:29
Byte formatting for Google Sheets
@loganvolkers
loganvolkers / Widget API Definition.js
Created September 20, 2016 02:55
Widget API Definition
/**
* Widget <> Squatch.js Interface via EasyXDM
*/
init(height, width, codeIn, rewardBalance, resizeEmbedToContentIn)
resize(height, width)
publish(eventName, payload)
close()
error(errorMessage, height, width)
@loganvolkers
loganvolkers / Auth0Mailchimp.js
Last active September 8, 2016 04:40
Auth0 Custom Connection Script
function doAuth(access_token, ctx, callback) {
var opts = {
'headers': {
'Authorization': 'OAuth ' + access_token,
'Accept': 'application/json',
'User-Agent': 'Auth0'
}
};
request.get('https://login.mailchimp.com/oauth2/metadata', opts, function(e, r, b) {
import Ember from 'ember';
export default Ember.Component.extend({
backendService: Ember.inject.service('backend-service'),
actions: {
login() {
this.get('backendService').login();
},
query() {
this.get('backendService').query();