-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(doc): added ability to change current tokens
- Loading branch information
Showing
14 changed files
with
707 additions
and
11 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
30 changes: 30 additions & 0 deletions
30
apps/doc/src/app/theme-token-changer/theme-token-changer.component.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,30 @@ | ||
<div #prizmTheme prizmTheme> | ||
<prizm-doc-documentation [hasTestId]="false" heading="Base variables" hostComponentKey="Base variables"> | ||
<ng-template | ||
*ngFor="let token of PRIZM_THEME_TOKEN_BASE_VARIABLES" | ||
[documentationPropertyName]="token" | ||
[documentationPropertyValue]="getTokenValue(token)" | ||
(documentationPropertyValueChange)="themeService.updateTokenValue(token, $event)" | ||
documentationPropertyType="string" | ||
documentationPropertyMode="css-var" | ||
> | ||
{{ token }} | ||
</ng-template> | ||
</prizm-doc-documentation> | ||
<prizm-doc-documentation | ||
[hasTestId]="false" | ||
heading="Palette variables" | ||
hostComponentKey="Palette variables" | ||
> | ||
<ng-template | ||
*ngFor="let token of PRIZM_THEME_TOKEN_PALETTE_VARIABLES" | ||
[documentationPropertyName]="token" | ||
[documentationPropertyValue]="getTokenValue(token)" | ||
(documentationPropertyValueChange)="themeService.updateTokenValue(token, $event)" | ||
documentationPropertyType="string" | ||
documentationPropertyMode="css-var" | ||
> | ||
{{ token }} | ||
</ng-template> | ||
</prizm-doc-documentation> | ||
</div> |
46 changes: 46 additions & 0 deletions
46
apps/doc/src/app/theme-token-changer/theme-token-changer.component.less
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,46 @@ | ||
.logo-block { | ||
margin-top: 44px; | ||
} | ||
|
||
.logo-block, | ||
.sub-text { | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
} | ||
|
||
.x-margin { | ||
margin-left: 1.25rem; | ||
margin-right: 1.25rem; | ||
} | ||
|
||
.sub-text { | ||
margin-top: 14px; | ||
color: var(--prizm-palette-gray-h750-dark); | ||
margin-bottom: 32px; | ||
text-align: left; | ||
} | ||
|
||
.icon { | ||
cursor: pointer; | ||
color: var(--prizm-text-icon-exception); | ||
|
||
&:hover { | ||
color: var(--prizm-status-info-primary-default); | ||
} | ||
} | ||
|
||
.buttons-block { | ||
display: flex; | ||
gap: 0.5rem; | ||
align-items: center; | ||
} | ||
|
||
.theme-tokens-updater { | ||
color: white; | ||
cursor: pointer; | ||
|
||
&:hover { | ||
color: var(--prizm-index-plan); | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
apps/doc/src/app/theme-token-changer/theme-token-changer.component.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,61 @@ | ||
import { ChangeDetectionStrategy, Component, ElementRef, Inject, OnInit, ViewChild } from '@angular/core'; | ||
import { | ||
PRIZM_THEME_TOKEN_BASE_VARIABLES, | ||
PRIZM_THEME_TOKEN_PALETTE_VARIABLES, | ||
PrizmThemeModule, | ||
PrizmThemeService, | ||
} from '@prizm-ui/theme'; | ||
import { LOCAL_STORAGE } from '@ng-web-apis/common'; | ||
import { | ||
PrizmIconsSvgRegistry, | ||
prizmIconSvgOtherGitHub, | ||
prizmIconSvgShapeGeometrySquareCirclePlusTriangleFill, | ||
} from '@prizm-ui/icons'; | ||
import { PrizmLanguageSwitcher } from '@prizm-ui/i18n'; | ||
import { PrizmAddonDocModule } from '@prizm-ui/doc'; | ||
import { DOCUMENT, NgFor } from '@angular/common'; | ||
|
||
@Component({ | ||
selector: 'prizm-doc-theme-token-changer', | ||
templateUrl: './theme-token-changer.component.html', | ||
styleUrls: ['./theme-token-changer.component.less'], | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
standalone: true, | ||
imports: [PrizmAddonDocModule, NgFor, PrizmThemeModule], | ||
}) | ||
export class ThemeTokenChanger implements OnInit { | ||
Check failure on line 26 in apps/doc/src/app/theme-token-changer/theme-token-changer.component.ts GitHub Actions / lint_build_test
Check failure on line 26 in apps/doc/src/app/theme-token-changer/theme-token-changer.component.ts GitHub Actions / lint_build_test
|
||
@ViewChild('prizmTheme') prizmThemeElement!: ElementRef<HTMLElement>; | ||
readonly PRIZM_THEME_TOKEN_PALETTE_VARIABLES = PRIZM_THEME_TOKEN_PALETTE_VARIABLES; | ||
readonly PRIZM_THEME_TOKEN_BASE_VARIABLES = PRIZM_THEME_TOKEN_BASE_VARIABLES; | ||
readonly mapValue = new Map<string, string>(); | ||
|
||
constructor( | ||
public readonly themeService: PrizmThemeService, | ||
@Inject(DOCUMENT) public readonly document: Document, | ||
private readonly svgRegistry: PrizmIconsSvgRegistry | ||
) { | ||
this.svgRegistry.registerIcons([ | ||
prizmIconSvgOtherGitHub, | ||
prizmIconSvgShapeGeometrySquareCirclePlusTriangleFill, | ||
]); | ||
} | ||
|
||
ngOnInit(): void { | ||
this.init(); | ||
} | ||
|
||
public getTokenValue(token: string): string { | ||
return this.mapValue.get(token) ?? ''; | ||
} | ||
|
||
private init() { | ||
this.addTokenValueToMap(PRIZM_THEME_TOKEN_PALETTE_VARIABLES); | ||
this.addTokenValueToMap(PRIZM_THEME_TOKEN_BASE_VARIABLES); | ||
} | ||
|
||
private addTokenValueToMap(tokens: string[]) { | ||
tokens.forEach((token: string) => { | ||
this.mapValue.set(token, this.themeService.getTokenValue(token) ?? ''); | ||
}); | ||
} | ||
} |
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,3 +1,4 @@ | ||
export * from './lib/services'; | ||
export * from './lib/types'; | ||
export * from './lib/directive'; | ||
export * from './lib/const'; |
Oops, something went wrong.