igniteui-cli 15.2.2 → 15.3.1-beta.1

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 (134) hide show
  1. package/lib/commands/build.js +7 -12
  2. package/package.json +7 -7
  3. package/templates/blazor/igb/projects/ai-config/files/skills/AGENTS.md +0 -5
  4. package/templates/blazor/igb/projects/ai-config/files/skills/igniteui-blazor-components/SKILL.md +2 -0
  5. package/templates/blazor/igb/projects/ai-config/files/skills/igniteui-blazor-components/references/charts.md +7 -35
  6. package/templates/blazor/igb/projects/ai-config/files/skills/igniteui-blazor-components/references/data-display.md +0 -54
  7. package/templates/blazor/igb/projects/ai-config/files/skills/igniteui-blazor-components/references/feedback.md +0 -38
  8. package/templates/blazor/igb/projects/ai-config/files/skills/igniteui-blazor-components/references/form-controls.md +0 -68
  9. package/templates/blazor/igb/projects/ai-config/files/skills/igniteui-blazor-components/references/layout-manager.md +1 -124
  10. package/templates/blazor/igb/projects/ai-config/files/skills/igniteui-blazor-components/references/layout.md +0 -62
  11. package/templates/blazor/igb/projects/ai-config/files/skills/igniteui-blazor-grids/references/grid-migration.md +322 -0
  12. package/templates/blazor/igb/projects/ai-config/files/skills/igniteui-blazor-theming/SKILL.md +1 -1
  13. package/templates/react/igr-ts/projects/_base/files/package.json +1 -0
  14. package/templates/react/igr-ts/projects/_base/files/src/app/app.tsx +4 -2
  15. package/templates/react/igr-ts/projects/_base/files/src/setupTests.ts +12 -0
  16. package/templates/react/igr-ts/projects/_base/files/styles.css +6 -0
  17. package/templates/react/igr-ts/projects/_base_with_home/files/index.html +2 -1
  18. package/templates/react/igr-ts/projects/_base_with_home/files/src/app/home/home.tsx +60 -10
  19. package/templates/react/igr-ts/projects/_base_with_home/files/src/app/home/style.module.css +79 -20
  20. package/templates/react/igr-ts/projects/ai-config/files/skills/grid-lite-to-igr-grid-migration/SKILL.md +274 -0
  21. package/templates/react/igr-ts/projects/ai-config/files/skills/igniteui-react-components/SKILL.md +0 -8
  22. package/templates/react/igr-ts/projects/ai-config/files/skills/igniteui-react-components/reference/CHARTS-GRIDS.md +6 -36
  23. package/templates/react/igr-ts/projects/ai-config/files/skills/igniteui-react-components/reference/COMPONENT-CATALOGUE.md +8 -142
  24. package/templates/react/igr-ts/projects/ai-config/files/skills/igniteui-react-components/reference/EVENT-HANDLING.md +2 -0
  25. package/templates/react/igr-ts/projects/ai-config/files/skills/igniteui-react-customize-theme/SKILL.md +7 -14
  26. package/templates/react/igr-ts/projects/ai-config/files/skills/igniteui-react-customize-theme/reference/CSS-THEMING.md +2 -0
  27. package/templates/react/igr-ts/projects/ai-config/files/skills/igniteui-react-customize-theme/reference/MCP-SERVER.md +0 -8
  28. package/templates/react/igr-ts/projects/ai-config/files/skills/igniteui-react-generate-from-image-design/SKILL.md +2 -2
  29. package/templates/react/igr-ts/projects/ai-config/files/skills/igniteui-react-generate-from-image-design/reference/component-mapping.md +60 -74
  30. package/templates/react/igr-ts/projects/ai-config/files/skills/igniteui-react-generate-from-image-design/reference/gotchas.md +2 -2
  31. package/templates/react/igr-ts/projects/empty/index.js +2 -2
  32. package/templates/react/igr-ts/projects/side-nav/files/src/app/app-routes.tsx +5 -0
  33. package/templates/react/igr-ts/projects/side-nav/files/src/app/app.css +82 -0
  34. package/templates/react/igr-ts/projects/side-nav/files/src/app/app.tsx +104 -0
  35. package/templates/react/igr-ts/projects/side-nav/files/src/app/home/home.tsx +69 -0
  36. package/templates/react/igr-ts/projects/side-nav/files/src/app/home/style.module.css +105 -0
  37. package/templates/react/igr-ts/projects/{top-nav → side-nav}/index.d.ts +2 -2
  38. package/templates/react/igr-ts/projects/{top-nav → side-nav}/index.js +7 -7
  39. package/templates/react/igr-ts/projects/side-nav-auth/files/index.html +19 -0
  40. package/templates/react/igr-ts/projects/side-nav-auth/files/src/app/app-routes.tsx +24 -0
  41. package/templates/react/igr-ts/projects/side-nav-auth/files/src/app/app.css +84 -0
  42. package/templates/react/igr-ts/projects/side-nav-auth/files/src/app/app.tsx +124 -0
  43. package/templates/react/igr-ts/projects/side-nav-auth/files/src/app/authentication/AuthContext.tsx +73 -0
  44. package/templates/react/igr-ts/projects/side-nav-auth/files/src/app/authentication/AuthGuard.tsx +14 -0
  45. package/templates/react/igr-ts/projects/side-nav-auth/files/src/app/authentication/components/Login.module.css +93 -0
  46. package/templates/react/igr-ts/projects/side-nav-auth/files/src/app/authentication/components/Login.tsx +69 -0
  47. package/templates/react/igr-ts/projects/side-nav-auth/files/src/app/authentication/components/LoginBar.module.css +42 -0
  48. package/templates/react/igr-ts/projects/side-nav-auth/files/src/app/authentication/components/LoginBar.tsx +44 -0
  49. package/templates/react/igr-ts/projects/side-nav-auth/files/src/app/authentication/components/LoginDialog.module.css +14 -0
  50. package/templates/react/igr-ts/projects/side-nav-auth/files/src/app/authentication/components/LoginDialog.tsx +49 -0
  51. package/templates/react/igr-ts/projects/side-nav-auth/files/src/app/authentication/components/Register.module.css +74 -0
  52. package/templates/react/igr-ts/projects/side-nav-auth/files/src/app/authentication/components/Register.tsx +67 -0
  53. package/templates/react/igr-ts/projects/side-nav-auth/files/src/app/authentication/models/external-login.ts +10 -0
  54. package/templates/react/igr-ts/projects/side-nav-auth/files/src/app/authentication/models/login.ts +4 -0
  55. package/templates/react/igr-ts/projects/side-nav-auth/files/src/app/authentication/models/register-info.ts +6 -0
  56. package/templates/react/igr-ts/projects/side-nav-auth/files/src/app/authentication/models/user.ts +19 -0
  57. package/templates/react/igr-ts/projects/side-nav-auth/files/src/app/authentication/pages/Profile.module.css +87 -0
  58. package/templates/react/igr-ts/projects/side-nav-auth/files/src/app/authentication/pages/Profile.tsx +42 -0
  59. package/templates/react/igr-ts/projects/side-nav-auth/files/src/app/authentication/pages/RedirectFacebook.tsx +44 -0
  60. package/templates/react/igr-ts/projects/side-nav-auth/files/src/app/authentication/pages/RedirectGoogle.tsx +40 -0
  61. package/templates/react/igr-ts/projects/side-nav-auth/files/src/app/authentication/pages/RedirectMicrosoft.tsx +40 -0
  62. package/templates/react/igr-ts/projects/side-nav-auth/files/src/app/authentication/services/authentication.ts +37 -0
  63. package/templates/react/igr-ts/projects/side-nav-auth/files/src/app/authentication/services/external-auth-config.ts +44 -0
  64. package/templates/react/igr-ts/projects/side-nav-auth/files/src/app/authentication/services/externalAuth.ts +272 -0
  65. package/templates/react/igr-ts/projects/side-nav-auth/files/src/app/authentication/services/fakeBackend.ts +88 -0
  66. package/templates/react/igr-ts/projects/side-nav-auth/files/src/app/authentication/services/jwtUtil.ts +10 -0
  67. package/templates/react/igr-ts/projects/side-nav-auth/files/src/app/authentication/services/pkce.ts +29 -0
  68. package/templates/react/igr-ts/projects/side-nav-auth/files/src/app/authentication/services/userStore.ts +39 -0
  69. package/templates/react/igr-ts/projects/side-nav-auth/index.d.ts +15 -0
  70. package/templates/react/igr-ts/projects/side-nav-auth/index.js +46 -0
  71. package/templates/react/igr-ts/projects/side-nav-mini/files/src/app/app-routes.tsx +5 -0
  72. package/templates/react/igr-ts/projects/side-nav-mini/files/src/app/app.css +109 -0
  73. package/templates/react/igr-ts/projects/side-nav-mini/files/src/app/app.test.tsx +20 -0
  74. package/templates/react/igr-ts/projects/side-nav-mini/files/src/app/app.tsx +81 -0
  75. package/templates/react/igr-ts/projects/side-nav-mini/files/src/app/home/home.tsx +69 -0
  76. package/templates/react/igr-ts/projects/side-nav-mini/files/src/app/home/style.module.css +105 -0
  77. package/templates/react/igr-ts/projects/side-nav-mini/index.d.ts +15 -0
  78. package/templates/react/igr-ts/projects/side-nav-mini/index.js +46 -0
  79. package/templates/react/igr-ts/projects/side-nav-mini-auth/files/src/app/app.css +106 -0
  80. package/templates/react/igr-ts/projects/side-nav-mini-auth/files/src/app/app.tsx +101 -0
  81. package/templates/react/igr-ts/projects/side-nav-mini-auth/index.d.ts +15 -0
  82. package/templates/react/igr-ts/projects/side-nav-mini-auth/index.js +50 -0
  83. package/templates/webcomponents/igc-ts/projects/_base/files/src/app/app.ts +6 -1
  84. package/templates/webcomponents/igc-ts/projects/_base/files/styles.css +1 -0
  85. package/templates/webcomponents/igc-ts/projects/_base_with_home/files/index.html +2 -0
  86. package/templates/webcomponents/igc-ts/projects/_base_with_home/files/src/app/home/home.ts +103 -9
  87. package/templates/webcomponents/igc-ts/projects/_base_with_home/files/src/assets/wc.png +0 -0
  88. package/templates/webcomponents/igc-ts/projects/ai-config/files/skills/igniteui-wc-choose-components/SKILL.md +122 -160
  89. package/templates/webcomponents/igc-ts/projects/ai-config/files/skills/igniteui-wc-customize-component-theme/SKILL.md +83 -311
  90. package/templates/webcomponents/igc-ts/projects/ai-config/files/skills/igniteui-wc-customize-component-theme/references/mcp-setup.md +69 -0
  91. package/templates/webcomponents/igc-ts/projects/ai-config/files/skills/igniteui-wc-generate-from-image-design/SKILL.md +4 -1
  92. package/templates/webcomponents/igc-ts/projects/ai-config/files/skills/igniteui-wc-generate-from-image-design/references/component-mapping.md +60 -61
  93. package/templates/webcomponents/igc-ts/projects/ai-config/files/skills/igniteui-wc-generate-from-image-design/references/gotchas.md +15 -11
  94. package/templates/webcomponents/igc-ts/projects/ai-config/files/skills/igniteui-wc-migrate-grid-lite-to-premium/SKILL.md +446 -0
  95. package/templates/webcomponents/igc-ts/projects/ai-config/files/skills/igniteui-wc-optimize-bundle-size/SKILL.md +23 -274
  96. package/templates/webcomponents/igc-ts/projects/empty/index.js +1 -1
  97. package/templates/webcomponents/igc-ts/projects/side-nav/files/index.html +21 -0
  98. package/templates/webcomponents/igc-ts/projects/side-nav/files/src/app/app-routing.ts +9 -0
  99. package/templates/webcomponents/igc-ts/projects/side-nav/files/src/app/app.ts +192 -22
  100. package/templates/webcomponents/igc-ts/projects/side-nav/files/src/app/home/home.ts +175 -0
  101. package/templates/webcomponents/igc-ts/projects/side-nav/index.js +1 -1
  102. package/templates/webcomponents/igc-ts/projects/side-nav-auth/files/index.html +25 -0
  103. package/templates/webcomponents/igc-ts/projects/side-nav-auth/files/src/app/app-routing.ts +37 -0
  104. package/templates/webcomponents/igc-ts/projects/side-nav-auth/files/src/app/app.ts +251 -0
  105. package/templates/webcomponents/igc-ts/projects/side-nav-auth/files/src/app/authentication/login-bar/login-bar.ts +124 -0
  106. package/templates/webcomponents/igc-ts/projects/side-nav-auth/files/src/app/authentication/login-dialog/login-dialog.ts +253 -0
  107. package/templates/webcomponents/igc-ts/projects/side-nav-auth/files/src/app/authentication/models/external-login.ts +10 -0
  108. package/templates/webcomponents/igc-ts/projects/side-nav-auth/files/src/app/authentication/models/login.ts +4 -0
  109. package/templates/webcomponents/igc-ts/projects/side-nav-auth/files/src/app/authentication/models/register-info.ts +6 -0
  110. package/templates/webcomponents/igc-ts/projects/side-nav-auth/files/src/app/authentication/models/user.ts +19 -0
  111. package/templates/webcomponents/igc-ts/projects/side-nav-auth/files/src/app/authentication/services/authentication.ts +37 -0
  112. package/templates/webcomponents/igc-ts/projects/side-nav-auth/files/src/app/authentication/services/external-auth-config.ts +44 -0
  113. package/templates/webcomponents/igc-ts/projects/side-nav-auth/files/src/app/authentication/services/externalAuth.ts +272 -0
  114. package/templates/webcomponents/igc-ts/projects/side-nav-auth/files/src/app/authentication/services/fakeBackend.ts +88 -0
  115. package/templates/webcomponents/igc-ts/projects/side-nav-auth/files/src/app/authentication/services/jwtUtil.ts +10 -0
  116. package/templates/webcomponents/igc-ts/projects/side-nav-auth/files/src/app/authentication/services/pkce.ts +29 -0
  117. package/templates/webcomponents/igc-ts/projects/side-nav-auth/files/src/app/authentication/services/userStore.ts +39 -0
  118. package/templates/webcomponents/igc-ts/projects/side-nav-auth/files/src/app/profile/profile.ts +142 -0
  119. package/templates/webcomponents/igc-ts/projects/side-nav-auth/files/src/app/redirect/redirect-facebook.ts +57 -0
  120. package/templates/webcomponents/igc-ts/projects/side-nav-auth/files/src/app/redirect/redirect-google.ts +53 -0
  121. package/templates/webcomponents/igc-ts/projects/side-nav-auth/files/src/app/redirect/redirect-microsoft.ts +53 -0
  122. package/templates/webcomponents/igc-ts/projects/side-nav-auth/index.d.ts +15 -0
  123. package/templates/webcomponents/igc-ts/projects/side-nav-auth/index.js +46 -0
  124. package/templates/webcomponents/igc-ts/projects/side-nav-mini/files/src/app/app-routing.ts +13 -0
  125. package/templates/webcomponents/igc-ts/projects/side-nav-mini/files/src/app/app.ts +238 -0
  126. package/templates/webcomponents/igc-ts/projects/side-nav-mini/index.d.ts +14 -0
  127. package/templates/webcomponents/igc-ts/projects/side-nav-mini/index.js +45 -0
  128. package/templates/webcomponents/igc-ts/projects/side-nav-mini-auth/files/src/app/app.ts +258 -0
  129. package/templates/webcomponents/igc-ts/projects/side-nav-mini-auth/index.d.ts +15 -0
  130. package/templates/webcomponents/igc-ts/projects/side-nav-mini-auth/index.js +50 -0
  131. package/templates/react/igr-ts/projects/top-nav/files/src/app/app.css +0 -62
  132. package/templates/react/igr-ts/projects/top-nav/files/src/app/app.tsx +0 -18
  133. package/templates/react/igr-ts/projects/top-nav/files/src/components/navigation-header/index.tsx +0 -19
  134. /package/templates/react/igr-ts/projects/{top-nav → side-nav}/files/src/app/app.test.tsx +0 -0
