Skip to content

Commit d00cb12

Browse files
authored
build: fix chips drag-drop example not working and improve example-module generation (#20003)
* build: fix chips drag-drop example not working and improve example-module generation Loading the chips-drag-drop example in the docs site is currently not possible, as the example files fail to load. This is because the example id does not match up with the directory that the example is stored within. This highlights an issue as the docs site assumes a certain folder structure. This is not ideal and an implementation detail specific to the Angular Components repository. The docs site should not need to make any assumptions about where code lives, but instead should just retrieve this information through the example information. That way we are free to change layout/file conventions in the components repository without having to worry about it breaking the docs site. This is implemented as part of this commit. Also a few sanity checks that enforce consistency (for improved code health) have been added. The new concept for examples also allows us to remove empty CSS files for examples without CSS. * chore: remove empty CSS files from examples We now can have examples without CSS files. This was previously not possible and the docs site just failed loading as it assumed a CSS file per example. We remove those empty stylesheets as they are superflous to examples and rather can confuse/distract the examples in the docs.
1 parent 23170af commit d00cb12

File tree

148 files changed

+98
-163
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

148 files changed

+98
-163
lines changed

src/components-examples/cdk/platform/cdk-platform-overview/cdk-platform-overview-example.css

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/components-examples/cdk/platform/cdk-platform-overview/cdk-platform-overview-example.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import {
1212
@Component({
1313
selector: 'cdk-platform-overview-example',
1414
templateUrl: 'cdk-platform-overview-example.html',
15-
styleUrls: ['cdk-platform-overview-example.css'],
1615
})
1716
export class CdkPlatformOverviewExample {
1817
supportedInputTypes = Array.from(getSupportedInputTypes()).join(', ');

src/components-examples/cdk/stepper/cdk-linear-stepper-with-form/cdk-linear-stepper-with-form-example.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {FormBuilder, FormGroup, Validators} from '@angular/forms';
44

55
/** @title A custom CDK linear stepper with forms */
66
@Component({
7-
selector: 'cdk-linear-stepper-with-form',
7+
selector: 'cdk-linear-stepper-with-form-example',
88
templateUrl: './cdk-linear-stepper-with-form-example.html',
99
styleUrls: ['./cdk-linear-stepper-with-form-example.css']
1010
})

src/components-examples/example-data.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,13 @@ export class ExampleData {
2727
return;
2828
}
2929

30-
const {componentName, additionalFiles, additionalComponents, title} =
30+
const {componentName, files, selector, primaryFile, additionalComponents, title} =
3131
EXAMPLE_COMPONENTS[example];
3232
const exampleName = example.replace(/(?:^\w|\b\w)/g, letter => letter.toUpperCase());
3333

34-
// TODO(tinayuangao): Do not hard-code extensions
35-
this.exampleFiles = ['html', 'ts', 'css'].map(extension => `${example}-example.${extension}`);
36-
this.selectorName = this.indexFilename = `${example}-example`;
37-
38-
this.exampleFiles.push(...additionalFiles);
34+
this.exampleFiles = files;
35+
this.selectorName = selector;
36+
this.indexFilename = primaryFile;
3937
this.description = title || exampleName.replace(/[\-]+/g, ' ') + ' Example';
4038
this.componentNames = [componentName, ...additionalComponents];
4139
}

0 commit comments

Comments
 (0)