Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
leomcelroy committed Oct 17, 2023
1 parent e60e1e5 commit b777c06
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
24 changes: 12 additions & 12 deletions js/createComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ export { html, render, svg };
export function createComponent({
name, // tag?
props,
attributes,
css,
view,
onConstruct,
onConnect,
onDisconnect,
onAttributeChange
onPropertyChange
}) {

if (!name) {
Expand All @@ -22,8 +23,8 @@ export function createComponent({
onConstruct = onConstruct ? onConstruct : null;
onConnect = onConnect ? onConnect : null;
onDisconnect = onDisconnect ? onDisconnect : null;
onAttributeChange = onAttributeChange ? onAttributeChange : null;

onPropertyChange = onPropertyChange ? onPropertyChange : null;
attributes = attributes ? attributes : {};

class Temp extends HTMLElement {

Expand All @@ -39,7 +40,7 @@ export function createComponent({
},
set: function(value) {
props[key] = value;
if (onAttributeChange) onAttributeChange(this, key, value);
if (onPropertyChange) onPropertyChange(this, key, value);
this.render();
},
enumerable: true,
Expand Down Expand Up @@ -71,15 +72,14 @@ export function createComponent({
render(view(this), this.dom);
}

// static get observedAttributes() {
// return Object.keys(props);
// }
static get observedAttributes() {
return Object.keys(attributes);
}

// attributeChangedCallback(name, oldValue, newValue) {
// console.log(name, oldValue, newValue);
// this[name] = JSON.parse(newValue);
// this.render();
// }
attributeChangedCallback(name, oldValue, newValue) {
console.log(name, oldValue, newValue);
this.render();
}
}

customElements.define( name, Temp );
Expand Down
6 changes: 4 additions & 2 deletions js/pcb_helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const vector_rotate = ([x, y], angle) => [


class Component {
constructor({ pads, layers, drills, footprint, pos, padShapes, id, rotation }) {
constructor({ pads, layers, drills, footprint, pos, padShapes, id, rotation, flip }) {
this.pads = pads;
this.layers = layers;
this.footprint = footprint;
Expand All @@ -44,6 +44,7 @@ class Component {
this.rotation = rotation;
this.padShapes = padShapes;
this.id = id;
this.flip = flip;
}

pad(name) {
Expand Down Expand Up @@ -207,7 +208,8 @@ function makeComponent(comp, options = {}) {
pos: translate,
padShapes,
id: id,
rotation: rotate
rotation: rotate,
flip
})
}

Expand Down

0 comments on commit b777c06

Please sign in to comment.