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.
Files changed (130) hide show
  1. package/components/button/button.component.d.ts +12 -0
  2. package/components/card/card.component.d.ts +8 -0
  3. package/components/clickable-card/clickable-card.component.d.ts +11 -0
  4. package/components/icons/angular-icon.component.d.ts +5 -0
  5. package/components/icons/bug-icon.component.d.ts +6 -0
  6. package/components/icons/code-icon.component.d.ts +6 -0
  7. package/components/icons/database-icon.component.d.ts +6 -0
  8. package/components/icons/discord-icon.component.d.ts +6 -0
  9. package/components/icons/docs-icon.component.d.ts +6 -0
  10. package/components/icons/export-icon.component.d.ts +6 -0
  11. package/components/icons/gauge-icon.component.d.ts +6 -0
  12. package/components/icons/gear-icon.component.d.ts +6 -0
  13. package/components/icons/git-branch-icon.component.d.ts +6 -0
  14. package/components/icons/icon.component.d.ts +9 -0
  15. package/components/icons/icon.models.d.ts +1 -0
  16. package/components/icons/import-icon.component.d.ts +6 -0
  17. package/components/icons/layout-icon.component.d.ts +6 -0
  18. package/components/icons/lightbulb-icon.component.d.ts +6 -0
  19. package/components/icons/lighting-icon.component.d.ts +6 -0
  20. package/components/icons/moon-icon.component.d.ts +6 -0
  21. package/components/icons/network-icon.component.d.ts +6 -0
  22. package/components/icons/puzzle-icon.component.d.ts +6 -0
  23. package/components/icons/refresh-icon.component.d.ts +6 -0
  24. package/components/icons/star-icon.component.d.ts +6 -0
  25. package/components/icons/sun-icon.component.d.ts +6 -0
  26. package/components/icons/terminal-icon.component.d.ts +6 -0
  27. package/components/icons/toggle-left-icon.component.d.ts +6 -0
  28. package/components/icons/translate-icon.component.d.ts +6 -0
  29. package/components/icons/trash-icon.component.d.ts +6 -0
  30. package/components/icons/users-icon.component.d.ts +6 -0
  31. package/components/input/input.component.d.ts +10 -0
  32. package/components/link-button/link-button.component.d.ts +8 -0
  33. package/components/select/select.component.d.ts +25 -0
  34. package/components/tool-button/tool-button.component.d.ts +23 -0
  35. package/components/toolbar-tool/toolbar-tool.component.d.ts +30 -0
  36. package/components/toolbar-tool/toolbar-tool.models.d.ts +25 -0
  37. package/components/window/window.component.d.ts +16 -0
  38. package/dev-toolbar-state.service.d.ts +21 -0
  39. package/dev-toolbar.component.d.ts +18 -0
  40. package/fesm2022/ngx-dev-toolbar.mjs +3039 -0
  41. package/fesm2022/ngx-dev-toolbar.mjs.map +1 -0
  42. package/models/dev-tools.interface.d.ts +17 -0
  43. package/package.json +32 -9
  44. package/tools/feature-flags-tool/feature-flags-internal.service.d.ts +21 -0
  45. package/tools/feature-flags-tool/feature-flags-tool.component.d.ts +27 -0
  46. package/tools/feature-flags-tool/feature-flags.models.d.ts +9 -0
  47. package/tools/feature-flags-tool/feature-flags.service.d.ts +19 -0
  48. package/tools/home-tool/home-tool.component.d.ts +38 -0
  49. package/{src/tools/home-tool/settings.models.ts → tools/home-tool/settings.models.d.ts} +1 -1
  50. package/tools/home-tool/settings.service.d.ts +10 -0
  51. package/tools/language-tool/language-internal.service.d.ts +19 -0
  52. package/tools/language-tool/language-tool.component.d.ts +14 -0
  53. package/tools/language-tool/language.models.d.ts +4 -0
  54. package/tools/language-tool/language.service.d.ts +19 -0
  55. package/utils/storage.service.d.ts +18 -0
  56. package/eslint.config.cjs +0 -47
  57. package/ng-package.json +0 -7
  58. package/project.json +0 -37
  59. package/src/components/button/button.component.scss +0 -49
  60. package/src/components/button/button.component.ts +0 -36
  61. package/src/components/card/card.component.scss +0 -18
  62. package/src/components/card/card.component.ts +0 -30
  63. package/src/components/clickable-card/clickable-card.component.scss +0 -39
  64. package/src/components/clickable-card/clickable-card.component.ts +0 -34
  65. package/src/components/icons/angular-icon.component.ts +0 -35
  66. package/src/components/icons/bug-icon.component.ts +0 -23
  67. package/src/components/icons/code-icon.component.ts +0 -24
  68. package/src/components/icons/database-icon.component.ts +0 -27
  69. package/src/components/icons/discord-icon.component.ts +0 -23
  70. package/src/components/icons/docs-icon.component.ts +0 -23
  71. package/src/components/icons/export-icon.component.ts +0 -23
  72. package/src/components/icons/gauge-icon.component.ts +0 -27
  73. package/src/components/icons/gear-icon.component.ts +0 -27
  74. package/src/components/icons/git-branch-icon.component.ts +0 -27
  75. package/src/components/icons/icon.component.ts +0 -129
  76. package/src/components/icons/icon.models.ts +0 -27
  77. package/src/components/icons/import-icon.component.ts +0 -23
  78. package/src/components/icons/layout-icon.component.ts +0 -24
  79. package/src/components/icons/lightbulb-icon.component.ts +0 -23
  80. package/src/components/icons/lighting-icon.component.ts +0 -24
  81. package/src/components/icons/moon-icon.component.ts +0 -27
  82. package/src/components/icons/network-icon.component.ts +0 -27
  83. package/src/components/icons/puzzle-icon.component.ts +0 -27
  84. package/src/components/icons/refresh-icon.component.ts +0 -27
  85. package/src/components/icons/star-icon.component.ts +0 -27
  86. package/src/components/icons/sun-icon.component.ts +0 -27
  87. package/src/components/icons/terminal-icon.component.ts +0 -27
  88. package/src/components/icons/toggle-left-icon.component.ts +0 -27
  89. package/src/components/icons/translate-icon.component.ts +0 -23
  90. package/src/components/icons/trash-icon.component.ts +0 -23
  91. package/src/components/icons/users-icon.component.ts +0 -27
  92. package/src/components/input/input.component.ts +0 -67
  93. package/src/components/link-button/link-button.component.scss +0 -36
  94. package/src/components/link-button/link-button.component.ts +0 -29
  95. package/src/components/select/select.component.scss +0 -162
  96. package/src/components/select/select.component.ts +0 -127
  97. package/src/components/tool-button/tool-button.component.scss +0 -67
  98. package/src/components/tool-button/tool-button.component.ts +0 -126
  99. package/src/components/toolbar-tool/toolbar-tool.component.scss +0 -9
  100. package/src/components/toolbar-tool/toolbar-tool.component.ts +0 -169
  101. package/src/components/toolbar-tool/toolbar-tool.models.ts +0 -33
  102. package/src/components/window/window.component.scss +0 -95
  103. package/src/components/window/window.component.ts +0 -69
  104. package/src/dev-toolbar-state.service.ts +0 -89
  105. package/src/dev-toolbar.component.scss +0 -22
  106. package/src/dev-toolbar.component.ts +0 -105
  107. package/src/models/dev-tools.interface.ts +0 -19
  108. package/src/styles.scss +0 -342
  109. package/src/test-setup.ts +0 -12
  110. package/src/tools/feature-flags-tool/feature-flags-internal.service.ts +0 -96
  111. package/src/tools/feature-flags-tool/feature-flags-tool.component.ts +0 -261
  112. package/src/tools/feature-flags-tool/feature-flags.models.ts +0 -10
  113. package/src/tools/feature-flags-tool/feature-flags.service.ts +0 -28
  114. package/src/tools/home-tool/home-tool.component.scss +0 -67
  115. package/src/tools/home-tool/home-tool.component.ts +0 -197
  116. package/src/tools/home-tool/settings.service.spec.ts +0 -59
  117. package/src/tools/home-tool/settings.service.ts +0 -21
  118. package/src/tools/language-tool/language-internal.service.ts +0 -51
  119. package/src/tools/language-tool/language-tool.component.scss +0 -7
  120. package/src/tools/language-tool/language-tool.component.ts +0 -71
  121. package/src/tools/language-tool/language.models.ts +0 -4
  122. package/src/tools/language-tool/language.service.ts +0 -26
  123. package/src/utils/storage.service.spec.ts +0 -179
  124. package/src/utils/storage.service.ts +0 -80
  125. package/tsconfig.json +0 -28
  126. package/tsconfig.lib.json +0 -28
  127. package/tsconfig.lib.prod.json +0 -9
  128. package/tsconfig.spec.json +0 -29
  129. package/vite.config.mts +0 -27
  130. /package/{src/index.ts → index.d.ts} +0 -0
