sagittarius-admin-template 0.0.0-stage → 0.2.0
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/LICENSE +21 -0
- package/README.md +174 -2
- package/fesm2022/sagittarius-admin-template.mjs +399 -0
- package/fesm2022/sagittarius-admin-template.mjs.map +1 -0
- package/index.d.ts +203 -0
- package/package.json +56 -3
- package/styles/sagittarius-admin.scss +496 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-2026 Marian Spisiak
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,175 @@
|
|
|
1
|
-
#
|
|
1
|
+
# sagittarius-admin-template
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Admin application layout for **Angular 20 + Angular Material 3**: collapsible sidebar (hover overlay on desktop, full-screen overlay on mobile), header with user menu, content area with **stacked drawers**, footer. Ships with design tokens (light/dark theme) and CSS utility classes for building pages.
|
|
4
|
+
|
|
5
|
+
- **Live demo:** https://majo32.github.io/sagittarius-admin-template/
|
|
6
|
+
- **Source & demo app:** https://github.com/majo32/sagittarius-admin-template
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm i sagittarius-admin-template
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Peer dependencies: `@angular/core`, `@angular/common`, `@angular/router`, `@angular/material`, `@angular/cdk` (20.x).
|
|
15
|
+
|
|
16
|
+
`angular.json` → `styles` (template stylesheet before your own styles):
|
|
17
|
+
|
|
18
|
+
```json
|
|
19
|
+
"styles": [
|
|
20
|
+
"node_modules/sagittarius-admin-template/styles/sagittarius-admin.scss",
|
|
21
|
+
"src/styles.scss"
|
|
22
|
+
]
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
`index.html` – fonts and icons:
|
|
26
|
+
|
|
27
|
+
```html
|
|
28
|
+
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;600;700&display=swap" rel="stylesheet">
|
|
29
|
+
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
`styles.scss` – Material theme (the primary color is picked up by the template as well):
|
|
33
|
+
|
|
34
|
+
```scss
|
|
35
|
+
@use '@angular/material' as mat;
|
|
36
|
+
|
|
37
|
+
html {
|
|
38
|
+
color-scheme: light;
|
|
39
|
+
@include mat.theme((color: (primary: mat.$azure-palette), typography: Roboto, density: 0));
|
|
40
|
+
|
|
41
|
+
&.dark-theme { color-scheme: dark; }
|
|
42
|
+
}
|
|
43
|
+
body { margin: 0; }
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Usage
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
import { SagittariusAdmin, SgMenuItem, SgUser, SgUserMenuItem } from 'sagittarius-admin-template';
|
|
50
|
+
|
|
51
|
+
@Component({
|
|
52
|
+
selector: 'app-root',
|
|
53
|
+
imports: [RouterOutlet, SagittariusAdmin],
|
|
54
|
+
template: `
|
|
55
|
+
<lib-sagittarius-admin appTitle="My application" [menuItems]="menu" [user]="user" [userMenuItems]="userMenu">
|
|
56
|
+
<div sg-admin-header-actions>…icon buttons…</div>
|
|
57
|
+
<router-outlet />
|
|
58
|
+
<span sg-admin-footer>© 2026 My Company</span>
|
|
59
|
+
</lib-sagittarius-admin>
|
|
60
|
+
`,
|
|
61
|
+
})
|
|
62
|
+
export class App {
|
|
63
|
+
menu: SgMenuItem[] = [
|
|
64
|
+
{ label: 'Dashboard', icon: 'space_dashboard', route: '/dashboard' },
|
|
65
|
+
{ label: 'Management', spacer: true },
|
|
66
|
+
{ label: 'Users', icon: 'group', route: '/users', badge: 3 },
|
|
67
|
+
];
|
|
68
|
+
user: SgUser = { name: 'Jane Doe', subtitle: 'Administrator' };
|
|
69
|
+
userMenu: SgUserMenuItem[] = [
|
|
70
|
+
{ label: 'Profile', icon: 'person', route: '/profile' },
|
|
71
|
+
{ divider: true },
|
|
72
|
+
{ label: 'Sign out', icon: 'logout', action: () => this.logout() },
|
|
73
|
+
];
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
**Inputs:** `appTitle`, `appShortTitle`, `logoUrl`, `homeRoute`, `menuItems`, `user`, `userMenuItems`, `persistSidebarState` (stores the collapsed state in `localStorage`).
|
|
78
|
+
**Outputs:** `userMenuItemClick`.
|
|
79
|
+
|
|
80
|
+
**Content slots** (attribute on the projected element):
|
|
81
|
+
|
|
82
|
+
| Slot | Position |
|
|
83
|
+
|---|---|
|
|
84
|
+
| *(none)* | main content – typically `<router-outlet />` |
|
|
85
|
+
| `sg-admin-header-left` | left part of the header (breadcrumbs, title) |
|
|
86
|
+
| `sg-admin-header-middle` | middle of the header |
|
|
87
|
+
| `sg-admin-header-actions` | right side of the header, before the avatar |
|
|
88
|
+
| `sg-admin-sidebar-bottom` | bottom of the sidebar below the menu |
|
|
89
|
+
| `sg-admin-footer` | footer (defaults to `appTitle`) |
|
|
90
|
+
|
|
91
|
+
## Drawer
|
|
92
|
+
|
|
93
|
+
```ts
|
|
94
|
+
private drawer = inject(DrawerService);
|
|
95
|
+
|
|
96
|
+
openDetail(user: User) {
|
|
97
|
+
this.drawer.open(UserDetail, { userId: user.id }, { title: user.name });
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
@Component({ /* … */ })
|
|
103
|
+
export class UserDetail {
|
|
104
|
+
readonly userId = input.required<number>();
|
|
105
|
+
private drawerRef = inject(DrawerRef);
|
|
106
|
+
|
|
107
|
+
save() { /* … */ this.drawerRef.close(); }
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
- `data` (2nd argument) are the component inputs – signal `input()`s are set via `setInput`, other keys are assigned to the instance.
|
|
112
|
+
- Layers can be nested (detail → edit); a nested layer shows a back arrow, the first one a close button.
|
|
113
|
+
- The browser / mobile **Back button closes the top layer**; router navigation (e.g. a menu click) closes all layers.
|
|
114
|
+
- `DrawerRef` offers `close()`, `setTitle()`, `title`, `setFullPageUrl()`, `fullPageUrl`.
|
|
115
|
+
|
|
116
|
+
### Options (`DrawerOptions`)
|
|
117
|
+
|
|
118
|
+
| Option | Type | Default | Description |
|
|
119
|
+
|---|---|---|---|
|
|
120
|
+
| `title` | `string` | `''` | Title in the drawer header (runtime: `DrawerRef.setTitle()`). |
|
|
121
|
+
| `fullPageUrl` | `string \| any[]` | – | URL of a standalone page with the same content. When set, an icon link in the header closes all layers and navigates there (replacing the drawer history entry). |
|
|
122
|
+
| `fullPageIcon` | `string` | `open_in_full` | Material icon of that link. |
|
|
123
|
+
| `fullPageLabel` | `string` | `Open as full page` | Tooltip and `aria-label` (default from `SgAdminLabels.drawerFullPage`). |
|
|
124
|
+
|
|
125
|
+
```ts
|
|
126
|
+
this.drawer.open(UserDetail, { userId: user.id }, {
|
|
127
|
+
title: user.name,
|
|
128
|
+
fullPageUrl: ['/users', user.id],
|
|
129
|
+
});
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
A component that is used both inside and outside a drawer should inject the ref optionally: `inject(DrawerRef, { optional: true })`.
|
|
133
|
+
|
|
134
|
+
## Built-in texts (i18n)
|
|
135
|
+
|
|
136
|
+
Aria labels and tooltips rendered by the layout (open/close menu, drawer close/back, full-page link…) are English by default. Provide your own via `provideSgAdminLabels()` – missing keys fall back to English. A Slovak set is included:
|
|
137
|
+
|
|
138
|
+
```ts
|
|
139
|
+
import { SG_ADMIN_LABELS_SK, provideSgAdminLabels } from 'sagittarius-admin-template';
|
|
140
|
+
|
|
141
|
+
bootstrapApplication(App, {
|
|
142
|
+
providers: [
|
|
143
|
+
provideSgAdminLabels(SG_ADMIN_LABELS_SK),
|
|
144
|
+
// or only some keys: provideSgAdminLabels({ drawerClose: 'Schließen', drawerBack: 'Zurück' })
|
|
145
|
+
],
|
|
146
|
+
});
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Keys (`SgAdminLabels`): `openMenu`, `closeMenu`, `expandMenu`, `collapseMenu`, `userMenu`, `drawerClose`, `drawerBack`, `drawerFullPage`.
|
|
150
|
+
|
|
151
|
+
## Theming
|
|
152
|
+
|
|
153
|
+
All colors and sizes are CSS custom properties `--sg-*`. Override them in `:root`:
|
|
154
|
+
|
|
155
|
+
```css
|
|
156
|
+
:root {
|
|
157
|
+
--sg-sidebar-bg: #1a1033;
|
|
158
|
+
--sg-sidebar-accent: #b18cff;
|
|
159
|
+
--sg-sidebar-width: 280px;
|
|
160
|
+
}
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
Dark theme: set `color-scheme: dark` on `<html>` (e.g. with a class, as above).
|
|
164
|
+
|
|
165
|
+
## Page utility classes
|
|
166
|
+
|
|
167
|
+
`sg-page`, `sg-page-header`, `sg-breadcrumbs`, `sg-card`, `sg-grid`, `sg-stat`, `sg-badge`, `sg-avatar`, `sg-toolbar`, `sg-table-clickable`, `sg-form-grid`, `sg-kv`, `sg-empty-state`, `sg-drawer-page`, `sg-muted`… See the demo app for examples of each.
|
|
168
|
+
|
|
169
|
+
## Notes
|
|
170
|
+
|
|
171
|
+
- The sidebar menu supports one level plus section headers.
|
|
172
|
+
|
|
173
|
+
## License
|
|
174
|
+
|
|
175
|
+
MIT
|