1- import { computed } from '@ember/object' ;
1+ import classic from 'ember-classic-decorator' ;
2+ import { tagName , layout as templateLayout } from '@ember-decorators/component' ;
3+ import { action , computed } from '@ember/object' ;
24import { A } from '@ember/array' ;
35import Component from '@ember/component' ;
46import layout from './template' ;
@@ -27,23 +29,23 @@ import layout from './template';
2729 @yield {Component} demo.snippet
2830 @yield {Component} demo.liveExample
2931*/
30- export default Component . extend ( {
31- layout,
32- tagName : '' ,
33-
32+ @ classic
33+ @ templateLayout ( layout )
34+ @ tagName ( '' )
35+ export default class DocsDemo extends Component {
3436 init ( ) {
35- this . _super ( ...arguments ) ;
37+ super . init ( ...arguments ) ;
3638
3739 this . set ( 'snippetRegistrations' , A ( ) ) ;
38- } ,
40+ }
3941
4042 /**
4143 The snippets registered with this demo component
4244
4345 @field snippetRegistrations
4446 @type Array<Object>
4547 */
46- snippetRegistrations : null ,
48+ snippetRegistrations = null ;
4749
4850 /**
4951 The finalized snippets complete with name (or default), language,
@@ -54,7 +56,8 @@ export default Component.extend({
5456 @type Array<Object>
5557 @readOnly
5658 */
57- snippets : computed ( 'activeSnippet' , 'snippetRegistrations.[]' , function ( ) {
59+ @computed ( 'activeSnippet' , 'snippetRegistrations.[]' )
60+ get snippets ( ) {
5861 let activeSnippet = this . activeSnippet ;
5962
6063 return this . snippetRegistrations
@@ -67,7 +70,7 @@ export default Component.extend({
6770 language : language || defaults . language
6871 } ;
6972 } )
70- } ) ,
73+ }
7174
7275 /**
7376 Returns the default label and language based on snippet file name
@@ -102,32 +105,32 @@ export default Component.extend({
102105 }
103106
104107 return { label, language } ;
105- } ,
106-
107- actions : {
108- /**
109- Registers snippets with the demo component and sets it to the active
110- snippet if it's the only one
111-
112- @action registerSnippet
113- @param {Object } snippet
114- */
115- registerSnippet ( snippet ) {
116- this . snippetRegistrations . pushObject ( snippet ) ;
117-
118- if ( this . get ( 'snippetRegistrations.length' ) === 1 ) {
119- this . set ( 'activeSnippet' , snippet . name ) ;
120- }
121- } ,
122-
123- /**
124- Sets the active snippet
125-
126- @action selectSnippet
127- @param {Object } snippet
128- */
129- selectSnippet ( snippet ) {
108+ }
109+
110+ /**
111+ Registers snippets with the demo component and sets it to the active
112+ snippet if it's the only one
113+
114+ @action registerSnippet
115+ @param {Object } snippet
116+ */
117+ @action
118+ registerSnippet ( snippet ) {
119+ this . snippetRegistrations . pushObject ( snippet ) ;
120+
121+ if ( this . get ( 'snippetRegistrations.length' ) === 1 ) {
130122 this . set ( 'activeSnippet' , snippet . name ) ;
131123 }
132124 }
133- } ) ;
125+
126+ /**
127+ Sets the active snippet
128+
129+ @action selectSnippet
130+ @param {Object } snippet
131+ */
132+ @action
133+ selectSnippet ( snippet ) {
134+ this . set ( 'activeSnippet' , snippet . name ) ;
135+ }
136+ }
0 commit comments