@@ -1,29 +0,0 @@
1
- import { Component, input } from '@angular/core';
2
- import { DevToolbarIconComponent } from '../icons/icon.component';
3
- import { IconName } from '../icons/icon.models';
4
-
5
- @Component({
6
- selector: 'ndt-link-button',
7
- standalone: true,
8
- imports: [DevToolbarIconComponent],
9
- template: `
10
- <a
11
- [href]="url()"
12
- target="_blank"
13
- rel="noopener noreferrer"
14
- class="link-button"
15
- >
16
- <div class="link-button__icon">
17
- <ndt-icon [name]="icon()" />
18
- </div>
19
- <span class="link-button__text">
20
- <ng-content></ng-content>
21
- </span>
22
- </a>
23
- `,
24
- styleUrls: ['./link-button.component.scss'],
25
- })
26
- export class DevToolbarLinkButtonComponent {
27
- readonly url = input.required<string>();
28
- readonly icon = input.required<IconName>();
29
- }
@@ -1,162 +0,0 @@
1
- @use '../../styles' as devtools;
2
- @use 'sass:map';
3
-
4
- .select {
5
- position: relative;
6
- width: 100%;
7
- min-width: 120px;
8
- display: flex;
9
- align-items: center;
10
- justify-content: space-between;
11
- padding: var(--ndt-spacing-sm) var(--ndt-spacing-md);
12
- border: 1px solid var(--ndt-border-primary);
13
- border-radius: var(--ndt-border-radius-small);
14
- background-color: var(--ndt-bg-primary);
15
- color: var(--ndt-text-primary);
16
- font-size: var(--ndt-font-size-sm);
17
- cursor: pointer;
18
- user-select: none;
19
- transition: var(--ndt-transition-default);
20
- outline: none;
21
- height: 32px;
22
- box-sizing: border-box;
23
-
24
- &:hover {
25
- background-color: var(--ndt-hover-bg);
26
- border-color: var(--ndt-primary);
27
- }
28
-
29
- &:focus-visible {
30
- outline: none;
31
- border-color: var(--ndt-primary);
32
- box-shadow: 0 0 0 2px rgba(var(--ndt-primary-rgb), 0.2);
33
- }
34
-
35
- &.small {
36
- padding: var(--ndt-spacing-xs) var(--ndt-spacing-sm);
37
- font-size: var(--ndt-font-size-sm);
38
- height: 24px;
39
- }
40
-
41
- &.open {
42
- border-color: var(--ndt-primary);
43
- box-shadow: 0 0 0 2px rgba(var(--ndt-primary-rgb), 0.2);
44
-
45
- .select__arrow {
46
- transform: rotate(180deg);
47
- }
48
- }
49
-
50
- &__value {
51
- flex: 1;
52
- white-space: nowrap;
53
- overflow: hidden;
54
- text-overflow: ellipsis;
55
- line-height: 1;
56
- margin-right: var(--ndt-spacing-sm);
57
- min-width: 0;
58
- }
59
-
60
- &__arrow {
61
- width: 16px;
62
- height: 16px;
63
- flex-shrink: 0;
64
- background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
65
- background-repeat: no-repeat;
66
- background-position: center;
67
- background-size: contain;
68
- transition: transform 0.2s ease;
69
- opacity: 0.9;
70
- }
71
- }
72
-
73
- .select-menu {
74
- display: inline-flex;
75
- flex-direction: column;
76
- min-width: 180px;
77
- background-color: var(--ndt-bg-primary);
78
- padding: var(--ndt-spacing-xs) 0;
79
- border: 1px solid var(--ndt-border-primary);
80
- border-radius: var(--ndt-border-radius-small);
81
- box-shadow: var(--ndt-shadow-window);
82
- color: var(--ndt-text-primary);
83
- max-height: min(400px, 70vh);
84
- overflow-y: auto;
85
- backdrop-filter: blur(8px);
86
-
87
- /* Scrollbar Styles */
88
- &::-webkit-scrollbar {
89
- width: 8px;
90
- height: 8px;
91
- }
92
-
93
- &::-webkit-scrollbar-track {
94
- background: transparent;
95
- }
96
-
97
- &::-webkit-scrollbar-thumb {
98
- background-color: var(--ndt-border-primary);
99
- border-radius: 4px;
100
- border: 2px solid var(--ndt-bg-primary);
101
- }
102
- }
103
-
104
- .select-menu-item {
105
- background-color: transparent;
106
- cursor: pointer;
107
- border: none;
108
- color: inherit;
109
- user-select: none;
110
- min-width: 64px;
111
- line-height: 36px;
112
- padding: 0 var(--ndt-spacing-md);
113
- display: flex;
114
- align-items: center;
115
- flex-direction: row;
116
- flex: 1;
117
- font-size: var(--ndt-font-size-sm);
118
- font-family: inherit;
119
- position: relative;
120
- white-space: nowrap;
121
- text-overflow: ellipsis;
122
- overflow: hidden;
123
-
124
- &:hover {
125
- background-color: var(--ndt-hover-bg);
126
- }
127
-
128
- &:active {
129
- background-color: rgba(var(--ndt-primary-rgb), 0.15);
130
- }
131
-
132
- &.selected {
133
- color: var(--ndt-primary);
134
- background-color: rgba(var(--ndt-primary-rgb), 0.1);
135
- font-weight: 500;
136
-
137
- &:hover {
138
- background-color: rgba(var(--ndt-primary-rgb), 0.15);
139
- }
140
-
141
- &::before {
142
- content: '';
143
- position: absolute;
144
- left: 0;
145
- top: 8px;
146
- width: 3px;
147
- height: calc(100% - 16px);
148
- background-color: var(--ndt-primary);
149
- border-radius: 2px;
150
- }
151
- }
152
-
153
- &:focus-visible {
154
- outline: none;
155
- background-color: var(--ndt-hover-bg);
156
- }
157
- }
158
-
159
- // Ensure proper theme inheritance in overlay
160
- .select-overlay {
161
- backdrop-filter: blur(8px);
162
- }
@@ -1,127 +0,0 @@
1
- import { CdkMenuModule } from '@angular/cdk/menu';
2
- import { ConnectedPosition, OverlayModule } from '@angular/cdk/overlay';
3
- import { CommonModule } from '@angular/common';
4
- import {
5
- ChangeDetectionStrategy,
6
- Component,
7
- computed,
8
- inject,
9
- input,
10
- model,
11
- signal,
12
- } from '@angular/core';
13
- import { FormsModule } from '@angular/forms';
14
- import { DevToolbarStateService } from '../../dev-toolbar-state.service';
15
-
16
- export interface SelectOption {
17
- value: string;
18
- label: string;
19
- }
20
-
21
- @Component({
22
- selector: 'ndt-select',
23
- standalone: true,
24
- imports: [CommonModule, FormsModule, OverlayModule, CdkMenuModule],
25
- template: `
26
- <div
27
- class="dev-toolbar select"
28
- [class.small]="size() === 'small'"
29
- [class.open]="isOpen()"
30
- [attr.aria-label]="ariaLabel()"
31
- [attr.aria-expanded]="isOpen()"
32
- [attr.aria-controls]="selectMenuId"
33
- [attr.data-theme]="theme()"
34
- cdkOverlayOrigin
35
- #trigger="cdkOverlayOrigin"
36
- (click)="toggle()"
37
- (keydown.enter)="toggle()"
38
- (keydown.space)="toggle()"
39
- tabindex="0"
40
- role="combobox"
41
- >
42
- <span class="select__value">{{ selectedLabel() }}</span>
43
- <span class="select__arrow" aria-hidden="true"></span>
44
- </div>
45
-
46
- <ng-template
47
- cdkConnectedOverlay
48
- [cdkConnectedOverlayOrigin]="trigger"
49
- [cdkConnectedOverlayOpen]="isOpen()"
50
- [cdkConnectedOverlayPositions]="positions"
51
- (overlayOutsideClick)="close()"
52
- >
53
- <div
54
- [id]="selectMenuId"
55
- class="dev-toolbar select-menu"
56
- cdkMenu
57
- role="listbox"
58
- [attr.data-theme]="theme()"
59
- >
60
- @for (option of options(); track option.value) {
61
- <button
62
- class="select-menu-item"
63
- [class.selected]="option.value === value()"
64
- [attr.aria-selected]="option.value === value()"
65
- cdkMenuItem
66
- type="button"
67
- (click)="selectOption(option)"
68
- >
69
- {{ option.label }}
70
- </button>
71
- }
72
- </div>
73
- </ng-template>
74
- `,
75
- styleUrls: ['./select.component.scss'],
76
- changeDetection: ChangeDetectionStrategy.OnPush,
77
- })
78
- export class DevToolbarSelectComponent {
79
- readonly devToolbarStateService = inject(DevToolbarStateService);
80
-
81
- value = model<string>();
82
- options = input.required<SelectOption[]>();
83
- ariaLabel = input<string>('');
84
- label = input<string>('');
85
- size = input<'small' | 'medium'>('medium');
86
- readonly theme = computed(() => this.devToolbarStateService.theme());
87
-
88
- protected readonly selectMenuId = `select-menu-${Math.random()
89
- .toString(36)
90
- .slice(2, 11)}`;
91
- isOpen = signal(false);
92
-
93
- selectedLabel = computed(() => {
94
- const selected = this.options()?.find((opt) => opt.value === this.value());
95
- return selected?.label ?? '';
96
- });
97
-
98
- positions: ConnectedPosition[] = [
99
- {
100
- originX: 'end',
101
- originY: 'bottom',
102
- overlayX: 'end',
103
- overlayY: 'top',
104
- offsetY: 4,
105
- },
106
- {
107
- originX: 'end',
108
- originY: 'top',
109
- overlayX: 'end',
110
- overlayY: 'bottom',
111
- offsetY: -4,
112
- },
113
- ];
114
-
115
- toggle() {
116
- this.isOpen.update((v) => !v);
117
- }
118
-
119
- close() {
120
- this.isOpen.set(false);
121
- }
122
-
123
- selectOption(option: SelectOption) {
124
- this.value.set(option.value);
125
- this.close();
126
- }
127
- }
@@ -1,67 +0,0 @@
1
- @use '../../styles' as devtools;
2
- @use 'sass:map';
3
- $dimensions: devtools.$dimensions;
4
-
5
- .tool-button {
6
- display: flex;
7
- justify-content: center;
8
- align-items: center;
9
- width: map.get($dimensions, toolbar-button-width);
10
- height: map.get($dimensions, toolbar-height);
11
- border: 0;
12
- background: transparent;
13
- color: var(--ndt-text-primary);
14
- transition: var(--ndt-transition-default);
15
- cursor: pointer;
16
- opacity: 0.5;
17
- position: relative;
18
-
19
- &--active {
20
- background: var(--ndt-hover-bg);
21
- opacity: 1;
22
- }
23
-
24
- &:hover {
25
- background: var(--ndt-hover-bg);
26
- opacity: 1;
27
- }
28
-
29
- ::ng-deep svg {
30
- width: 24px;
31
- height: 24px;
32
- display: block;
33
- margin: auto;
34
- }
35
-
36
- &__badge {
37
- position: absolute;
38
- top: -0.25rem;
39
- right: -0.25rem;
40
- background-color: var(--ndt-hover-danger);
41
- color: var(--ndt-text-primary);
42
- border-radius: var(--ndt-border-radius-full);
43
- min-width: 1rem;
44
- height: 1rem;
45
- font-size: 0.75rem;
46
- display: flex;
47
- align-items: center;
48
- justify-content: center;
49
- padding: 0.125rem;
50
- }
51
- }
52
-
53
- .tooltip {
54
- position: absolute;
55
- bottom: calc(100% + 1.2rem);
56
- left: 50%;
57
- transform: translateX(-50%);
58
- background: var(--ndt-bg-primary);
59
- color: var(--ndt-text-primary);
60
- padding: 0.5rem 0.75rem;
61
- border-radius: var(--ndt-border-radius-medium);
62
- font-size: 0.75rem;
63
- white-space: nowrap;
64
- pointer-events: none;
65
- z-index: 1000;
66
- box-shadow: var(--ndt-shadow-tooltip);
67
- }
@@ -1,126 +0,0 @@
1
- import {
2
- animate,
3
- state,
4
- style,
5
- transition,
6
- trigger,
7
- } from '@angular/animations';
8
- import {
9
- ChangeDetectionStrategy,
10
- Component,
11
- ElementRef,
12
- computed,
13
- inject,
14
- input,
15
- output,
16
- signal,
17
- } from '@angular/core';
18
- import { DevToolbarStateService } from '../../dev-toolbar-state.service';
19
-
20
- @Component({
21
- selector: 'ndt-tool-button',
22
- standalone: true,
23
- template: `
24
- <button
25
- class="tool-button"
26
- [class.tool-button--active]="isActive()"
27
- [class.tool-button--focus]="isFocused()"
28
- (mouseenter)="onMouseEnter()"
29
- (focusin)="onFocus()"
30
- (focusout)="onBlur()"
31
- (mouseleave)="onMouseLeave()"
32
- (keydown.escape)="onEscape()"
33
- >
34
- @if (isTooltipVisible()) {
35
- <span
36
- class="tooltip"
37
- [@tooltipAnimation]="tooltipState ? 'visible' : 'hidden'"
38
- >
39
- {{ tooltip() }}
40
- </span>
41
- }
42
- <ng-content />
43
- </button>
44
- `,
45
- styleUrls: ['./tool-button.component.scss'],
46
- animations: [
47
- trigger('tooltipAnimation', [
48
- state(
49
- 'hidden',
50
- style({
51
- opacity: 0,
52
- transform: 'translateX(-50%) translateY(1rem)',
53
- })
54
- ),
55
- state(
56
- 'visible',
57
- style({
58
- opacity: 1,
59
- transform: 'translateX(-50%) translateY(0)',
60
- })
61
- ),
62
- transition('hidden => visible', [animate('200ms ease-out')]),
63
- transition('visible => hidden', [animate('150ms ease-in')]),
64
- ]),
65
- ],
66
- changeDetection: ChangeDetectionStrategy.OnPush,
67
- })
68
- export class DevToolbarToolButtonComponent {
69
- // Injects
70
- private readonly state = inject(DevToolbarStateService);
71
- private readonly elementRef = inject(ElementRef);
72
-
73
- // Inputs
74
- readonly title = input.required<string>();
75
- readonly toolId = input.required<string>();
76
-
77
- // Outputs
78
- readonly open = output<void>();
79
-
80
- // Signals
81
- readonly isActive = computed(
82
- () => this.state.activeToolId() === this.toolId()
83
- );
84
- readonly isToolbarVisible = this.state.isVisible;
85
-
86
- readonly isFocused = signal(false);
87
- readonly tooltip = computed(
88
- () =>
89
- this.elementRef.nativeElement.parentElement?.getAttribute(
90
- 'data-tooltip'
91
- ) ?? ''
92
- );
93
- readonly isTooltipVisible = computed(
94
- () => this.tooltip() && !this.isActive()
95
- );
96
-
97
- // Properties
98
- protected tooltipState = false;
99
- private readonly hideDelay = 3000;
100
-
101
- // Public methods
102
- onClick(): void {
103
- this.isFocused.set(false);
104
- this.open.emit();
105
- }
106
-
107
- onMouseEnter(): void {
108
- this.tooltipState = true;
109
- }
110
-
111
- onMouseLeave(): void {
112
- this.tooltipState = false;
113
- }
114
-
115
- onEscape(): void {
116
- this.isFocused.set(false);
117
- }
118
-
119
- onFocus(): void {
120
- this.isFocused.set(true);
121
- }
122
-
123
- onBlur(): void {
124
- this.isFocused.set(false);
125
- }
126
- }
@@ -1,9 +0,0 @@
1
- @use '../../styles' as devtools;
2
-
3
- .tool {
4
- position: relative;
5
- }
6
-
7
- .trigger {
8
- cursor: pointer;
9
- }
@@ -1,169 +0,0 @@
1
- import { animate, style, transition, trigger } from '@angular/animations';
2
- import { CdkConnectedOverlay, OverlayModule } from '@angular/cdk/overlay';
3
- import {
4
- ChangeDetectionStrategy,
5
- Component,
6
- ContentChild,
7
- ElementRef,
8
- ViewChild,
9
- computed,
10
- inject,
11
- input,
12
- } from '@angular/core';
13
- import { DevToolbarStateService } from '../../dev-toolbar-state.service';
14
- import { DevToolbarIconComponent } from '../icons/icon.component';
15
- import { IconName } from '../icons/icon.models';
16
- import { DevToolbarToolButtonComponent } from '../tool-button/tool-button.component';
17
- import { DevToolbarWindowComponent } from '../window/window.component';
18
- import { DevToolbarWindowOptions } from './toolbar-tool.models';
19
-
20
- @Component({
21
- selector: 'ndt-toolbar-tool',
22
- standalone: true,
23
- imports: [
24
- CdkConnectedOverlay,
25
- OverlayModule,
26
- DevToolbarWindowComponent,
27
- DevToolbarToolButtonComponent,
28
- DevToolbarIconComponent,
29
- ],
30
- template: `
31
- <div #trigger="cdkOverlayOrigin" class="dev-toolbar-tool" cdkOverlayOrigin>
32
- <div
33
- class="dev-toolbar-tool__icon"
34
- (click)="onOpen()"
35
- (keydown.enter)="onOpen()"
36
- (keydown.space)="onOpen()"
37
- tabindex="0"
38
- >
39
- <div #buttonContainer [attr.data-tooltip]="title()">
40
- @if (icon()) {
41
- <ndt-tool-button [title]="title()" [toolId]="options().id">
42
- <ndt-icon [name]="icon()" />
43
- </ndt-tool-button>
44
- } @else {
45
- <ng-content select="ndt-tool-button"></ng-content>
46
- }
47
- </div>
48
- </div>
49
-
50
- @if (isActive()) {
51
- <ng-template
52
- #contentTemplate
53
- [cdkConnectedOverlayOrigin]="trigger"
54
- [cdkConnectedOverlayOpen]="isActive()"
55
- [cdkConnectedOverlayPositions]="positions()"
56
- [cdkConnectedOverlayWidth]="width()"
57
- [cdkConnectedOverlayHeight]="height()"
58
- cdkConnectedOverlay
59
- >
60
- <ndt-window [@slideAnimation] [config]="options()" (close)="onClose()">
61
- <ng-content />
62
- </ndt-window>
63
- </ng-template>
64
- }
65
- </div>
66
- `,
67
- styleUrl: './toolbar-tool.component.scss',
68
- changeDetection: ChangeDetectionStrategy.OnPush,
69
- animations: [
70
- trigger('slideAnimation', [
71
- transition(':enter', [
72
- style({
73
- transform: 'translateY(20px)',
74
- opacity: 0,
75
- }),
76
- animate(
77
- '400ms cubic-bezier(0.4, 0, 0.2, 1)',
78
- style({
79
- transform: 'translateY(0)',
80
- opacity: 1,
81
- })
82
- ),
83
- ]),
84
- transition(':leave', [
85
- style({
86
- transform: 'translateY(0)',
87
- opacity: 1,
88
- }),
89
- animate(
90
- '400ms cubic-bezier(0.4, 0, 0.2, 1)',
91
- style({
92
- transform: 'translateY(20px)',
93
- opacity: 0,
94
- })
95
- ),
96
- ]),
97
- ]),
98
- ],
99
- })
100
- export class DevToolbarToolComponent {
101
- state = inject(DevToolbarStateService);
102
- @ViewChild('buttonContainer') buttonContainer!: ElementRef;
103
-
104
- @ContentChild(DevToolbarToolButtonComponent)
105
- buttonComponent!: DevToolbarToolButtonComponent;
106
-
107
- options = input.required<DevToolbarWindowOptions>();
108
- icon = input.required<IconName>();
109
- title = input.required<string>();
110
- isActive = computed(() => this.state.activeToolId() === this.options().id);
111
- height = computed(() => {
112
- switch (this.options().size) {
113
- case 'small':
114
- return 320;
115
- case 'medium':
116
- return 480;
117
- case 'tall':
118
- return 620;
119
- case 'large':
120
- return 620;
121
- default:
122
- return 480;
123
- }
124
- });
125
-
126
- width = computed(() => {
127
- switch (this.options().size) {
128
- case 'small':
129
- return 320;
130
- case 'medium':
131
- return 480;
132
- case 'tall':
133
- return 480;
134
- case 'large':
135
- return 620;
136
- default:
137
- return 400;
138
- }
139
- });
140
- positions = computed(() => {
141
- const triggerXPosition = this.getButtonContainerXPosition();
142
- const windowCenter = window.innerWidth / 2;
143
- const offsetX = windowCenter - triggerXPosition - 22;
144
- return [
145
- {
146
- originX: 'center' as const,
147
- originY: 'center' as const,
148
- overlayX: 'center' as const,
149
- overlayY: 'center' as const,
150
- offsetY: -(Math.ceil(this.height() / 2) + 36),
151
- offsetX,
152
- },
153
- ];
154
- });
155
-
156
- onOpen(): void {
157
- this.state.setActiveTool(this.options().id);
158
- }
159
-
160
- onClose(): void {
161
- this.state.setActiveTool(null);
162
- }
163
-
164
- getButtonContainerXPosition(): number {
165
- const buttonContainerRect =
166
- this.buttonContainer?.nativeElement?.getBoundingClientRect();
167
- return buttonContainerRect?.left ?? 0;
168
- }
169
- }