forked from positive-js/mosaic
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7f33804
commit e70432d
Showing
24 changed files
with
156 additions
and
39 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import { Version } from '@angular/core'; | ||
|
||
|
||
/** Current version of the Component Development Kit. */ | ||
export const VERSION = new Version('0.0.0-PLACEHOLDER'); |
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 './style-manager'; |
47 changes: 47 additions & 0 deletions
47
packages/docs/src/app/shared/style-manager/style-manager.ts
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,47 @@ | ||
import {Injectable} from '@angular/core'; | ||
|
||
|
||
/** | ||
* Class for managing stylesheets. Stylesheets are loaded into named slots so that they can be | ||
* removed or changed later. | ||
*/ | ||
@Injectable() | ||
export class StyleManager { | ||
/** | ||
* Set the stylesheet with the specified key. | ||
*/ | ||
setStyle(key: string, href: string) { | ||
getLinkElementForKey(key).setAttribute('href', href); | ||
} | ||
|
||
/** | ||
* Remove the stylesheet with the specified key. | ||
*/ | ||
removeStyle(key: string) { | ||
const existingLinkElement = getExistingLinkElementByKey(key); | ||
if (existingLinkElement) { | ||
document.head.removeChild(existingLinkElement); | ||
} | ||
} | ||
} | ||
|
||
function getLinkElementForKey(key: string) { | ||
return getExistingLinkElementByKey(key) || createLinkElementWithKey(key); | ||
} | ||
|
||
function getExistingLinkElementByKey(key: string) { | ||
return document.head.querySelector(`link[rel="stylesheet"].${getClassNameForKey(key)}`); | ||
} | ||
|
||
function createLinkElementWithKey(key: string) { | ||
const linkEl = document.createElement('link'); | ||
linkEl.setAttribute('rel', 'stylesheet'); | ||
linkEl.classList.add(getClassNameForKey(key)); | ||
document.head.appendChild(linkEl); | ||
|
||
return linkEl; | ||
} | ||
|
||
function getClassNameForKey(key: string) { | ||
return `style-manager-${key}`; | ||
} |
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'; |
4 changes: 4 additions & 0 deletions
4
packages/docs/src/app/shared/version-picker/version-picker.html
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,4 @@ | ||
<button > | ||
{{mosaicVersion}} | ||
</button> | ||
|
38 changes: 38 additions & 0 deletions
38
packages/docs/src/app/shared/version-picker/version-picker.ts
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,38 @@ | ||
import { CommonModule } from '@angular/common'; | ||
import { HttpClient } from '@angular/common/http'; | ||
import { Component, NgModule } from '@angular/core'; | ||
import { McButtonModule } from '@ptsecurity/mosaic/button'; | ||
|
||
import { mosaicVersion, VersionInfo } from '../version/version'; | ||
|
||
|
||
const versionUrl = ''; | ||
|
||
@Component({ | ||
selector: 'version-picker', | ||
templateUrl: './version-picker.html' | ||
}) | ||
export class VersionPicker { | ||
/** The currently running versin of Material. */ | ||
mosaicVersion = mosaicVersion; | ||
/** The possible versions of the doc site. */ | ||
docVersions = this.http.get(versionUrl); | ||
|
||
constructor(private http: HttpClient) { | ||
} | ||
|
||
/** Updates the window location if the selected version is a different version. */ | ||
onVersionChanged(version: VersionInfo) { | ||
if (!version.url.startsWith(window.location.href)) { | ||
window.location.assign(version.url); | ||
} | ||
} | ||
} | ||
|
||
@NgModule({ | ||
imports: [McButtonModule, 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,11 @@ | ||
import { VERSION } from '@ptsecurity/mosaic/core'; | ||
|
||
|
||
/** This material version will be used in footer and stackblitz. */ | ||
export const mosaicVersion = VERSION.full; | ||
|
||
/** Version information with title and redirect url */ | ||
export interface VersionInfo { | ||
url: string; | ||
title: string; | ||
} |
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 @@ | ||
declare const module: {id: string}; |
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 @@ | ||
Core library code for other `@ptsecurity/mosaic` components. |
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import { Version } from '@angular/core'; | ||
|
||
|
||
/** Current version. */ | ||
export const VERSION = new Version('0.0.0-PLACEHOLDER'); |
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