Skip to content

Commit

Permalink
Merge pull request #87 from thoov/embrodier-improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
rwjblue authored Nov 11, 2021
2 parents e8b300b + 597e1bb commit ac29b1b
Show file tree
Hide file tree
Showing 12 changed files with 484 additions and 231 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ jobs:
#- ember-canary
#- ember-classic
- ember-default-with-jquery
#- embroider-safe
#- embroider-optimized
- embroider-safe
- embroider-optimized

steps:
- uses: actions/checkout@v2
Expand Down
21 changes: 19 additions & 2 deletions addon/components/cp-panel-body/component.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
import { macroCondition, dependencySatisfies, importSync } from '@embroider/macros';
import { ensureSafeComponent } from '@embroider/util';
import Component from '@ember/component';
import { computed } from '@ember/object';
import { assert } from '@ember/debug';
import layout from './template';

let LiquidIf, hasRealLiquidIf;
if (macroCondition(dependencySatisfies('liquid-fire', '*'))) {
LiquidIf = importSync('liquid-fire/components/liquid-if').default;
hasRealLiquidIf = true;
} else {
hasRealLiquidIf = false;
}

export default Component.extend({
layout,

classNames: ['cp-Panel-body'],
classNameBindings: ['isOpen:cp-is-open']
classNameBindings: ['isOpen:cp-is-open'],

});
// ideally we'd use a getter here, but that requires Ember 3.16+
'liquidif': computed(function() {
assert('ember-collapsible-panel\'s cp-panel-body component requires liquid-fire to be present if `shouldAnimate` is used', hasRealLiquidIf);
return ensureSafeComponent(LiquidIf, this);
}),
});
4 changes: 2 additions & 2 deletions addon/components/cp-panel-body/template.hbs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{{#if shouldAnimate}}

{{#liquid-if isOpen use='crossFade'}}
{{#this.liquidif isOpen use='crossFade'}}
<div class="cp-Panel-body-inner">
{{yield}}
</div>
{{/liquid-if}}
{{/this.liquidif}}

{{else}}

Expand Down
18 changes: 13 additions & 5 deletions addon/components/cp-panel/component.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
import { scheduleOnce } from '@ember/runloop';
import { computed } from '@ember/object';
import { and, oneWay, readOnly, not } from '@ember/object/computed';
import { macroCondition, dependencySatisfies } from '@embroider/macros';
import { inject as service } from '@ember/service';
import Component from '@ember/component';
import layout from './template';

let hasLiquidFireDep;
if (macroCondition(dependencySatisfies('liquid-fire', '*'))) {
hasLiquidFireDep = true;
} else {
hasLiquidFireDep = false;
}

export default Component.extend({
layout,

panelActions: service(),
dependencyChecker: service(),
shouldAnimate: and('dependencyChecker.hasLiquidFire', 'animate'),
shouldAnimate: and('hasLiquidFireDep', 'animate'),

disabled: false,
hasLiquidFireDep,

group: null, // passed in if rendered as part of a {{cp-panels}} group

Expand Down Expand Up @@ -53,7 +61,7 @@ export default Component.extend({
}
});
},

// Custom action called when toggling that can be provided by caller
didToggle() {},

Expand All @@ -63,9 +71,9 @@ export default Component.extend({
return;
}
let name = this.get('name');

this.get('panelActions').toggle(name);

this.didToggle(name);
}
}
Expand Down
13 changes: 0 additions & 13 deletions addon/services/dependency-checker.js

This file was deleted.

1 change: 0 additions & 1 deletion app/services/dependency-checker.js

This file was deleted.

4 changes: 4 additions & 0 deletions config/ember-try.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
'use strict';

const getChannelURL = require('ember-source-channel-url');
const { embroiderSafe, embroiderOptimized } = require('@embroider/test-setup');

module.exports = async function () {
return {
useYarn: true,
scenarios: [
{
name: 'ember-lts-3.20',
Expand Down Expand Up @@ -84,6 +86,8 @@ module.exports = async function () {
},
},
},
embroiderSafe(),
embroiderOptimized(),
],
};
};
16 changes: 3 additions & 13 deletions config/environment.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
/*jshint node:true*/
'use strict';

var VersionChecker = require('ember-cli-version-checker');

module.exports = function( environment, appConfig, addon ) {
appConfig['ember-collapsible-panel'] = appConfig['ember-collapsible-panel'] || {};

var checker = new VersionChecker(addon);
var dep = checker.for('liquid-fire', 'npm');
var hasLiquidFire = dep.version;

appConfig['ember-collapsible-panel']['hasLiquidFire'] = hasLiquidFire;

return appConfig;
};
module.exports = function() {
return {};
}
3 changes: 2 additions & 1 deletion ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ module.exports = function(defaults) {
*/
app.import('node_modules/bootstrap/dist/css/bootstrap.css');

return app.toTree();
const { maybeEmbroider } = require('@embroider/test-setup');
return maybeEmbroider(app);
};
16 changes: 1 addition & 15 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,5 @@
'use strict';

var fs = require('fs');
var path = require('path');

module.exports = {
name: 'ember-collapsible-panel',

config: function (env, baseConfig) {
var configPath = path.join(this.root, 'config', 'environment.js');

if (fs.existsSync(configPath)) {
var configGenerator = require(configPath);

return configGenerator(env, baseConfig, this);
}
}

name: require('./package').name,
};
33 changes: 19 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,26 @@
"keywords": [
"ember-addon"
],
"homepage": "https://adopted-ember-addons.github.io/ember-collapsible-panel/",
"bugs": {
"url": "https://github.com/adopted-ember-addons/ember-collapsible-panel/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/adopted-ember-addons/ember-collapsible-panel.git"
},
"license": "MIT",
"author": "TEDconf and contributors",
"contributors": [
{
"email": "[email protected]",
"name": "Alon Bukai"
"name": "Alon Bukai",
"email": "[email protected]"
}
],
"directories": {
"doc": "doc",
"test": "tests"
},
"repository": {
"type": "git",
"url": "https://github.com/adopted-ember-addons/ember-collapsible-panel.git"
},
"scripts": {
"build": "ember build",
"lint:js": "eslint .",
Expand All @@ -29,12 +33,14 @@
"test:ember": "ember test"
},
"dependencies": {
"@embroider/macros": "^0.47.2",
"@embroider/util": "^0.47.2",
"ember-cli-babel": "^7.26.6",
"ember-cli-htmlbars": "^6.0.0",
"ember-cli-version-checker": "^5.1.2"
"ember-cli-htmlbars": "^6.0.0"
},
"devDependencies": {
"@ember/test-helpers": "^2.6.0",
"@embroider/test-setup": "^0.47.2",
"bootstrap": "^3.3.7",
"broccoli-asset-rev": "^3.0.0",
"ember-auto-import": "^2.2.3",
Expand All @@ -56,11 +62,11 @@
"ember-source": "~3.28.0",
"ember-source-channel-url": "^3.0.0",
"ember-ted-docs": "Alonski/ember-ted-docs",
"ember-try": "^2.0.0",
"ember-try": "^1.4.0",
"eslint": "^7.0.0",
"eslint-plugin-ember": "^5.0.0",
"eslint-plugin-node": "^11.1.0",
"liquid-fire": "0.32.0",
"liquid-fire": "^0.32.0",
"loader.js": "^4.7.0",
"node-sass": "^5.0.0",
"qunit": "^2.17.2",
Expand All @@ -70,12 +76,11 @@
"engines": {
"node": "12.* || 14.* || >= 16"
},
"bugs": {
"url": "https://github.com/adopted-ember-addons/ember-collapsible-panel/issues"
},
"homepage": "https://adopted-ember-addons.github.io/ember-collapsible-panel/",
"ember-addon": {
"configPath": "tests/dummy/config",
"demoURL": "https://adopted-ember-addons.github.io/ember-collapsible-panel/"
},
"volta": {
"node": "12.22.7"
}
}
Loading

0 comments on commit ac29b1b

Please sign in to comment.