@allsorter/ui-components 0.0.329 → 0.0.333

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 (87) hide show
  1. package/README.md +40 -73
  2. package/fesm2022/allsorter-ui-components.mjs +329 -0
  3. package/fesm2022/allsorter-ui-components.mjs.map +1 -0
  4. package/index.d.ts +5 -0
  5. package/lib/allsorter-lib.component.d.ts +5 -0
  6. package/lib/allsorter-lib.service.d.ts +6 -0
  7. package/lib/button/button.component.d.ts +46 -0
  8. package/lib/button/button.module.d.ts +13 -0
  9. package/lib/input/input.component.d.ts +34 -0
  10. package/lib/input/input.module.d.ts +8 -0
  11. package/package.json +17 -55
  12. package/public-api.d.ts +6 -0
  13. package/.editorconfig +0 -16
  14. package/.gitignore copy +0 -44
  15. package/.storybook/main.ts +0 -14
  16. package/.storybook/preview.ts +0 -17
  17. package/.storybook/tsconfig.doc.json +0 -10
  18. package/.storybook/tsconfig.json +0 -11
  19. package/.storybook/typings.d.ts +0 -4
  20. package/.vscode/settings.json +0 -1
  21. package/LICENSE +0 -21
  22. package/angular.json +0 -109
  23. package/bitbucket-pipelines.yml +0 -108
  24. package/documentation.json +0 -1080
  25. package/src/app/app.component.css +0 -0
  26. package/src/app/app.component.html +0 -328
  27. package/src/app/app.component.spec.ts +0 -31
  28. package/src/app/app.component.ts +0 -11
  29. package/src/app/app.module.ts +0 -16
  30. package/src/app/button/button.component.html +0 -117
  31. package/src/app/button/button.component.scss +0 -462
  32. package/src/app/button/button.component.spec.ts +0 -23
  33. package/src/app/button/button.component.ts +0 -105
  34. package/src/app/button/button.module.ts +0 -23
  35. package/src/app/input/input.component.css +0 -424
  36. package/src/app/input/input.component.html +0 -27
  37. package/src/app/input/input.component.spec.ts +0 -444
  38. package/src/app/input/input.component.ts +0 -92
  39. package/src/app/input/input.module.ts +0 -9
  40. package/src/assets/.gitkeep +0 -0
  41. package/src/assets/font/OpenSans-Light-webfont.eot +0 -0
  42. package/src/assets/font/OpenSans-Light-webfont.svg +0 -252
  43. package/src/assets/font/OpenSans-Light-webfont.ttf +0 -0
  44. package/src/assets/font/OpenSans-Light-webfont.woff +0 -0
  45. package/src/assets/font/OpenSans-Regular-webfont.eot +0 -0
  46. package/src/assets/font/OpenSans-Regular-webfont.svg +0 -252
  47. package/src/assets/font/OpenSans-Regular-webfont.ttf +0 -0
  48. package/src/assets/font/OpenSans-Regular-webfont.woff +0 -0
  49. package/src/assets/icon/percolate.eot +0 -0
  50. package/src/assets/icon/percolate.svg +0 -139
  51. package/src/assets/icon/percolate.ttf +0 -0
  52. package/src/assets/icon/percolate.woff +0 -0
  53. package/src/environments/environment.prod.ts +0 -3
  54. package/src/environments/environment.ts +0 -16
  55. package/src/favicon.ico +0 -0
  56. package/src/index.html +0 -15
  57. package/src/main.ts +0 -7
  58. package/src/polyfills.ts +0 -63
  59. package/src/public-api.ts +0 -9
  60. package/src/stories/.eslintrc.json +0 -8
  61. package/src/stories/Configure.mdx +0 -369
  62. package/src/stories/assets/accessibility.png +0 -0
  63. package/src/stories/assets/accessibility.svg +0 -5
  64. package/src/stories/assets/addon-library.png +0 -0
  65. package/src/stories/assets/assets.png +0 -0
  66. package/src/stories/assets/avif-test-image.avif +0 -0
  67. package/src/stories/assets/context.png +0 -0
  68. package/src/stories/assets/discord.svg +0 -15
  69. package/src/stories/assets/docs.png +0 -0
  70. package/src/stories/assets/figma-plugin.png +0 -0
  71. package/src/stories/assets/github.svg +0 -3
  72. package/src/stories/assets/share.png +0 -0
  73. package/src/stories/assets/styling.png +0 -0
  74. package/src/stories/assets/testing.png +0 -0
  75. package/src/stories/assets/theming.png +0 -0
  76. package/src/stories/assets/tutorials.svg +0 -12
  77. package/src/stories/assets/youtube.svg +0 -4
  78. package/src/stories/button-gallery.stories.ts +0 -145
  79. package/src/stories/button-playground.stories.ts +0 -59
  80. package/src/stories/input-gallery.stories.ts +0 -124
  81. package/src/stories/input-playground.stories.ts +0 -135
  82. package/src/styles/global-menu-overlay-styles.scss +0 -8
  83. package/src/styles/typography-classes.scss +0 -122
  84. package/src/styles.css +0 -463
  85. package/tsconfig.app.json +0 -10
  86. package/tsconfig.json +0 -29
  87. package/tsconfig.spec.json +0 -10
