Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow user-defined defaults that override the normal defaults #1

Closed
kybishop opened this issue May 9, 2017 · 3 comments
Closed

Allow user-defined defaults that override the normal defaults #1

kybishop opened this issue May 9, 2017 · 3 comments

Comments

@kybishop
Copy link
Owner

@kybishop kybishop commented May 9, 2017

Ideally we determine all the default values at build time

@enkol

This comment has been minimized.

Copy link
Contributor

@enkol enkol commented May 17, 2017

I've taken a quick look at this and came up with master...enkol:user-defaults

It basically makes ember-attacher to look in the apps config/environment.js for options under ENV.emberAttacher.

Example user default options in config/environment.js:

module.exports = function(environment) {
  var ENV = {
    ...
    EmberENV: {
     ...
    },

    emberAttacher: {
        animation: 'fade',
        arrow: true,
        hideDelay: 0,
        hideDuration: 300,
        hideOn: 'mouseleave blur',
        interactive: false,
        placement: 'bottom',
        popperClass: 'popper tooltip fancy',
        popperOptions: null,
        renderInPlace: false,
        showDelay: 0,
        showDuration: 300,
        showOn: 'mouseenter focus',
    }
  };

  if (environment === 'development') {
...

It's not at build time, but maybe you can use this as a starting point for user default options.

I did not yet try to just import config from '../config/environment to get rid of the getOwner stuff in the init override . I think, this then would be at build time, but i'm not sure if it works from an addon (how to get the correct import path).

@kybishop

This comment has been minimized.

Copy link
Owner Author

@kybishop kybishop commented May 17, 2017

This is a great stop-gap until we can come up with a fully build-time solution; happy to accept a PR!

The only thing holding this back from being a permanent approach is that we need to recalculate the default values every time an ember-attacher is initialized, so if we have 10 tooltips, we do the same calculation 10 times. That said, I like that your approach optimizes for the common case (where the default value is used instead of the user-defined one).

I was initially holding off on this kind of approach in hopes of doing all the calculations for default values up-front at build time. Basically the same approach you've done, but without the need for the work done in init().

Still haven't figured out an easy way to do that... but have a hard way in mind where we generate a runtime file at build time, then stick that in broccoli. Will probably spike another addon for that since it is a general issue not specific to ember-attacher.

@kybishop

This comment has been minimized.

Copy link
Owner Author

@kybishop kybishop commented May 18, 2017

Implemented in #11.

Will revisit build time computed defaults when I or someone else has time to hammer out the details.

@kybishop kybishop closed this May 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.