Skip to content

Conversation

@vibraphone
Copy link
Member

No description provided.

@jourdain
Copy link
Collaborator

jourdain commented Nov 1, 2016

@vibraphone why the css contains style/classes for other components?
Why d3 in that component?

model.container.querySelector('.bg-color-container').style.backgroundColor = model.color;

What was the API change that you wanted? ;-)

@vibraphone
Copy link
Member Author

@jourdain d3 is in there because I'm comfy with it. I will clean up the CSS. The API change I really wanted was what's mentioned in the commit: adopting the newInstance(publicAPI, model) API instead of just providing a constructor that takes an element and a color. I presume that part is OK?

@vibraphone
Copy link
Member Author

@vibraphone why the css contains style/classes for other components?
Why d3 in that component?

model.container.querySelector('.bg-color-container').style.backgroundColor = model.color;

What was the API change that you wanted? ;-)

@jourdain d3 is in there because I'm comfy with it. I will clean up the CSS. The API change I really wanted was what's mentioned in the commit: adopting the newInstance(publicAPI, model) API instead of just providing a constructor that takes an element and a color. I presume that part is OK?

@vibraphone
Copy link
Member Author

@jourdain I've removed d3 and cleaned up the CSS.

return;
}

model.clientRect = model.container.getBoundingClientRect();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that method could remain empty...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like the method to be there (so that, for instance, it is easier to copy the component as a starting point for new components). Is it OK for the method to exist but do nothing? Or should I find something "demo-like" for it to do on resize to justify its existence?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes the method should exist, but do nothing. You can put its content inside a comment so other component could use the actual content by uncommenting it...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when using it as a template/starting-point.

@jourdain
Copy link
Collaborator

jourdain commented Nov 1, 2016

LGTM otherwise

const green = new BGColorComponent({ color:'green' });
const red = new BGColorComponent({ color:'red' });
const blue = new BGColorComponent({ color:'blue' });
const pink = new BGColorComponent({ color:'pink' });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this one use 'new' when the other example use 'newInstance'?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch Aron, that should be newInstance() now...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, Aron. Should be fixed now.

@vibraphone
Copy link
Member Author

@jourdain @aronhelser Thanks for the feedback.

@jourdain
Copy link
Collaborator

jourdain commented Nov 1, 2016

Thinking about it, you should have a destroy() method that call setContainer(null) and call the "parent" destroy.
You might be able to handle it by pushing a callback that does that in model.subscritions... ;-)
It is kind of sneaky but that will make a more complete example. If you want we can talk about it on a hangout so I can explain what I mean.

Now `BackgroundColor` provides a `newInstance()` method that
takes publicAPI and model objects, making it a good minimal example.
It also demonstrates how to import HTML fragments and CSS
style from external files.
See the `ToggleControl` and `Workbench` examples for usage.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants