@@ -6,37 +6,42 @@ import {EXAMPLE_COMPONENTS} from './example-module';
6
6
* with information about Component name, selector, files used in example, and path to examples
7
7
*/
8
8
export class ExampleData {
9
- // TODO: figure out how do we get these variables.
10
- description = 'Some description for material' ;
11
- // TODO: use real example and delete the example/ folder.
12
- examplePath = '/assets/example/' ;
13
- exampleFiles = [ 'button-demo.html' , 'button-demo.scss' , 'button-demo.ts' ] ;
14
9
15
- // TODO: extract these variables from example code.
16
- selectorName = 'button-demo' ;
17
- indexFilename = 'button-demo' ;
18
- componentName = 'ButtonDemo' ;
10
+ /** Description of the example. */
11
+ description : string ;
12
+
13
+ /** Path to the example. This is based on the structure of the material.angular.io repo. */
14
+ examplePath : string ;
15
+
16
+ /** List of files that are part of this example. */
17
+ exampleFiles : string [ ] ;
18
+
19
+ /** Selector name of the example component. */
20
+ selectorName : string ;
21
+
22
+ /** Name of the file that contains the example component. */
23
+ indexFilename : string ;
24
+
25
+ /**
26
+ * Name of the example component. For examples with multiple components, this property will
27
+ * include multiple components that are comma separated (e.g. dialog-overview)
28
+ */
29
+ componentName : string ;
19
30
20
31
constructor ( example : string ) {
21
32
if ( ! example || ! EXAMPLE_COMPONENTS . hasOwnProperty ( example ) ) {
22
33
return ;
23
34
}
24
35
25
36
const exampleConfig = EXAMPLE_COMPONENTS [ example ] ;
26
- const exampleFilesSet = new Set ( [ 'html' , 'ts' , 'css' ] . map ( extension => {
27
- return `${ example } -example.${ extension } ` ;
28
- } ) ) ;
29
37
30
38
// TODO(tinayuangao): Do not hard-code extensions
31
39
this . exampleFiles = [ 'html' , 'ts' , 'css' ] . map ( extension => `${ example } -example.${ extension } ` ) ;
32
40
this . examplePath = `/assets/stackblitz/examples/${ example } /` ;
33
- this . exampleFiles = Array . from ( exampleFilesSet . values ( ) ) ;
34
41
this . selectorName = this . indexFilename = `${ example } -example` ;
35
42
36
43
if ( exampleConfig . additionalFiles ) {
37
- for ( let file of exampleConfig . additionalFiles ) {
38
- exampleFilesSet . add ( file ) ;
39
- }
44
+ this . exampleFiles . push ( ...exampleConfig . additionalFiles ) ;
40
45
}
41
46
42
47
const exampleName = example . replace ( / (?: ^ \w | \b \w ) / g, letter => letter . toUpperCase ( ) ) ;
0 commit comments