UI/Update blueprints to glimmer components (#13149)

* updates generator to glimmer

* adds changelog

* accounts for addon vs reg components

* moves imports to the top of components
This commit is contained in:
claire bontempo 2021-11-16 13:14:16 -08:00 committed by GitHub
parent eda9607c8a
commit c8bfbbdf7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 10 deletions

3
changelog/13149.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:improvement
ui: Updates ember blueprints to glimmer components
```

View File

@ -1,3 +1,6 @@
import Component from '@glimmer/component';
<%= importTemplate %>
<%= setComponentTemplate %>
/**
* @module <%= classifiedModuleName %>
* <%= classifiedModuleName %> components are used to...
@ -11,7 +14,7 @@
* @param {string} [param1=defaultValue] - param1 is...
*/
import Component from '@ember/component';
<%= importTemplate %>
export default Component.extend({<%= contents %>
});
<%= exportDefault %>class <%= classifiedModuleName %> extends Component {
}
<%= exportAddOn %>

View File

@ -54,11 +54,13 @@ module.exports = {
},
locals: function(options) {
let templatePath = '';
let exportDefault = 'export default ';
let exportAddOn = '';
let importTemplate = '';
let contents = '';
let setComponentTemplate = '';
let templatePath = '';
// if we're in an addon, build import statement
// if we're in an addon, build import statement and set layout
if (options.project.isEmberCLIAddon() || (options.inRepoAddon && !options.inDummy) || !!options.in) {
if (options.pod) {
templatePath = './template';
@ -68,13 +70,19 @@ module.exports = {
'templates/components/' +
stringUtil.dasherize(options.entity.name);
}
importTemplate = "import layout from '" + templatePath + "';\n";
contents = '\n layout';
exportDefault = '';
exportAddOn = `export default setComponentTemplate(layout, ${stringUtil.classify(
options.entity.name
)})`;
importTemplate = "import layout from '" + templatePath + "';";
setComponentTemplate = "import { setComponentTemplate } from '@ember/component'; \n";
}
return {
exportDefault: exportDefault,
exportAddOn: exportAddOn,
importTemplate: importTemplate,
contents: contents,
setComponentTemplate: setComponentTemplate,
path: getPathOption(options),
};
},