This repository has been archived by the owner on Dec 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 401
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add version and version picker (#406)
- Loading branch information
1 parent
aebdacb
commit 11918de
Showing
10 changed files
with
96 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './version-picker'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<button mat-button [matMenuTriggerFor]="versionPicker"> | ||
{{materialVersion}} | ||
</button> | ||
<mat-menu #versionPicker="matMenu"> | ||
<button mat-menu-item *ngFor="let version of docVersions" | ||
(click)="onVersionChanged(version)"> | ||
{{version.title}} | ||
</button> | ||
</mat-menu> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import {Component, NgModule} from '@angular/core'; | ||
import {CommonModule} from '@angular/common'; | ||
import {MatButtonModule, MatMenuModule} from '@angular/material'; | ||
import {docVersions, materialVersion, VersionInfo} from '../version/version' | ||
|
||
@Component({ | ||
selector: 'version-picker', | ||
templateUrl: './version-picker.html' | ||
}) | ||
export class VersionPicker { | ||
|
||
_versionRegex = /\d+.\d+.\d+/; | ||
docVersions = docVersions; | ||
|
||
materialVersion = materialVersion; | ||
|
||
displayVersion = materialVersion.match(this._versionRegex)[0]; | ||
|
||
onVersionChanged(version: VersionInfo) { | ||
if (version.title.match(this._versionRegex)[0] !== this.displayVersion) { | ||
window.location.assign(version.url); | ||
} | ||
} | ||
} | ||
|
||
@NgModule({ | ||
imports: [MatButtonModule, MatMenuModule, CommonModule], | ||
exports: [VersionPicker], | ||
declarations: [VersionPicker] | ||
}) | ||
export class VersionPickerModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import {VERSION} from '@angular/material'; | ||
|
||
/** This material version will be used in footer and stackblitz. */ | ||
export const materialVersion = VERSION.full; | ||
|
||
/** Version information with title and redirect url */ | ||
export interface VersionInfo { | ||
url: string; | ||
title: string; | ||
} | ||
|
||
/** Doc site versions. We update the urls and titles manually */ | ||
// TODO(tinayuangao): Update the title with actual versions | ||
export const docVersions: VersionInfo[] = [ | ||
{ | ||
url: 'https://material.angular.io/', | ||
title: '5.2.4' | ||
}, | ||
{ | ||
url: `http://v5.material.angular.io`, | ||
title: '6.0.0-beta.4' | ||
} | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/bash | ||
|
||
set -eu -o pipefail | ||
|
||
declare -A PROJECT_ID | ||
|
||
#Firebase project Ids | ||
PROJECT_ID["stable", "dev"]="material2-docs-dev" | ||
PROJECT_ID["stable", "prod"]="material-angular-io" | ||
PROJECT_ID["v5", "dev"]="material2-docs-5" | ||
PROJECT_ID["v5", "prod"]="v5-material-angular-io" | ||
|
||
version=${1:-stable} | ||
mode=${2:-dev} | ||
projectId=${PROJECT_ID[$version, $mode]} | ||
|
||
npm run build-themes | ||
ng build --aot --prod | ||
firebase use $projectId | ||
firebase deploy | ||
|