@@ -0,0 +1,175 @@
1
+ import { css, html, LitElement } from 'lit';
2
+ import { customElement } from 'lit/decorators.js';
3
+ import {
4
+ defineComponents,
5
+ IgcIconComponent,
6
+ } from 'igniteui-webcomponents';
7
+
8
+ defineComponents(IgcIconComponent);
9
+
10
+ @customElement('app-home')
11
+ export class HomeComponent extends LitElement {
12
+ static styles = css`
13
+ :host {
14
+ display: flex;
15
+ width: 100%;
16
+ min-height: 100%;
17
+ }
18
+
19
+ .home {
20
+ width: 100%;
21
+ max-width: 920px;
22
+ margin: auto;
23
+ padding: 48px 24px;
24
+ box-sizing: border-box;
25
+ font-family: "Titillium Web", "Segoe UI", Arial, sans-serif;
26
+ }
27
+
28
+ .home__intro {
29
+ max-width: 720px;
30
+ margin: 0 auto 24px;
31
+ text-align: center;
32
+ }
33
+
34
+ h1 {
35
+ margin: 0 0 12px;
36
+ color: #09f;
37
+ font-size: 3rem;
38
+ font-weight: 600;
39
+ line-height: 1.2;
40
+ }
41
+
42
+ .home__description {
43
+ margin: 0;
44
+ color: #000;
45
+ font-size: 1.125rem;
46
+ line-height: 1.5;
47
+ }
48
+
49
+ .home__image {
50
+ display: block;
51
+ width: 500px;
52
+ height: 350px;
53
+ margin: 0 auto 28px;
54
+ max-width: 100%;
55
+ object-fit: contain;
56
+ }
57
+
58
+ .home__resources {
59
+ display: grid;
60
+ grid-template-columns: repeat(2, 300px);
61
+ justify-content: center;
62
+ margin: 0 auto;
63
+ gap: 12px 64px;
64
+ }
65
+
66
+ .home__resource {
67
+ display: flex;
68
+ align-items: center;
69
+ min-height: 64px;
70
+ padding: 6px 0;
71
+ color: rgba(0, 0, 0, .74);
72
+ text-align: left;
73
+ text-decoration: none;
74
+ }
75
+
76
+ .home__resource:hover strong {
77
+ text-decoration: underline;
78
+ }
79
+
80
+ .home__resource igc-icon {
81
+ flex: 0 0 28px;
82
+ margin-right: 16px;
83
+ color: #09f;
84
+ font-size: 28px;
85
+ }
86
+
87
+ .home__resource strong,
88
+ .home__resource small {
89
+ display: block;
90
+ }
91
+
92
+ .home__resource strong {
93
+ margin-bottom: 2px;
94
+ color: #731963;
95
+ font-size: 1rem;
96
+ }
97
+
98
+ .home__resource small {
99
+ color: #000;
100
+ font-size: 0.875rem;
101
+ line-height: 1.4;
102
+ }
103
+
104
+ @media (max-width: 768px) {
105
+ .home {
106
+ padding: 32px 16px;
107
+ }
108
+
109
+ h1 {
110
+ font-size: 2.25rem;
111
+ }
112
+
113
+ .home__image {
114
+ width: 100%;
115
+ height: 240px;
116
+ }
117
+
118
+ .home__resources {
119
+ grid-template-columns: minmax(0, 300px);
120
+ justify-content: center;
121
+ gap: 4px;
122
+ }
123
+ }
124
+ `;
125
+
126
+ render() {
127
+ return html`
128
+ <main class="home">
129
+ <div class="home__intro">
130
+ <h1>Welcome to Ignite UI for Web Components!</h1>
131
+ <p class="home__description">
132
+ A routed application shell with a responsive side navigation drawer and curated Ignite UI resources.
133
+ </p>
134
+ </div>
135
+
136
+ <img
137
+ src="./src/assets/astronaut-components.svg"
138
+ class="home__image"
139
+ alt="Ignite UI for Web Components"
140
+ >
141
+
142
+ <div class="home__resources" role="navigation" aria-label="Ignite UI resources">
143
+ <a class="home__resource" href="https://www.infragistics.com/products/ignite-ui-web-components" target="_blank" rel="noopener noreferrer">
144
+ <igc-icon name="apps" collection="material"></igc-icon>
145
+ <span>
146
+ <strong>Component Demos</strong>
147
+ <small>Browse Web Components demos and examples</small>
148
+ </span>
149
+ </a>
150
+ <a class="home__resource" href="https://github.com/IgniteUI/igniteui-webcomponents" target="_blank" rel="noopener noreferrer">
151
+ <igc-icon name="code" collection="material"></igc-icon>
152
+ <span>
153
+ <strong>Web Components Repository</strong>
154
+ <small>Explore Ignite UI for Web Components on GitHub</small>
155
+ </span>
156
+ </a>
157
+ <a class="home__resource" href="https://github.com/IgniteUI/igniteui-cli" target="_blank" rel="noopener noreferrer">
158
+ <igc-icon name="build" collection="material"></igc-icon>
159
+ <span>
160
+ <strong>Ignite UI CLI</strong>
161
+ <small>Review the CLI source and project tooling</small>
162
+ </span>
163
+ </a>
164
+ <a class="home__resource" href="https://www.figma.com/@infragistics" target="_blank" rel="noopener noreferrer">
165
+ <igc-icon name="palette" collection="material"></igc-icon>
166
+ <span>
167
+ <strong>Figma UI Kit</strong>
168
+ <small>Open Infragistics design resources</small>
169
+ </span>
170
+ </a>
171
+ </div>
172
+ </main>
173
+ `;
174
+ }
175
+ }
@@ -30,7 +30,7 @@ class SideNavProject extends _base_with_home_1.BaseWithHomeIgcProject {
30
30
  constructor() {
31
31
  super(...arguments);
32
32
  this.id = "side-nav";
33
- this.name = "Default side navigation";
33
+ this.name = "Side navigation default";
34
34
  this.description = "Project structure with side navigation drawer";
35
35
  this.framework = "webcomponents";
36
36
  this.projectType = "igc-ts";
@@ -0,0 +1,25 @@
1
+ <!doctype html>
2
+ <html lang="en-GB">
3
+
4
+ <head>
5
+ <meta charset="utf-8">
6
+ <base href="/">
7
+ <meta name="viewport" content="width=device-width, initial-scale=1">
8
+ <title>Ignite UI for Web Components</title>
9
+ <link rel="icon" type="image/png" href="./src/assets/wc.png">
10
+ <link href="https://fonts.googleapis.com/css?family=Titillium+Web:300,400,600,700" rel="stylesheet">
11
+ <link rel="stylesheet" href="./node_modules/igniteui-webcomponents/themes/light/material.css">
12
+ <link rel="stylesheet" href="./styles.css">
13
+ <!-- Facebook JS SDK — required only when facebook is configured in external-auth-config.ts.
14
+ Remove this script if you are not using Facebook login. -->
15
+ <script async defer crossorigin="anonymous"
16
+ src="https://connect.facebook.net/en_US/sdk.js"></script>
17
+ </head>
18
+
19
+ <body class="ig-scrollbar">
20
+ <app-root></app-root>
21
+
22
+ <script type="module" src="./src/index.ts"></script>
23
+ </body>
24
+
25
+ </html>
@@ -0,0 +1,37 @@
1
+ import { type Route } from '@vaadin/router';
2
+ import { UserStore } from './authentication/services/userStore.js';
3
+ import './home/home.js';
4
+ import './not-found/not-found.js';
5
+ import './profile/profile.js';
6
+ import './redirect/redirect-google.js';
7
+ import './redirect/redirect-microsoft.js';
8
+ import './redirect/redirect-facebook.js';
9
+
10
+ export interface AppRoute extends Route {
11
+ icon?: string;
12
+ requiresAuth?: boolean;
13
+ }
14
+
15
+ function authGuard(_context: any, commands: any) {
16
+ if (!UserStore.getUser()) {
17
+ return commands.redirect('/');
18
+ }
19
+ return undefined;
20
+ }
21
+
22
+ export const routes: AppRoute[] = [
23
+ { path: '/', component: 'app-home', name: 'Home', icon: 'home' },
24
+ {
25
+ path: '/auth/profile',
26
+ component: 'app-profile',
27
+ name: 'Profile',
28
+ icon: 'account_circle',
29
+ requiresAuth: true,
30
+ action: authGuard,
31
+ },
32
+ { path: '/auth/redirect-google', component: 'app-redirect-google' },
33
+ { path: '/auth/redirect-microsoft', component: 'app-redirect-microsoft' },
34
+ { path: '/auth/redirect-facebook', component: 'app-redirect-facebook' },
35
+ // The fallback route should always be after other alternatives.
36
+ { path: '(.*)', component: 'app-not-found' },
37
+ ];
@@ -0,0 +1,251 @@
1
+ import { Router } from '@vaadin/router';
2
+ import { css, html, LitElement } from 'lit';
3
+ import { customElement, state } from 'lit/decorators.js';
4
+ import {
5
+ defineComponents,
6
+ IgcIconComponent,
7
+ IgcNavDrawerComponent,
8
+ IgcNavDrawerItemComponent,
9
+ registerIcon,
10
+ } from 'igniteui-webcomponents';
11
+ import { routes, type AppRoute } from './app-routing.js';
12
+ import { UserStore } from './authentication/services/userStore.js';
13
+ import './authentication/login-bar/login-bar.js';
14
+
15
+ defineComponents(
16
+ IgcIconComponent,
17
+ IgcNavDrawerComponent,
18
+ IgcNavDrawerItemComponent,
19
+ );
20
+
21
+ const materialIcons = [
22
+ ['home', 'action/svg/production/ic_home_24px.svg'],
23
+ ['menu', 'navigation/svg/production/ic_menu_24px.svg'],
24
+ ['apps', 'navigation/svg/production/ic_apps_24px.svg'],
25
+ ['code', 'action/svg/production/ic_code_24px.svg'],
26
+ ['build', 'action/svg/production/ic_build_24px.svg'],
27
+ ['palette', 'image/svg/production/ic_palette_24px.svg'],
28
+ ['account_circle', 'action/svg/production/ic_account_circle_24px.svg'],
29
+ ['lock', 'action/svg/production/ic_lock_24px.svg'],
30
+ ['assignment_ind', 'action/svg/production/ic_assignment_ind_24px.svg'],
31
+ ] as const;
32
+
33
+ materialIcons.forEach(([name, path]) =>
34
+ registerIcon(name, `https://unpkg.com/material-design-icons@3.0.1/${path}`, 'material')
35
+ );
36
+
37
+ @customElement('app-root')
38
+ export default class App extends LitElement {
39
+ @state()
40
+ private drawerOpen = true;
41
+
42
+ @state()
43
+ private drawerPosition: 'relative' | 'start' = 'relative';
44
+
45
+ @state()
46
+ private currentPath = window.location.pathname;
47
+
48
+ @state()
49
+ private isLoggedIn = Boolean(UserStore.getUser());
50
+
51
+ private mediaQuery?: MediaQueryList;
52
+
53
+ static styles = css`
54
+ :host {
55
+ display: flex;
56
+ height: 100%;
57
+ }
58
+
59
+ .app {
60
+ display: flex;
61
+ flex-flow: column nowrap;
62
+ width: 100%;
63
+ height: 100%;
64
+ overflow: hidden;
65
+ }
66
+
67
+ .app__navbar {
68
+ display: flex;
69
+ align-items: center;
70
+ flex: 0 0 auto;
71
+ height: 56px;
72
+ padding: 0 16px;
73
+ background: #239ef0;
74
+ box-shadow: 0 2px 4px rgba(0, 0, 0, .24);
75
+ box-sizing: border-box;
76
+ position: relative;
77
+ z-index: 10;
78
+ }
79
+
80
+ .app__menu-button {
81
+ display: inline-flex;
82
+ align-items: center;
83
+ justify-content: center;
84
+ width: 40px;
85
+ height: 40px;
86
+ padding: 0;
87
+ color: #000;
88
+ border: 0;
89
+ background: transparent;
90
+ cursor: pointer;
91
+ }
92
+
93
+ .app__menu-button igc-icon {
94
+ font-size: 24px;
95
+ }
96
+
97
+ .app__title {
98
+ margin: 0 0 0 16px;
99
+ color: #000;
100
+ font-size: 1.25rem;
101
+ font-weight: 600;
102
+ line-height: 1;
103
+ }
104
+
105
+ .app__navbar-spacer {
106
+ flex: 1 1 auto;
107
+ }
108
+
109
+ .app__body {
110
+ display: flex;
111
+ flex: 1 1 auto;
112
+ min-height: 0;
113
+ }
114
+
115
+ .app__drawer {
116
+ flex: 0 0 auto;
117
+ height: 100%;
118
+ --menu-full-width: 280px;
119
+ }
120
+
121
+ igc-nav-drawer-item::part(base) {
122
+ min-height: 48px;
123
+ color: #2d2d2d;
124
+ }
125
+
126
+ igc-nav-drawer-item[active]::part(base) {
127
+ background: #e0f2ff;
128
+ color: #0075d2;
129
+ }
130
+
131
+ igc-nav-drawer-item[active] igc-icon {
132
+ color: #0075d2;
133
+ }
134
+
135
+ igc-nav-drawer-item:not([active]) igc-icon {
136
+ color: #2d2d2d;
137
+ }
138
+
139
+ router-outlet {
140
+ flex: 1 1 auto;
141
+ display: flex;
142
+ align-items: stretch;
143
+ justify-content: center;
144
+ min-width: 0;
145
+ overflow: auto;
146
+ }
147
+ `;
148
+
149
+ render() {
150
+ const visibleRoutes = (routes as AppRoute[]).filter((route) => {
151
+ if (!route.name) return false;
152
+ if (route.requiresAuth && !this.isLoggedIn) return false;
153
+ return true;
154
+ });
155
+
156
+ return html`
157
+ <div class="app">
158
+ <header class="app__navbar">
159
+ <button
160
+ class="app__menu-button"
161
+ type="button"
162
+ aria-label="Toggle navigation"
163
+ @click=${this.toggleDrawer}
164
+ >
165
+ <igc-icon name="menu" collection="material"></igc-icon>
166
+ </button>
167
+ <h1 class="app__title">$(name)</h1>
168
+ <div class="app__navbar-spacer"></div>
169
+ <auth-login-bar @auth-change=${this.handleAuthChange}></auth-login-bar>
170
+ </header>
171
+ <div class="app__body">
172
+ <igc-nav-drawer
173
+ class="app__drawer"
174
+ ?open=${this.drawerOpen}
175
+ position=${this.drawerPosition}
176
+ >
177
+ ${visibleRoutes.map((route) => html`
178
+ <igc-nav-drawer-item
179
+ ?active=${this.currentPath === route.path}
180
+ @click=${() => this.navigate(route.path)}
181
+ >
182
+ <igc-icon
183
+ slot="icon"
184
+ name=${route.icon || 'home'}
185
+ collection="material"
186
+ ></igc-icon>
187
+ <span slot="content">${route.name}</span>
188
+ </igc-nav-drawer-item>
189
+ `)}
190
+ </igc-nav-drawer>
191
+ <router-outlet></router-outlet>
192
+ </div>
193
+ </div>
194
+ `;
195
+ }
196
+
197
+ connectedCallback() {
198
+ super.connectedCallback();
199
+
200
+ this.mediaQuery = window.matchMedia('(min-width: 1025px)');
201
+ this.updateDrawerState();
202
+ this.mediaQuery.addEventListener('change', this.updateDrawerState);
203
+ window.addEventListener('popstate', this.updateCurrentPath);
204
+ // Listen globally so redirect components (Google/Facebook/Microsoft) in the router
205
+ // outlet can also trigger a shell state update after a successful OAuth redirect.
206
+ window.addEventListener('auth-change', this.handleAuthChange);
207
+ }
208
+
209
+ disconnectedCallback() {
210
+ this.mediaQuery?.removeEventListener('change', this.updateDrawerState);
211
+ window.removeEventListener('popstate', this.updateCurrentPath);
212
+ window.removeEventListener('auth-change', this.handleAuthChange);
213
+
214
+ super.disconnectedCallback();
215
+ }
216
+
217
+ firstUpdated() {
218
+ const outlet = this.shadowRoot?.querySelector('router-outlet');
219
+ const router = new Router(outlet);
220
+ router.setRoutes(routes);
221
+ }
222
+
223
+ private toggleDrawer = () => {
224
+ this.drawerOpen = !this.drawerOpen;
225
+ };
226
+
227
+ private navigate(path: string) {
228
+ this.currentPath = path;
229
+ Router.go(path);
230
+
231
+ if (!this.mediaQuery?.matches) {
232
+ this.drawerOpen = false;
233
+ }
234
+ }
235
+
236
+ private updateDrawerState = () => {
237
+ const pinned = Boolean(this.mediaQuery?.matches);
238
+
239
+ this.drawerOpen = pinned;
240
+ this.drawerPosition = pinned ? 'relative' : 'start';
241
+ };
242
+
243
+ private updateCurrentPath = () => {
244
+ this.currentPath = window.location.pathname;
245
+ };
246
+
247
+ private handleAuthChange = () => {
248
+ this.isLoggedIn = Boolean(UserStore.getUser());
249
+ this.currentPath = window.location.pathname;
250
+ };
251
+ }
@@ -0,0 +1,124 @@
1
+ import { LitElement, html, css } from 'lit';
2
+ import { customElement, state } from 'lit/decorators.js';
3
+ import { Router } from '@vaadin/router';
4
+ import { defineComponents, IgcAvatarComponent, IgcButtonComponent, IgcDropdownComponent, IgcDropdownItemComponent } from 'igniteui-webcomponents';
5
+ import { UserStore } from '../services/userStore.js';
6
+ import { ExternalAuth } from '../services/externalAuth.js';
7
+ import type { User } from '../models/user.js';
8
+ import '../login-dialog/login-dialog.js';
9
+
10
+ defineComponents(IgcAvatarComponent, IgcButtonComponent, IgcDropdownComponent, IgcDropdownItemComponent);
11
+
12
+ @customElement('auth-login-bar')
13
+ export class LoginBarElement extends LitElement {
14
+ @state() private currentUser: User | null = UserStore.getUser();
15
+
16
+ static styles = css`
17
+ :host {
18
+ display: contents;
19
+ }
20
+
21
+ .login-btn::part(base) {
22
+ color: #0075d2;
23
+ background: #fff;
24
+ border-color: rgba(0, 117, 210, 0.35);
25
+ font-weight: 600;
26
+ white-space: nowrap;
27
+ }
28
+
29
+ .login-btn::part(base):hover {
30
+ background: #e8f3fc;
31
+ }
32
+
33
+ .profile-avatar {
34
+ cursor: pointer;
35
+ color: #0075d2;
36
+ --ig-avatar-background: #fff;
37
+ --ig-avatar-color: #0075d2;
38
+ --ig-avatar-initials-font-size: 0.875rem;
39
+ }
40
+
41
+ igc-dropdown-item:hover,
42
+ igc-dropdown-item[active]:hover {
43
+ background: #e8f3fc;
44
+ color: #0075d2;
45
+ }
46
+
47
+ igc-dropdown-item[active] {
48
+ background: #e8f3fc;
49
+ color: #0075d2;
50
+ }
51
+
52
+ igc-dropdown-item[selected],
53
+ igc-dropdown-item[selected]:hover,
54
+ igc-dropdown-item[selected][active] {
55
+ background: #e8f3fc;
56
+ color: #0075d2;
57
+ }
58
+
59
+ .profile-avatar:focus-visible {
60
+ outline: 2px solid #fff;
61
+ outline-offset: 2px;
62
+ }
63
+ `;
64
+
65
+ connectedCallback() {
66
+ super.connectedCallback();
67
+ this.addEventListener('auth-change', this.handleAuthChange as EventListener);
68
+ }
69
+
70
+ disconnectedCallback() {
71
+ this.removeEventListener('auth-change', this.handleAuthChange as EventListener);
72
+ super.disconnectedCallback();
73
+ }
74
+
75
+ private handleAuthChange = () => {
76
+ this.currentUser = UserStore.getUser();
77
+ };
78
+
79
+ private handleMenuSelect(e: CustomEvent) {
80
+ // igcChange detail is the selected IgcDropdownItemComponent element
81
+ const value = (e.detail as any)?.value;
82
+ if (value === 'profile') {
83
+ Router.go('/auth/profile');
84
+ } else if (value === 'logout') {
85
+ ExternalAuth.logout();
86
+ UserStore.clearUser();
87
+ this.currentUser = null;
88
+ Router.go('/');
89
+ }
90
+ }
91
+
92
+ render() {
93
+ if (!this.currentUser) {
94
+ return html`
95
+ <igc-button variant="outlined" class="login-btn" @click=${() => (this.shadowRoot?.querySelector('auth-login-dialog') as any)?.open()}>Log In</igc-button>
96
+ <auth-login-dialog @auth-change=${this.handleAuthChange}></auth-login-dialog>
97
+ `;
98
+ }
99
+
100
+ const initials = UserStore.getInitials(this.currentUser);
101
+
102
+ return html`
103
+ <igc-dropdown placement="bottom-end" @igcChange=${this.handleMenuSelect}>
104
+ <igc-avatar
105
+ slot="target"
106
+ class="profile-avatar"
107
+ shape="circle"
108
+ size="small"
109
+ src=${this.currentUser.picture ?? ''}
110
+ tabindex="0"
111
+ aria-label="Open profile menu"
112
+ >${initials}</igc-avatar>
113
+ <igc-dropdown-item value="profile">Profile</igc-dropdown-item>
114
+ <igc-dropdown-item value="logout">Log Out</igc-dropdown-item>
115
+ </igc-dropdown>
116
+ `;
117
+ }
118
+ }
119
+
120
+ declare global {
121
+ interface HTMLElementTagNameMap {
122
+ 'auth-login-bar': LoginBarElement;
123
+ }
124
+ }