ngx-dev-toolbar 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/button/button.component.d.ts +12 -0
- package/components/card/card.component.d.ts +8 -0
- package/components/clickable-card/clickable-card.component.d.ts +11 -0
- package/components/icons/angular-icon.component.d.ts +5 -0
- package/components/icons/bug-icon.component.d.ts +6 -0
- package/components/icons/code-icon.component.d.ts +6 -0
- package/components/icons/database-icon.component.d.ts +6 -0
- package/components/icons/discord-icon.component.d.ts +6 -0
- package/components/icons/docs-icon.component.d.ts +6 -0
- package/components/icons/export-icon.component.d.ts +6 -0
- package/components/icons/gauge-icon.component.d.ts +6 -0
- package/components/icons/gear-icon.component.d.ts +6 -0
- package/components/icons/git-branch-icon.component.d.ts +6 -0
- package/components/icons/icon.component.d.ts +9 -0
- package/components/icons/icon.models.d.ts +1 -0
- package/components/icons/import-icon.component.d.ts +6 -0
- package/components/icons/layout-icon.component.d.ts +6 -0
- package/components/icons/lightbulb-icon.component.d.ts +6 -0
- package/components/icons/lighting-icon.component.d.ts +6 -0
- package/components/icons/moon-icon.component.d.ts +6 -0
- package/components/icons/network-icon.component.d.ts +6 -0
- package/components/icons/puzzle-icon.component.d.ts +6 -0
- package/components/icons/refresh-icon.component.d.ts +6 -0
- package/components/icons/star-icon.component.d.ts +6 -0
- package/components/icons/sun-icon.component.d.ts +6 -0
- package/components/icons/terminal-icon.component.d.ts +6 -0
- package/components/icons/toggle-left-icon.component.d.ts +6 -0
- package/components/icons/translate-icon.component.d.ts +6 -0
- package/components/icons/trash-icon.component.d.ts +6 -0
- package/components/icons/users-icon.component.d.ts +6 -0
- package/components/input/input.component.d.ts +10 -0
- package/components/link-button/link-button.component.d.ts +8 -0
- package/components/select/select.component.d.ts +25 -0
- package/components/tool-button/tool-button.component.d.ts +23 -0
- package/components/toolbar-tool/toolbar-tool.component.d.ts +30 -0
- package/components/toolbar-tool/toolbar-tool.models.d.ts +25 -0
- package/components/window/window.component.d.ts +16 -0
- package/dev-toolbar-state.service.d.ts +21 -0
- package/dev-toolbar.component.d.ts +18 -0
- package/fesm2022/ngx-dev-toolbar.mjs +3039 -0
- package/fesm2022/ngx-dev-toolbar.mjs.map +1 -0
- package/models/dev-tools.interface.d.ts +17 -0
- package/package.json +32 -9
- package/tools/feature-flags-tool/feature-flags-internal.service.d.ts +21 -0
- package/tools/feature-flags-tool/feature-flags-tool.component.d.ts +27 -0
- package/tools/feature-flags-tool/feature-flags.models.d.ts +9 -0
- package/tools/feature-flags-tool/feature-flags.service.d.ts +19 -0
- package/tools/home-tool/home-tool.component.d.ts +38 -0
- package/{src/tools/home-tool/settings.models.ts → tools/home-tool/settings.models.d.ts} +1 -1
- package/tools/home-tool/settings.service.d.ts +10 -0
- package/tools/language-tool/language-internal.service.d.ts +19 -0
- package/tools/language-tool/language-tool.component.d.ts +14 -0
- package/tools/language-tool/language.models.d.ts +4 -0
- package/tools/language-tool/language.service.d.ts +19 -0
- package/utils/storage.service.d.ts +18 -0
- package/eslint.config.cjs +0 -47
- package/ng-package.json +0 -7
- package/project.json +0 -37
- package/src/components/button/button.component.scss +0 -49
- package/src/components/button/button.component.ts +0 -36
- package/src/components/card/card.component.scss +0 -18
- package/src/components/card/card.component.ts +0 -30
- package/src/components/clickable-card/clickable-card.component.scss +0 -39
- package/src/components/clickable-card/clickable-card.component.ts +0 -34
- package/src/components/icons/angular-icon.component.ts +0 -35
- package/src/components/icons/bug-icon.component.ts +0 -23
- package/src/components/icons/code-icon.component.ts +0 -24
- package/src/components/icons/database-icon.component.ts +0 -27
- package/src/components/icons/discord-icon.component.ts +0 -23
- package/src/components/icons/docs-icon.component.ts +0 -23
- package/src/components/icons/export-icon.component.ts +0 -23
- package/src/components/icons/gauge-icon.component.ts +0 -27
- package/src/components/icons/gear-icon.component.ts +0 -27
- package/src/components/icons/git-branch-icon.component.ts +0 -27
- package/src/components/icons/icon.component.ts +0 -129
- package/src/components/icons/icon.models.ts +0 -27
- package/src/components/icons/import-icon.component.ts +0 -23
- package/src/components/icons/layout-icon.component.ts +0 -24
- package/src/components/icons/lightbulb-icon.component.ts +0 -23
- package/src/components/icons/lighting-icon.component.ts +0 -24
- package/src/components/icons/moon-icon.component.ts +0 -27
- package/src/components/icons/network-icon.component.ts +0 -27
- package/src/components/icons/puzzle-icon.component.ts +0 -27
- package/src/components/icons/refresh-icon.component.ts +0 -27
- package/src/components/icons/star-icon.component.ts +0 -27
- package/src/components/icons/sun-icon.component.ts +0 -27
- package/src/components/icons/terminal-icon.component.ts +0 -27
- package/src/components/icons/toggle-left-icon.component.ts +0 -27
- package/src/components/icons/translate-icon.component.ts +0 -23
- package/src/components/icons/trash-icon.component.ts +0 -23
- package/src/components/icons/users-icon.component.ts +0 -27
- package/src/components/input/input.component.ts +0 -67
- package/src/components/link-button/link-button.component.scss +0 -36
- package/src/components/link-button/link-button.component.ts +0 -29
- package/src/components/select/select.component.scss +0 -162
- package/src/components/select/select.component.ts +0 -127
- package/src/components/tool-button/tool-button.component.scss +0 -67
- package/src/components/tool-button/tool-button.component.ts +0 -126
- package/src/components/toolbar-tool/toolbar-tool.component.scss +0 -9
- package/src/components/toolbar-tool/toolbar-tool.component.ts +0 -169
- package/src/components/toolbar-tool/toolbar-tool.models.ts +0 -33
- package/src/components/window/window.component.scss +0 -95
- package/src/components/window/window.component.ts +0 -69
- package/src/dev-toolbar-state.service.ts +0 -89
- package/src/dev-toolbar.component.scss +0 -22
- package/src/dev-toolbar.component.ts +0 -105
- package/src/models/dev-tools.interface.ts +0 -19
- package/src/styles.scss +0 -342
- package/src/test-setup.ts +0 -12
- package/src/tools/feature-flags-tool/feature-flags-internal.service.ts +0 -96
- package/src/tools/feature-flags-tool/feature-flags-tool.component.ts +0 -261
- package/src/tools/feature-flags-tool/feature-flags.models.ts +0 -10
- package/src/tools/feature-flags-tool/feature-flags.service.ts +0 -28
- package/src/tools/home-tool/home-tool.component.scss +0 -67
- package/src/tools/home-tool/home-tool.component.ts +0 -197
- package/src/tools/home-tool/settings.service.spec.ts +0 -59
- package/src/tools/home-tool/settings.service.ts +0 -21
- package/src/tools/language-tool/language-internal.service.ts +0 -51
- package/src/tools/language-tool/language-tool.component.scss +0 -7
- package/src/tools/language-tool/language-tool.component.ts +0 -71
- package/src/tools/language-tool/language.models.ts +0 -4
- package/src/tools/language-tool/language.service.ts +0 -26
- package/src/utils/storage.service.spec.ts +0 -179
- package/src/utils/storage.service.ts +0 -80
- package/tsconfig.json +0 -28
- package/tsconfig.lib.json +0 -28
- package/tsconfig.lib.prod.json +0 -9
- package/tsconfig.spec.json +0 -29
- package/vite.config.mts +0 -27
- /package/{src/index.ts → index.d.ts} +0 -0
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { IconName } from '../icons/icon.models';
|
|
2
|
-
|
|
3
|
-
export interface DevToolbarWindowPosition {
|
|
4
|
-
x: number;
|
|
5
|
-
y: number;
|
|
6
|
-
}
|
|
7
|
-
export interface DevToolbarWindowOptions {
|
|
8
|
-
id: string;
|
|
9
|
-
/**
|
|
10
|
-
* The title of the window, this can be different from the name of the tool
|
|
11
|
-
*/
|
|
12
|
-
title: string;
|
|
13
|
-
description?: string;
|
|
14
|
-
isClosable?: boolean;
|
|
15
|
-
isMaximizable?: boolean;
|
|
16
|
-
isMinimizable?: boolean;
|
|
17
|
-
placement?:
|
|
18
|
-
| 'bottom-left'
|
|
19
|
-
| 'bottom-center'
|
|
20
|
-
| 'bottom-right'
|
|
21
|
-
| 'top-left'
|
|
22
|
-
| 'top-center'
|
|
23
|
-
| 'top-right';
|
|
24
|
-
size?: 'small' | 'medium' | 'tall' | 'large';
|
|
25
|
-
isBeta?: boolean;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export interface DevToolbarToolOptions {
|
|
29
|
-
icon: IconName;
|
|
30
|
-
name: string;
|
|
31
|
-
windowOptions: DevToolbarWindowOptions;
|
|
32
|
-
isBeta?: boolean;
|
|
33
|
-
}
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
@use '../../styles' as *;
|
|
2
|
-
@use 'sass:map';
|
|
3
|
-
|
|
4
|
-
:host {
|
|
5
|
-
display: block;
|
|
6
|
-
width: 100%;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
.window {
|
|
10
|
-
box-sizing: border-box;
|
|
11
|
-
display: flex;
|
|
12
|
-
flex-direction: column;
|
|
13
|
-
width: 100%;
|
|
14
|
-
height: 100%;
|
|
15
|
-
background: var(--ndt-bg-primary);
|
|
16
|
-
border: 1px solid var(--ndt-border-primary);
|
|
17
|
-
border-radius: var(--ndt-border-radius-large);
|
|
18
|
-
padding: var(--ndt-window-padding);
|
|
19
|
-
font-family: $font-family;
|
|
20
|
-
color: var(--ndt-text-secondary);
|
|
21
|
-
z-index: #{map.get($z-indices, window)};
|
|
22
|
-
box-shadow: var(--ndt-shadow-window);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.header {
|
|
26
|
-
display: flex;
|
|
27
|
-
flex-direction: row;
|
|
28
|
-
justify-content: space-between;
|
|
29
|
-
align-items: flex-start;
|
|
30
|
-
|
|
31
|
-
&__title {
|
|
32
|
-
display: flex;
|
|
33
|
-
align-items: center;
|
|
34
|
-
gap: var(--ndt-spacing-sm);
|
|
35
|
-
|
|
36
|
-
.beta-tag {
|
|
37
|
-
font-size: var(--ndt-font-size-xxs, 0.65rem);
|
|
38
|
-
background: var(--ndt-purple, #8b5cf6);
|
|
39
|
-
color: var(--ndt-text-on-primary);
|
|
40
|
-
padding: 1px 4px;
|
|
41
|
-
margin-left: var(--ndt-spacing-xs);
|
|
42
|
-
border-radius: var(--ndt-border-radius-small);
|
|
43
|
-
font-weight: 500;
|
|
44
|
-
text-transform: uppercase;
|
|
45
|
-
letter-spacing: 0.5px;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
&__description {
|
|
49
|
-
font-size: var(--ndt-font-size-sm);
|
|
50
|
-
color: var(--ndt-text-muted);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
&__content {
|
|
54
|
-
display: flex;
|
|
55
|
-
flex-direction: column;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
&__controls {
|
|
59
|
-
display: flex;
|
|
60
|
-
gap: var(--ndt-spacing-sm);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
.content {
|
|
65
|
-
flex: 1;
|
|
66
|
-
overflow: auto;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
.divider {
|
|
70
|
-
height: 1px;
|
|
71
|
-
background-color: var(--ndt-border-primary);
|
|
72
|
-
margin-bottom: var(--ndt-spacing-md);
|
|
73
|
-
margin-top: var(--ndt-spacing-md);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
.control {
|
|
77
|
-
background: none;
|
|
78
|
-
border: none;
|
|
79
|
-
color: var(--ndt-text-secondary);
|
|
80
|
-
cursor: pointer;
|
|
81
|
-
padding: var(--ndt-spacing-xs) var(--ndt-spacing-sm);
|
|
82
|
-
border-radius: var(--ndt-border-radius-small);
|
|
83
|
-
font-size: var(--ndt-font-size-md);
|
|
84
|
-
line-height: 1;
|
|
85
|
-
transition: var(--ndt-transition-smooth);
|
|
86
|
-
|
|
87
|
-
&:hover {
|
|
88
|
-
background: var(--ndt-hover-bg);
|
|
89
|
-
color: var(--ndt-text-primary);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
&--close:hover {
|
|
93
|
-
background: var(--ndt-hover-danger);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { Component, computed, inject, input, output } from '@angular/core';
|
|
2
|
-
import { DevToolbarStateService } from '../../dev-toolbar-state.service';
|
|
3
|
-
import { DevToolbarWindowOptions } from '../toolbar-tool/toolbar-tool.models';
|
|
4
|
-
|
|
5
|
-
@Component({
|
|
6
|
-
selector: 'ndt-window',
|
|
7
|
-
standalone: true,
|
|
8
|
-
template: `
|
|
9
|
-
<div class="window dev-toolbar" [attr.data-theme]="theme()">
|
|
10
|
-
<div class="header">
|
|
11
|
-
<div class="header__content">
|
|
12
|
-
<div class="header__title">
|
|
13
|
-
<h1>{{ config().title }}</h1>
|
|
14
|
-
@if (config().isBeta) {
|
|
15
|
-
<span class="beta-tag">BETA</span>
|
|
16
|
-
}
|
|
17
|
-
</div>
|
|
18
|
-
<p class="header__description">{{ config().description }}</p>
|
|
19
|
-
</div>
|
|
20
|
-
<div class="header__controls">
|
|
21
|
-
@if (config().isMinimizable) {
|
|
22
|
-
<button aria-label="Minimize" class="control" (click)="onMinimize()">
|
|
23
|
-
−
|
|
24
|
-
</button>
|
|
25
|
-
} @if (config().isMaximizable) {
|
|
26
|
-
<button aria-label="Maximize" class="control" (click)="onMaximize()">
|
|
27
|
-
□
|
|
28
|
-
</button>
|
|
29
|
-
} @if (config().isClosable) {
|
|
30
|
-
<button
|
|
31
|
-
aria-label="Close"
|
|
32
|
-
class="control control--close"
|
|
33
|
-
(click)="onClose()"
|
|
34
|
-
>
|
|
35
|
-
×
|
|
36
|
-
</button>
|
|
37
|
-
}
|
|
38
|
-
</div>
|
|
39
|
-
</div>
|
|
40
|
-
|
|
41
|
-
<div class="divider"></div>
|
|
42
|
-
<div class="content">
|
|
43
|
-
<ng-content></ng-content>
|
|
44
|
-
</div>
|
|
45
|
-
</div>
|
|
46
|
-
`,
|
|
47
|
-
styleUrls: ['./window.component.scss'],
|
|
48
|
-
})
|
|
49
|
-
export class DevToolbarWindowComponent {
|
|
50
|
-
readonly devToolbarStateService = inject(DevToolbarStateService);
|
|
51
|
-
readonly config = input.required<DevToolbarWindowOptions>();
|
|
52
|
-
readonly close = output<void>();
|
|
53
|
-
readonly maximize = output<void>();
|
|
54
|
-
readonly minimize = output<void>();
|
|
55
|
-
|
|
56
|
-
readonly theme = computed(() => this.devToolbarStateService.theme());
|
|
57
|
-
|
|
58
|
-
protected onClose(): void {
|
|
59
|
-
this.close.emit();
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
protected onMaximize(): void {
|
|
63
|
-
this.maximize.emit();
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
protected onMinimize(): void {
|
|
67
|
-
this.minimize.emit();
|
|
68
|
-
}
|
|
69
|
-
}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { Injectable, computed, signal } from '@angular/core';
|
|
2
|
-
|
|
3
|
-
interface DevToolbarState {
|
|
4
|
-
isHidden: boolean;
|
|
5
|
-
activeToolId: string | null;
|
|
6
|
-
error: string | null;
|
|
7
|
-
theme: 'light' | 'dark';
|
|
8
|
-
delay: number;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
@Injectable({
|
|
12
|
-
providedIn: 'root',
|
|
13
|
-
})
|
|
14
|
-
export class DevToolbarStateService {
|
|
15
|
-
// Initial state
|
|
16
|
-
private state = signal<DevToolbarState>({
|
|
17
|
-
isHidden: true,
|
|
18
|
-
activeToolId: null,
|
|
19
|
-
delay: 3000,
|
|
20
|
-
error: null,
|
|
21
|
-
theme: 'dark',
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
// Selectors
|
|
25
|
-
readonly isVisible = computed(
|
|
26
|
-
() => !this.state().isHidden || this.hasActiveTool()
|
|
27
|
-
);
|
|
28
|
-
readonly isDarkTheme = computed(() => this.state().theme === 'dark');
|
|
29
|
-
readonly activeToolId = computed(() => this.state().activeToolId);
|
|
30
|
-
readonly hasActiveTool = computed(() => this.state().activeToolId !== null);
|
|
31
|
-
readonly error = computed(() => this.state().error);
|
|
32
|
-
readonly theme = computed(() => this.state().theme);
|
|
33
|
-
/**
|
|
34
|
-
* The delay to hide the toolbar
|
|
35
|
-
*/
|
|
36
|
-
readonly delay = computed(() => this.state().delay);
|
|
37
|
-
|
|
38
|
-
// State updates
|
|
39
|
-
setVisibility(isVisible: boolean): void {
|
|
40
|
-
if (isVisible) {
|
|
41
|
-
this.state.update((state) => ({
|
|
42
|
-
...state,
|
|
43
|
-
isHidden: false,
|
|
44
|
-
}));
|
|
45
|
-
} else {
|
|
46
|
-
if (this.activeToolId() === null) {
|
|
47
|
-
setTimeout(() => {
|
|
48
|
-
this.state.update((state) => ({
|
|
49
|
-
...state,
|
|
50
|
-
isHidden: true,
|
|
51
|
-
}));
|
|
52
|
-
}, this.state().delay);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
setTheme(theme: 'light' | 'dark'): void {
|
|
58
|
-
this.state.update((state) => ({
|
|
59
|
-
...state,
|
|
60
|
-
theme,
|
|
61
|
-
}));
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
setActiveTool(toolId: string | null): void {
|
|
65
|
-
this.state.update((state) => ({
|
|
66
|
-
...state,
|
|
67
|
-
activeToolId: toolId,
|
|
68
|
-
}));
|
|
69
|
-
|
|
70
|
-
if (toolId === null) {
|
|
71
|
-
this.setVisibility(false);
|
|
72
|
-
} else {
|
|
73
|
-
this.setVisibility(true);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// Public actions
|
|
78
|
-
toggleTool(toolId: string | null): void {
|
|
79
|
-
const currentToolId = this.activeToolId();
|
|
80
|
-
this.setActiveTool(currentToolId === toolId ? null : toolId);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
toggleVisibility(): void {
|
|
84
|
-
this.state.update((state) => ({
|
|
85
|
-
...state,
|
|
86
|
-
isHidden: !state.isHidden,
|
|
87
|
-
}));
|
|
88
|
-
}
|
|
89
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
@use './styles' as devtools;
|
|
2
|
-
@use 'sass:map';
|
|
3
|
-
|
|
4
|
-
.dev-toolbar {
|
|
5
|
-
position: fixed;
|
|
6
|
-
bottom: 0;
|
|
7
|
-
left: 50%;
|
|
8
|
-
z-index: map.get(devtools.$z-indices, toolbar);
|
|
9
|
-
transform: translateX(-50%);
|
|
10
|
-
display: flex;
|
|
11
|
-
pointer-events: auto;
|
|
12
|
-
background: var(--ndt-bg-primary);
|
|
13
|
-
border: 1px solid var(--ndt-border-primary);
|
|
14
|
-
border-radius: map.get(map.get(devtools.$dimensions, border-radius), full);
|
|
15
|
-
box-shadow: var(--ndt-shadow-toolbar);
|
|
16
|
-
height: map.get(devtools.$dimensions, toolbar-height);
|
|
17
|
-
overflow: hidden;
|
|
18
|
-
|
|
19
|
-
&--active {
|
|
20
|
-
opacity: 1;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
animate,
|
|
3
|
-
state,
|
|
4
|
-
style,
|
|
5
|
-
transition,
|
|
6
|
-
trigger,
|
|
7
|
-
} from '@angular/animations';
|
|
8
|
-
import {
|
|
9
|
-
Component,
|
|
10
|
-
DestroyRef,
|
|
11
|
-
OnInit,
|
|
12
|
-
inject,
|
|
13
|
-
isDevMode,
|
|
14
|
-
} from '@angular/core';
|
|
15
|
-
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
16
|
-
import { fromEvent } from 'rxjs';
|
|
17
|
-
import { filter, throttleTime } from 'rxjs/operators';
|
|
18
|
-
import { DevToolbarStateService } from './dev-toolbar-state.service';
|
|
19
|
-
import { DevToolbarFeatureFlagsToolComponent } from './tools/feature-flags-tool/feature-flags-tool.component';
|
|
20
|
-
import { DevToolbarHomeToolComponent } from './tools/home-tool/home-tool.component';
|
|
21
|
-
import { SettingsService } from './tools/home-tool/settings.service';
|
|
22
|
-
import { DevToolbarLanguageToolComponent } from './tools/language-tool/language-tool.component';
|
|
23
|
-
|
|
24
|
-
@Component({
|
|
25
|
-
standalone: true,
|
|
26
|
-
selector: 'ndt-toolbar',
|
|
27
|
-
styleUrls: ['./dev-toolbar.component.scss'],
|
|
28
|
-
imports: [
|
|
29
|
-
DevToolbarHomeToolComponent,
|
|
30
|
-
DevToolbarLanguageToolComponent,
|
|
31
|
-
DevToolbarFeatureFlagsToolComponent,
|
|
32
|
-
],
|
|
33
|
-
template: `
|
|
34
|
-
@if (isDevMode) {
|
|
35
|
-
<div
|
|
36
|
-
aria-label="Developer tools"
|
|
37
|
-
role="toolbar"
|
|
38
|
-
class="dev-toolbar"
|
|
39
|
-
[@toolbarState]="state.isVisible() ? 'visible' : 'hidden'"
|
|
40
|
-
[attr.data-theme]="state.theme()"
|
|
41
|
-
[class.dev-toolbar--active]="state.isVisible()"
|
|
42
|
-
(mouseenter)="onMouseEnter()"
|
|
43
|
-
>
|
|
44
|
-
<ndt-home-tool />
|
|
45
|
-
<ndt-language-tool />
|
|
46
|
-
<ndt-feature-flags-tool />
|
|
47
|
-
<ng-content />
|
|
48
|
-
</div>
|
|
49
|
-
}
|
|
50
|
-
`,
|
|
51
|
-
animations: [
|
|
52
|
-
trigger('toolbarState', [
|
|
53
|
-
state(
|
|
54
|
-
'hidden',
|
|
55
|
-
style({
|
|
56
|
-
transform: 'translate(-50%, calc(100% + -1.2rem))',
|
|
57
|
-
})
|
|
58
|
-
),
|
|
59
|
-
state(
|
|
60
|
-
'visible',
|
|
61
|
-
style({
|
|
62
|
-
transform: 'translate(-50%, -1rem)',
|
|
63
|
-
})
|
|
64
|
-
),
|
|
65
|
-
transition('hidden <=> visible', [
|
|
66
|
-
animate('300ms cubic-bezier(0.4, 0, 0.2, 1)'),
|
|
67
|
-
]),
|
|
68
|
-
]),
|
|
69
|
-
],
|
|
70
|
-
})
|
|
71
|
-
export class DevToolbarComponent implements OnInit {
|
|
72
|
-
state = inject(DevToolbarStateService);
|
|
73
|
-
destroyRef = inject(DestroyRef);
|
|
74
|
-
settingsService = inject(SettingsService);
|
|
75
|
-
|
|
76
|
-
isDevMode = isDevMode();
|
|
77
|
-
|
|
78
|
-
private keyboardShortcut = fromEvent<KeyboardEvent>(window, 'keydown')
|
|
79
|
-
.pipe(
|
|
80
|
-
filter((event) => event.ctrlKey && event.shiftKey && event.key === 'D'),
|
|
81
|
-
takeUntilDestroyed(this.destroyRef)
|
|
82
|
-
)
|
|
83
|
-
.subscribe(() => this.toggleDevTools());
|
|
84
|
-
|
|
85
|
-
private mouseLeave = fromEvent<MouseEvent>(document, 'mouseleave')
|
|
86
|
-
.pipe(throttleTime(3000), takeUntilDestroyed(this.destroyRef))
|
|
87
|
-
.subscribe(() => this.onMouseLeave());
|
|
88
|
-
|
|
89
|
-
ngOnInit(): void {
|
|
90
|
-
const settings = this.settingsService.getSettings();
|
|
91
|
-
this.state.setTheme(settings.isDarkMode ? 'dark' : 'light');
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
onMouseEnter(): void {
|
|
95
|
-
this.state.setVisibility(true);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
onMouseLeave(): void {
|
|
99
|
-
setTimeout(() => this.state.setVisibility(false), this.state.delay());
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
private toggleDevTools(): void {
|
|
103
|
-
this.state.setVisibility(!this.state.isVisible());
|
|
104
|
-
}
|
|
105
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Observable } from 'rxjs';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Interface that should be implemented by any tool service that is used in the dev toolbar
|
|
5
|
-
*/
|
|
6
|
-
export interface DevToolsService<OptionType> {
|
|
7
|
-
/**
|
|
8
|
-
* Sets the available options that will be displayed in the tool on the dev toolbar
|
|
9
|
-
* @param options The options to be displayed
|
|
10
|
-
*/
|
|
11
|
-
setAvailableOptions(options: OptionType[]): void;
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Gets the values that were forced/modified through the tool on the dev toolbar.
|
|
15
|
-
* If the tool only supports a single option, the returned array will have a single element.
|
|
16
|
-
* @returns Observable of forced values array
|
|
17
|
-
*/
|
|
18
|
-
getForcedValues(): Observable<OptionType[]>;
|
|
19
|
-
}
|