@@ -1,462 +0,0 @@
1
- @import url("https://fonts.googleapis.com/icon?family=Material+Icons|Material+Icons+Outlined");
2
- @import "../../styles/typography-classes.scss";
3
-
4
- .material-icons-outlined {
5
- font-family: 'Material Icons Outlined';
6
- font-weight: normal;
7
- font-style: normal;
8
- /* These two preserve the standard Material Icons sizing/ligatures */
9
- font-feature-settings: 'liga';
10
- font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
11
- /* everything else can stay at Angular’s defaults */
12
- /* Base Button Styling */
13
- }
14
- .mdc-button.btn {
15
-
16
- border-radius: 5px;
17
- display: flex;
18
- align-items: center;
19
- cursor: pointer;
20
- border: none;
21
- transition: background 0.2s, border 0.2s, transform 0.1s;
22
-
23
- min-width: auto !important;
24
- gap:8px;
25
- height:auto !important;
26
- }
27
- /* Button Categories primary*/
28
- .mdc-button.btn-primary1 {
29
- background-color: #5473e8;
30
- color: white;
31
- }
32
- .mdc-button.btn-primary2 {
33
- background-color: #37c1ce;
34
- color: white;
35
- }
36
- .mdc-button.btn-secondary {
37
- background-color: #383B4A;
38
- color: white;
39
- }
40
- .mdc-button.btn-destructive {
41
- background-color: #E854A4;
42
- color: white;
43
- }
44
- .mdc-button.btn-gradient {
45
- background: linear-gradient(275deg, #5473E8 -36.22%, #37C1CE 100.04%);
46
- color: white;
47
- }
48
-
49
- /* Hover States */
50
-
51
-
52
- .mdc-button.btn-primary2:hover {
53
- background-color: #4bc7d3 !important;
54
- }
55
-
56
- .mdc-button.btn-primary2:active {
57
- background-color: #299da8 !important;
58
- }
59
-
60
- .mdc-button.btn-primary2:outlined {
61
- background-color: #fff;
62
- border-radius: 4px;
63
- border: 1px solid #37c1ce;
64
- }
65
-
66
- .mdc-button.btn-primary1:hover {
67
- background-color: #6581ea !important;
68
- }
69
-
70
- .mdc-button.btn-primary1:active {
71
- background-color: #1e46df !important;
72
- }
73
-
74
- .mdc-button.btn-primary1:outlined {
75
- background-color: #fff;
76
- border-radius: 4px;
77
- border: 1px solid #5473e8;
78
- }
79
-
80
- .mdc-button.btn-secondary:hover {
81
- background-color: #4B4F62 !important;
82
- }
83
-
84
- .mdc-button.btn-secondary:active {
85
- background-color: #252831 !important;
86
- }
87
-
88
- .mdc-button.btn-secondary:outlined {
89
- background-color: #fff;
90
- border-radius: 4px;
91
- border: 1px solid #383B4A;
92
- }
93
-
94
-
95
- .mdc-button.btn-destructive:hover {
96
- background-color: #EF87BF !important;
97
- }
98
-
99
- .mdc-button.btn-destructive:active {
100
- background-color: #E22A8E !important;
101
- }
102
-
103
- .mdc-button.btn-destructive:outlined {
104
- background-color: #fff;
105
- border-radius: 4px;
106
- border: 1px solid #E854A4;
107
- }
108
-
109
- .mdc-button.btn-gradient:hover {
110
- background: linear-gradient(275deg, #4A90E2 -36.22%, #2BBBAD 100.04%) !important;
111
- }
112
-
113
- .mdc-button.btn-gradient:active {
114
- background: linear-gradient(275deg, #42A5F5 -36.22%, #1E88E5 100.04%) !important;
115
- }
116
-
117
-
118
-
119
-
120
- /* Pressed States (pseudo-class for active) */
121
-
122
-
123
- /* Disabled State */
124
- .mdc-button.btn-disabled {
125
- border: none !important;
126
- background-color: #b0b0b0;
127
- color: #666;
128
- cursor: not-allowed;
129
- }
130
-
131
- /* Outlined State */
132
- .mdc-button.btn-outlined {
133
- background: transparent;
134
- border: 2px solid currentColor;
135
- }
136
-
137
- /* Category colours used by Storybook */
138
- .blue { background-color:#5473e8 !important; color:#fff; }
139
- .blue.btn-hover, .blue:hover { background-color:#6581ea !important; }
140
- .blue.btn-pressed, .blue:active { background-color:#1e46df !important; }
141
-
142
- .green { background-color:#37c1ce !important; color:#fff; }
143
- .green.btn-hover, .green:hover { background-color:#4bc7d3 !important; }
144
- .green.btn-pressed, .green:active { background-color:#299da8 !important; }
145
-
146
- .grey { background-color:#383B4A !important; color:#fff; }
147
- .grey.btn-hover, .grey:hover { background-color:#4B4F62 !important; }
148
- .grey.btn-pressed, .grey:active { background-color:#252831 !important; }
149
-
150
- .error { background-color:#E854A4 !important; color:#fff; }
151
- .error.btn-hover, .error:hover { background-color:#EF87BF !important; }
152
- .error.btn-pressed, .error:active { background-color:#E22A8E !important; }
153
-
154
- .gradient { background:linear-gradient(275deg, #5473E8 -36.22%, #37C1CE 100.04%); color:#fff; }
155
- .gradient.btn-hover, .gradient:hover { opacity:0.9; }
156
- .gradient.btn-pressed, .gradient:active { opacity:0.8; }
157
-
158
-
159
- /* Spacing between icon and label */
160
- .btn.custom-button > * + * {
161
- margin-left: 8px;
162
- }
163
-
164
- /* Fixed 20x20 icon size for label/two-icon buttons */
165
- .two-icon-label{
166
- padding:4px 12px !important;
167
- }
168
- button.two-icon-label .mat-icon {
169
- width: 20px !important;
170
- height: 20px !important;
171
- }
172
-
173
-
174
- /* etc. */
175
- @font-face {
176
- font-family: 'Material Icons';
177
- font-style: normal;
178
- font-weight: 400;
179
- src: url(https://fonts.gstatic.com/s/materialicons/v143/flUhRq6tzZclQEJ-Vdg-IuiaDsNcIhQ8tQ.woff2) format('woff2');
180
- }
181
-
182
- .material-icons {
183
- font-family: 'Material Icons';
184
- font-weight: normal;
185
- font-style: normal;
186
- font-size: 24px;
187
- line-height: 1;
188
- letter-spacing: normal;
189
- text-transform: none;
190
- display: inline-block;
191
- white-space: nowrap;
192
- word-wrap: normal;
193
- direction: ltr;
194
- -webkit-font-feature-settings: 'liga';
195
- -webkit-font-smoothing: antialiased;
196
- }
197
-
198
- .left-icon{
199
- order:0;
200
- }
201
-
202
- .right-icon{
203
- order:2;
204
- }
205
-
206
- mat-icon.mat-icon {
207
- margin: 0 !important;
208
- padding: 0 !important;
209
- }
210
-
211
- /* ------------------------------------------------------------------
212
- Size utility classes
213
- ------------------------------------------------------------------ */
214
-
215
-
216
-
217
- /* New naming convention */
218
- .size-header { font-size: 20px; padding: 4px 12px !important; }
219
- .size-xs { font-size: 12px; padding: 8px 12px !important; }
220
- .size-sm { font-size: 14px; padding: 8px 12px !important; }
221
- .size-base { font-size: 14px; padding: 10px 20px !important; }
222
- .size-l { font-size: 16px; padding: 12px 20px !important; }
223
- .size-xl{ font-size: 16px; padding: 14px 24px !important; }
224
- /* Reuse .size-xl for xl */
225
-
226
- /* Icon sizes for new naming */
227
- .size-header .mat-icon { width:20px; height:20px; font-size:20px; }
228
- .size-xs .mat-icon { width:16px; height:16px; font-size:16px; }
229
- .size-sm .mat-icon, .size-base .mat-icon { width:16px; height:16px; font-size:16px; }
230
- .size-l .mat-icon, .size-xl .mat-icon { width:20px; height:20px; font-size:20px; }
231
-
232
- /* Adjust gap for header size */
233
- .btn.size-header { gap:4px !important; padding: 4px 12px !important;}
234
-
235
- /* --------------------------------------------------
236
- Dropdown menu custom styling
237
- -------------------------------------------------- */
238
- ::ng-deep .custom-dropdown-menu.mat-mdc-menu-panel,
239
- ::ng-deep .custom-dropdown-menu.mat-menu-panel {
240
- padding: 0; /* remove default padding */
241
- border-radius: 8px; /* rounded corners */
242
- box-shadow: 0 2px 6px rgba(0,0,0,0.15);
243
- border: 1px solid rgba(0,0,0,0.12);
244
- }
245
- ::ng-deep .custom-dropdown-menu .mat-mdc-menu-content,
246
- ::ng-deep .custom-dropdown-menu .mat-menu-content{
247
- padding: 0;
248
- }
249
- ::ng-deep .custom-dropdown-menu .mat-mdc-menu-item,
250
- ::ng-deep .custom-dropdown-menu .mat-menu-item{
251
- font-family: 'Roboto', sans-serif;
252
- font-size: 16px;
253
- line-height: 24px;
254
- height: 56px;
255
- padding: 16px 24px;
256
- color:#47515E;
257
- }
258
- ::ng-deep .custom-dropdown-menu .mat-mdc-menu-item:hover,
259
- ::ng-deep .custom-dropdown-menu .mat-menu-item:hover{
260
- background: #F5F6F7;
261
- }
262
- /* subtle divider between items */
263
- ::ng-deep .custom-dropdown-menu .mat-mdc-menu-item + .mat-mdc-menu-item,
264
- ::ng-deep .custom-dropdown-menu .mat-menu-item + .mat-menu-item{
265
- border-top: 1px solid #EAECEE;
266
- }
267
-
268
- /* Force white background on Angular Material menu panel */
269
- ::ng-deep .mat-mdc-menu-panel,
270
- ::ng-deep .mat-menu-panel,
271
- ::ng-deep .mdc-menu-surface {
272
- background-color: #ffffff !important;
273
- --mdc-theme-surface: #ffffff !important;
274
- --mdc-menu-container-color: #ffffff !important;
275
- }
276
- ::ng-deep .mat-mdc-menu-panel .mat-mdc-menu-content,
277
- ::ng-deep .mat-menu-panel .mat-menu-content {
278
- background-color: #ffffff !important;
279
- }
280
-
281
- /* Ensure dropdown menu is above other elements */
282
- .cdk-overlay-pane{
283
- z-index:1000 !important;
284
- background:#fff !important;
285
- }
286
- ::ng-deep .mat-mdc-menu-panel,
287
- ::ng-deep .mat-menu-panel,
288
- ::ng-deep .mdc-menu-surface,
289
- .cdk-overlay-pane .mat-mdc-menu-panel,
290
- .cdk-overlay-pane .mdc-menu-surface,
291
- .cdk-overlay-pane .mat-menu-panel{
292
- background-color:#ffffff !important;
293
- --mdc-theme-surface:#ffffff !important;
294
- --mdc-menu-container-color:#fff !important;
295
- }
296
-
297
- /* Make sure the Material menu panel itself is white (use ::ng-deep so rules pierce view encapsulation) */
298
-
299
-
300
- .mat-mdc-menu-panel,
301
- .mdc-menu-surface,
302
- .mat-menu-panel {
303
- --mdc-theme-surface: #ffffff !important; /* Material variable */
304
- background-color: #ffffff !important;
305
- }
306
-
307
- .cdk-overlay-pane .mat-mdc-menu-panel,
308
- .cdk-overlay-pane .mdc-menu-surface,
309
- .cdk-overlay-pane .mat-mdc-menu-panel { --mdc-menu-container-color:#fff !important; }
310
-
311
- .cdk-overlay-pane .mat-menu-panel,
312
- .cdk-overlay-pane .mat-mdc-menu-content,
313
- .cdk-overlay-pane .mat-menu-content {
314
- background: #fff !important;
315
- }
316
-
317
-
318
- /* Icon size helper */
319
-
320
-
321
- /* --------------------------------------------------
322
- Button types
323
- -------------------------------------------------- */
324
- button.icon-circle {
325
- width: auto !important;
326
- height: auto !important;
327
- border-radius: 50% !important;
328
- aspect-ratio: 1 / 1;
329
- display: inline-flex;
330
- align-items: center;
331
- justify-content: center;
332
- padding: 0 !important;
333
- min-width: 0 !important;
334
- justify-content: center;
335
- padding:6px !important;
336
- }
337
- .size-small.icon-circle {
338
- padding: 4px !important;
339
- }
340
- .size-medium.icon-circle {
341
- padding: 8px !important;
342
- }
343
- .size-base.icon-circle {
344
- padding: 10px !important;
345
- }
346
- .size-large.icon-circle {
347
- padding: 12px !important;
348
- }
349
- .size-xl.icon-circle {
350
- padding: 14px !important;
351
- }
352
-
353
- /* Circle button size overrides */
354
- .size-header.icon-circle { padding:4px !important; }
355
- .size-header.icon-circle .mat-icon { width:10px; height:10px; font-size:10px; }
356
-
357
- .size-xs.icon-circle { padding:4px !important; }
358
- .size-xs.icon-circle .mat-icon { width:12px; height:12px; font-size:12px; }
359
-
360
- .size-sm.icon-circle { padding:8px !important; }
361
- .size-sm.icon-circle .mat-icon { width:12px; height:12px; font-size:12px; }
362
-
363
- .size-base.icon-circle { padding:10px !important; }
364
- .size-base.icon-circle .mat-icon { width:14px; height:14px; font-size:14px; }
365
-
366
- .size-l.icon-circle { padding:12px !important; }
367
- .size-l.icon-circle .mat-icon { width:16px; height:16px; font-size:16px; }
368
-
369
- .size-xl.icon-circle { padding:14px !important; }
370
- .size-xl.icon-circle .mat-icon { width:16px; height:16px; font-size:16px; }
371
-
372
- /* icon-label and two-icon-label just rely on default flex behaviour */
373
- .icon-xs {
374
- /* width: 16px; height: 16px; */
375
- padding: 4px !important;
376
- }
377
-
378
-
379
- /* ------------------------------------------------------------------
380
- Color category classes (solid)
381
- ------------------------------------------------------------------ */
382
- .mdc-button.blue { background-color: #5473E8; color: #fff; }
383
- .mdc-button.blue:hover { background-color: #6581EA; }
384
- .mdc-button.blue:active { background-color: #1E46DF; }
385
-
386
- .mdc-button.green { background-color: #37C1CE; color: #fff; }
387
- .mdc-button.green:hover { background-color: #4BC7D3; }
388
- .mdc-button.green:active { background-color: #299DA8; }
389
-
390
- .mdc-button.grey { background-color: #383B4A; color: #fff; }
391
- .mdc-button.grey:hover { background-color: #4B4F62; }
392
- .mdc-button.grey:active { background-color: #252831; }
393
-
394
- .mdc-button.error { background-color: #E854A4; color: #fff; }
395
- .mdc-button.error:hover { background-color: #EF87BF; }
396
- .mdc-button.error:active { background-color: #E22A8E; }
397
-
398
- .mdc-button.gradient {
399
- background: linear-gradient(275deg, #5473E8 -36.22%, #37C1CE 100.04%);
400
- color: #fff;
401
- }
402
- .mdc-button.gradient:hover {
403
- background: linear-gradient(0deg, rgba(250, 250, 253, 0.30) 0%, rgba(250, 250, 253, 0.30) 100%),
404
- linear-gradient(275deg, #2BBBAD 9.3%, #4A90E2 115.85%);
405
- }
406
- .mdc-button.gradient:active {
407
- background: linear-gradient(0deg, rgba(56, 59, 74, 0.50) 0%, rgba(56, 59, 74, 0.50) 100%),
408
- linear-gradient(275deg, #2BBBAD 9.3%, #4A90E2 115.85%);
409
- }
410
-
411
- .mdc-button.disabled,
412
- .mdc-button:disabled {
413
- background-color: #D1D3DB !important;
414
- color: #666 !important;
415
- cursor: not-allowed !important;
416
- }
417
-
418
- /* ------------------------------------------------------------------
419
- No-outline (outlined) variants
420
- ------------------------------------------------------------------ */
421
- .mdc-button.blue-no-outline { background-color: #fff; color: #5473E8; border: 1px solid #5473E8; }
422
- .mdc-button.blue-no-outline:hover { background-color: #6581EA; color:#fff; }
423
- .mdc-button.blue-no-outline:active { background-color: #1E46DF; color:#fff; }
424
-
425
- .mdc-button.green-no-outline { background-color: #fff; color: #37C1CE; border: 1px solid #37C1CE; }
426
- .mdc-button.green-no-outline:hover { background-color: #4BC7D3; color:#fff; }
427
- .mdc-button.green-no-outline:active { background-color: #299DA8; color:#fff; }
428
-
429
- .mdc-button.grey-no-outline { background-color: #fff; color: #383B4A; border: 1px solid #383B4A; }
430
- .mdc-button.grey-no-outline:hover { background-color: #4B4F62; color:#fff; }
431
- .mdc-button.grey-no-outline:active { background-color: #252831; color:#fff; }
432
-
433
- .mdc-button.error-no-outline { background-color: #fff; color: #E854A4; border: 1px solid #E854A4; }
434
- .mdc-button.error-no-outline:hover { background-color: #EF87BF; color:#fff; }
435
- .mdc-button.error-no-outline:active { background-color: #E22A8E; color:#fff; }
436
-
437
- /*************Button Drop down design*********/
438
- ::ng-deep .cdk-overlay-pane {
439
- border-radius: 6px !important;
440
- box-shadow: 0px 2px 6px rgba(0, 0, 0, 0.15) !important;
441
- }
442
-
443
- ::ng-deep .mat-mdc-menu-panel {
444
- padding: 4px 0 !important;
445
- background-color: white !important;
446
- min-width: 180px !important;
447
- border-radius: 6px !important;
448
- box-shadow: none !important; /* handled by cdk-overlay-pane */
449
- }
450
-
451
- ::ng-deep .mat-mdc-menu-item {
452
- font-family: 'Roboto', sans-serif;
453
- font-size: 14px;
454
- color: #333;
455
- padding: 12px 16px;
456
- border-radius: 0 !important;
457
- transition: background 0.2s ease-in-out;
458
- }
459
-
460
- ::ng-deep .mat-mdc-menu-item:hover {
461
- background-color: #f5f5f5 !important;
462
- }
@@ -1,23 +0,0 @@
1
- import { ComponentFixture, TestBed } from '@angular/core/testing';
2
-
3
- import { ButtonComponent } from './button.component';
4
-
5
- describe('ButtonComponent', () => {
6
- let component: ButtonComponent;
7
- let fixture: ComponentFixture<ButtonComponent>;
8
-
9
- beforeEach(async () => {
10
- await TestBed.configureTestingModule({
11
- imports: [ButtonComponent]
12
- })
13
- .compileComponents();
14
-
15
- fixture = TestBed.createComponent(ButtonComponent);
16
- component = fixture.componentInstance;
17
- fixture.detectChanges();
18
- });
19
-
20
- it('should create', () => {
21
- expect(component).toBeTruthy();
22
- });
23
- });
@@ -1,105 +0,0 @@
1
- import { CommonModule } from '@angular/common';
2
- import { Component, EventEmitter, Input, Output } from '@angular/core';
3
- import { MatIconModule } from '@angular/material/icon';
4
- import { MatButtonModule } from '@angular/material/button';
5
- import { MatMenuModule } from '@angular/material/menu';
6
-
7
- @Component({
8
- selector: 'al-button',
9
- templateUrl: './button.component.html',
10
- styleUrls: ['./button.component.scss'],
11
- imports: [CommonModule, MatButtonModule, MatIconModule, MatMenuModule],
12
- standalone:true
13
- })
14
- export class ButtonComponent {
15
- /**
16
- * Returns the typography class to apply. If the consumer passes `fontClass`,
17
- * that value wins. Otherwise we derive a sensible default based on `size`.
18
- */
19
- get effectiveFontClass(): string {
20
- if (this.fontClass) {
21
- return this.fontClass;
22
- }
23
- switch (this.size) {
24
- case 'xs':
25
- return 'font-body-small';
26
- case 'sm':
27
- case 'base':
28
- return 'font-body-medium';
29
- case 'l':
30
- case 'xl':
31
- case 'header':
32
- return 'font-body-large';
33
- default:
34
- return '';
35
- }
36
- }
37
- @Input() state: 'default' | 'hover' | 'pressed' | 'disabled' = 'default';
38
- @Input() category!: string;
39
-
40
- @Input() label: string | undefined = ' '; // Default label
41
- @Input() arialabel: string | undefined = ' '; // Default label
42
- @Input() iconOnly: boolean = false; // Toggle for icon-only button
43
- @Input() leftIcon: string | null | undefined = ''; // ✅ Default to null
44
- @Input() rightIcon: string | null | undefined = ''; // ✅ Default to null
45
- /** Show/hide left icon (Storybook control) */
46
- @Input() showLeftIcon: boolean = true;
47
- /** Show/hide right icon (Storybook control) */
48
- @Input() showRightIcon: boolean = true;
49
- /** If true, use outlined style for icons */
50
- @Input() outlined: boolean = false;
51
- @Input() color: 'primary' | 'accent' | 'warn' = 'primary';
52
- /** Text size option for label and icons */
53
- @Input() size: 'header' | 'xs' | 'sm' | 'base' | 'l' | 'xl' = 'base';
54
-
55
- /** Visual type of button: icon only circle, icon+label, two icons + label */
56
- @Input() buttonType: 'icon-circle' | 'icon-label' | 'two-icon-label' | 'dropdown' = 'icon-label';
57
-
58
- /** Optional typography class, e.g. 'font-display-large' */
59
- @Input() fontClass: string = '';
60
-
61
- @Output() onClick = new EventEmitter<Event>(); // Initialize
62
- @Output() onHover = new EventEmitter<Event>(); // Initialize
63
- @Output() onMouseLeave = new EventEmitter<Event>(); // Initialize
64
-
65
- /** Dropdown menu options, used when buttonType is 'dropdown' */
66
- @Input() dropdownOptions: Array<{ label: string; value?: any }> = [];
67
-
68
- /** Emits the selected dropdown option's value */
69
- @Output() optionSelect = new EventEmitter<any>();
70
-
71
- selectOption(option: any) {
72
- this.optionSelect.emit(option?.value ?? option);
73
- }
74
-
75
- computeGap(): number {
76
- // Header size uses a tighter 4px gap across all combinations
77
- if (this.size === 'header') {
78
- return 4;
79
- }
80
- const hasLabel = !!(this.label && this.label.trim()) && !this.iconOnly;
81
- const leftIconPresent = !!(this.leftIcon && this.leftIcon.trim());
82
- const rightIconPresent = !!(this.rightIcon && this.rightIcon.trim());
83
- const iconCount = (leftIconPresent ? 1 : 0) + (rightIconPresent ? 1 : 0);
84
-
85
- // 0 gap for purely icon-only buttons (≤1 icon and no label)
86
- if (!hasLabel && iconCount <= 1) {
87
- return 0;
88
- }
89
-
90
- // Tighter gap when we have two icons and a label (e.g., two-icon buttons)
91
- if (iconCount === 2 && !hasLabel) {
92
- return 4;
93
- }
94
-
95
- // Default gap
96
- return 8;
97
- }
98
-
99
- stateClasses: { [key: string]: string } = {
100
- default: 'btn-default',
101
- hover: 'btn-hover',
102
- pressed: 'btn-pressed',
103
- disabled: 'btn-disabled',
104
- };
105
- }
@@ -1,23 +0,0 @@
1
- import { NgModule } from '@angular/core';
2
- import { CommonModule } from '@angular/common';
3
- import { ButtonComponent } from './button.component';
4
- import { MatIconRegistry } from '@angular/material/icon';
5
- import { DomSanitizer } from '@angular/platform-browser';
6
-
7
- @NgModule({
8
- declarations: [], // ✅ Ensure ButtonComponent is declared
9
- exports: [], // ✅ Export if used in other modules
10
- imports: [CommonModule, ButtonComponent], // ✅ Required for Angular directives like *ngIf, *ngFor
11
- })
12
- export class ButtonModule {
13
- constructor(
14
- private iconRegistry: MatIconRegistry,
15
- private sanitizer: DomSanitizer
16
- ) {
17
- // register the CSS class alias so <mat-icon> knows about it…
18
- this.iconRegistry.registerFontClassAlias(
19
- 'material-symbols-outlined',
20
- 'material-symbols-outlined'
21
- );
22
- }
23
- }