Skip to content
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

listed theme names and updated future work #3796

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions guides/theming.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ single css file for Angular Material in your app.
You can include a theme file directly into your application from
`@angular/material/core/theming/prebuilt`

Available pre-built themes:
<!-- directory(/src/lib/core/theming/prebuilt/) -->

If you're using Angular CLI, this is as simple as including one line
in your `styles.css` file:
```css
Expand Down Expand Up @@ -133,3 +136,4 @@ For more details about theming your own components, see [theming-your-components
### Future work
* Once CSS variables (custom properties) are available in all the browsers we support,
we will explore how to take advantage of them to make theming even simpler.
* More prebuilt themes will be added as development continues.
27 changes: 26 additions & 1 deletion tools/gulp/tasks/docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ const EXAMPLE_PATTERN = /<!--\W*example\(([^)]+)\)\W*-->/g;
// documentation page. Using a RegExp to rewrite links in HTML files to work in the docs.
const LINK_PATTERN = /(<a[^>]*) href="([^"]*)"/g;

// Some docs require maintaining a list of files.
// Supplying a directory as a argument will list the files at that directory.
// Supplying no arguments will list the files at the root of that folder.
const DIRECTORY_PATTERN = /<!--\W*directory\(([^)]+)\)\W*-->/g;

// HTML tags in the markdown generated files that should receive a .docs-markdown-${tagName} class
// for styling purposes.
const MARKDOWN_TAGS_TO_CLASS_ALIAS = [
Expand Down Expand Up @@ -107,10 +112,30 @@ function transformMarkdownFiles(buffer: Buffer, file: any): string {
// If the head is not prepended to the replaced value, then the first match will be lost.
`${head} href="${fixMarkdownDocLinks(link, file.path)}"`
);


/* Replace <!-- directory(..) --> comments with HTML elements. */
content = content.replace(DIRECTORY_PATTERN, (match: string, directory: string) =>
`<div>${listFiles(directory,file.path)}</div>`
);

return content;
}

/** Returns a list of files from a given directory */
function listFiles(directory: string, filePath: string): string {
// If no directory is supplied, take the directory from the filePath.
if(directory === '') {
directory = .dirname(filePath.base);
}

// Get all the files in the directory, just store their names in a list.
let files = gulp.src(directory).map((path) => {
return '<li>' + path.basename() + '</li>';
}).join();

return '<ul>' + files + '</ul>';
}

/** Fixes paths in the markdown files to work in the material-docs-io. */
function fixMarkdownDocLinks(link: string, filePath: string): string {
// As for now, only markdown links that are relative and inside of the guides/ directory
Expand Down