Skip to content

chore: additional files for examples are missing #9548

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

Merged
merged 1 commit into from
Jan 23, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 21 additions & 16 deletions src/material-examples/example-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,42 @@ import {EXAMPLE_COMPONENTS} from './example-module';
* with information about Component name, selector, files used in example, and path to examples
*/
export class ExampleData {
// TODO: figure out how do we get these variables.
description = 'Some description for material';
// TODO: use real example and delete the example/ folder.
examplePath = '/assets/example/';
exampleFiles = ['button-demo.html', 'button-demo.scss', 'button-demo.ts'];

// TODO: extract these variables from example code.
selectorName = 'button-demo';
indexFilename = 'button-demo';
componentName = 'ButtonDemo';
/** Description of the example. */
description: string;

/** Path to the example. This is based on the structure of the material.angular.io repo. */
examplePath: string;

/** List of files that are part of this example. */
exampleFiles: string[];

/** Selector name of the example component. */
selectorName: string;

/** Name of the file that contains the example component. */
indexFilename: string;

/**
* Name of the example component. For examples with multiple components, this property will
* include multiple components that are comma separated (e.g. dialog-overview)
*/
componentName: string;

constructor(example: string) {
if (!example || !EXAMPLE_COMPONENTS.hasOwnProperty(example)) {
return;
}

const exampleConfig = EXAMPLE_COMPONENTS[example];
const exampleFilesSet = new Set(['html', 'ts', 'css'].map(extension => {
return `${example}-example.${extension}`;
}));

// TODO(tinayuangao): Do not hard-code extensions
this.exampleFiles = ['html', 'ts', 'css'].map(extension => `${example}-example.${extension}`);
this.examplePath = `/assets/stackblitz/examples/${example}/`;
this.exampleFiles = Array.from(exampleFilesSet.values());
this.selectorName = this.indexFilename = `${example}-example`;

if (exampleConfig.additionalFiles) {
for (let file of exampleConfig.additionalFiles) {
exampleFilesSet.add(file);
}
this.exampleFiles.push(...exampleConfig.additionalFiles);
}

const exampleName = example.replace(/(?:^\w|\b\w)/g, letter => letter.toUpperCase());
Expand Down