@guildofgleks/ui 0.0.1 → 21.2.2

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Roman Malitskyi
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,64 +1,192 @@
1
- # Ui
2
-
3
- This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 21.2.0.
4
-
5
- ## Code scaffolding
6
-
7
- Angular CLI includes powerful code scaffolding tools. To generate a new component, run:
8
-
9
- ```bash
10
- ng generate component component-name
11
- ```
12
-
13
- For a complete list of available schematics (such as `components`, `directives`, or `pipes`), run:
14
-
15
- ```bash
16
- ng generate --help
17
- ```
18
-
19
- ## Building
20
-
21
- To build the library, run:
22
-
23
- ```bash
24
- ng build ui
25
- ```
26
-
27
- This command will compile your project, and the build artifacts will be placed in the `dist/` directory.
28
-
29
- ### Publishing the Library
30
-
31
- Once the project is built, you can publish your library by following these steps:
32
-
33
- 1. Navigate to the `dist` directory:
34
-
35
- ```bash
36
- cd dist/ui
37
- ```
38
-
39
- 2. Run the `npm publish` command to publish your library to the npm registry:
40
- ```bash
41
- npm publish
42
- ```
43
-
44
- ## Running unit tests
45
-
46
- To execute unit tests with the [Karma](https://karma-runner.github.io) test runner, use the following command:
47
-
48
- ```bash
49
- ng test
50
- ```
51
-
52
- ## Running end-to-end tests
53
-
54
- For end-to-end (e2e) testing, run:
55
-
56
- ```bash
57
- ng e2e
58
- ```
59
-
60
- Angular CLI does not come with an end-to-end testing framework by default. You can choose one that suits your needs.
61
-
62
- ## Additional Resources
63
-
64
- For more information on using the Angular CLI, including detailed command references, visit the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page.
1
+ ![NPM Version](https://img.shields.io/npm/v/@guildofgleks/ui?color=red)
2
+ ![Node Version](https://img.shields.io/node/v/@guildofgleks/ui)
3
+ ![Angular 21](https://img.shields.io/badge/Angular-21%2B-dd0031?logo=angular)
4
+ ![NPM Downloads](https://img.shields.io/npm/dm/@guildofgleks/ui)
5
+ ![License](https://img.shields.io/npm/l/@guildofgleks/ui)
6
+
7
+ A lightweight Angular 21 component library. No CDK, no Material the only runtime
8
+ dependencies are `@angular/core`, `@angular/common` and `@angular/forms`.
9
+
10
+ **Tags:** angular, angular21, components, ui-library, design-system, signals, standalone, accessible
11
+
12
+ ## Features
13
+
14
+ - 16 standalone components — accordion, button, checkbox, chip, dialog, icon,
15
+ inputfield, multiselect, paginator, select, skeleton, slider, spinner, table, tag,
16
+ toast plus `DialogService`, `ToastService` and `ThemeService`.
17
+ - Signal-based API throughout: `input()` / `output()` / `model()`, `OnPush` change
18
+ detection, no NgModules.
19
+ - No CDK, no Material — a small dependency footprint on top of `@angular/core`,
20
+ `@angular/common` and `@angular/forms`.
21
+ - Full theming through CSS custom properties: restyle any component, swap the whole
22
+ palette, or ship light/dark and custom themes at runtime via a `data-theme` attribute.
23
+ - `ControlValueAccessor` on every form control (checkbox, inputfield, select,
24
+ multiselect, slider) — works with `formControl`, `formControlName` and `ngModel`.
25
+ - Accessible by default: keyboard navigation, ARIA attributes, WCAG AA contrast.
26
+
27
+ ## Install
28
+
29
+ npm:
30
+
31
+ ```bash
32
+ npm install @guildofgleks/ui
33
+ ```
34
+
35
+ yarn:
36
+
37
+ ```bash
38
+ yarn add @guildofgleks/ui
39
+ ```
40
+
41
+ ## Setup
42
+
43
+ Add the stylesheet once. It carries the baseline theme (every token the components
44
+ read) plus the utility classes the component templates use, so without it components
45
+ render unstyled.
46
+
47
+ ```jsonc
48
+ // angular.json → projects.<app>.architect.build.options
49
+ "styles": [
50
+ "node_modules/@guildofgleks/ui/styles/index.css",
51
+ "src/styles.scss" // your own styles, after the baseline so they win
52
+ ]
53
+ ```
54
+
55
+ Then import a component where you need it:
56
+
57
+ ```ts
58
+ import { Component } from '@angular/core';
59
+ import { ButtonComponent, SelectComponent } from '@guildofgleks/ui';
60
+
61
+ @Component({
62
+ selector: 'app-example',
63
+ imports: [ButtonComponent, SelectComponent],
64
+ template: `
65
+ <gog-select label="Region" [options]="regions" [(value)]="region" />
66
+ <gog-button (gogClick)="save()">Save</gog-button>
67
+ `,
68
+ })
69
+ export class ExampleComponent {
70
+ /* … */
71
+ }
72
+ ```
73
+
74
+ Outputs are prefixed with `gog` (`gogClick`, `gogToggle`) so they never collide with
75
+ native DOM events. Inputs keep their natural names.
76
+
77
+ ## Theming
78
+
79
+ Everything is themed through CSS custom properties, and **every value the components
80
+ paint with lives in `styles/theme.css`** — no component stylesheet holds a colour, font,
81
+ border, radius, shadow, spacing or duration of its own. There are three layers:
82
+
83
+ **1. Foundation tokens** — the palette, type scale, spacing, motion and control metrics.
84
+ Override these to restyle everything at once; the component tokens all derive from them,
85
+ so a palette swap carries through without touching anything else.
86
+
87
+ | Group | Tokens |
88
+ | --- | --- |
89
+ | Palette | `--gog-background-color`, `--gog-surface-color`, `--gog-text-color`, `--gog-accent-text-color`, `--gog-muted-text-color`, `--gog-primary-color`, `--gog-secondary-color`, `--gog-accent-color`, `--gog-accent-bright`, `--gog-accent-dim`, `--gog-accent-pale`, `--gog-border-color`, `--gog-hover-color` |
90
+ | Status | `--gog-success-color`, `--gog-danger-color`, `--gog-warning-color`, `--gog-info-color` |
91
+ | Type | `--gog-font-heading`, `--gog-font-body`, `--gog-font-mono`, `--gog-text-xs` … `--gog-text-3xl` |
92
+ | Geometry | `--gog-radius`, `--gog-space-xs` … `--gog-space-2xl`, `--gog-panel-shadow`, `--gog-panel-radius`, `--gog-panel-border-width`, `--gog-panel-border-style` |
93
+ | Motion | `--gog-duration-fast`, `--gog-duration-base`, `--gog-duration-slow`, `--gog-easing` |
94
+ | Focus / state | `--gog-focus-ring-width`, `--gog-focus-ring-offset`, `--gog-disabled-opacity` |
95
+ | Controls | `--gog-control-padding-y`, `--gog-control-padding-x`, `--gog-control-icon-offset`, `--gog-control-border-width`, `--gog-control-border-style` |
96
+ | Fields | `--gog-field-{xsm,sm,md,lg,slg}-{padding-y,padding-x,font-size,icon-offset,icon-inset}` — shared by input, select and multiselect |
97
+ | Buttons | `--gog-btn-{xsm,sm,md,lg,slg}-padding`, `--gog-btn-{xsm,sm,md,lg,slg}-font-size` |
98
+ | Checkables | `--gog-control-checkbox-padding`, `--gog-control-checkbox-box-size-{xsm…slg}`, `--gog-control-checkbox-label-size-{xsm…slg}`, `--gog-control-checkbox-icon-size-{xsm…slg}` |
99
+ | Overlays | `--gog-dropdown-z`, `--gog-spinner-overlay-z` |
100
+
101
+ **2. Component tokens** — `--gog-<block>-*`, one block per component in `theme.css`, for
102
+ restyling a single component theme-wide. They cover every painted property, including
103
+ per-variant and per-size values (`--gog-btn-ghost-hover-bg`, `--gog-tag-lg-padding-block`,
104
+ `--gog-accordion-sm-chevron-size`, `--gog-skeleton-shine`, `--gog-paginator-gap`, …), plus
105
+ each component's font family, so a theme can decide that e.g. buttons use the body face:
106
+
107
+ ```css
108
+ :root[data-theme='mine'] {
109
+ --gog-btn-font-family: var(--gog-font-body);
110
+ --gog-btn-font-weight: 600;
111
+ --gog-btn-ghost-hover-bg: color-mix(in srgb, var(--gog-accent-color) 20%, transparent);
112
+ --gog-table-hover-bg: var(--gog-hover-color);
113
+ }
114
+ ```
115
+
116
+ **3. Instance tokens** — a small set left deliberately *undeclared* so that setting them
117
+ anywhere always wins over the variant/size classes. This is the per-instance escape
118
+ hatch:
119
+
120
+ ```css
121
+ .my-form gog-button {
122
+ --gog-btn-bg: rebeccapurple; /* beats .gog-btn--primary, unlike a declared token */
123
+ }
124
+ ```
125
+
126
+ They are `--gog-btn-{bg,color,border,shadow,hover-bg,hover-color,hover-shadow,padding,font-size,spinner-color}`,
127
+ `--gog-tag-{accent,bg,border,color,font-size,gap,padding-block,padding-inline,icon-size}`,
128
+ `--gog-chip-{font-size,gap,padding-block,padding-inline,avatar-size,icon-size,remove-size}`,
129
+ the per-size field hooks (`--gog-input-padding-y`, `--gog-select-control-font`,
130
+ `--gog-ms-font-size`, `--gog-table-td-padding-v`, `--gog-accordion-padding-y`, …) and
131
+ `--gog-spinner-color`.
132
+
133
+ ### Light and dark
134
+
135
+ The theme is selected with a `data-theme` attribute on `:root`, and `ThemeService`
136
+ manages it:
137
+
138
+ ```ts
139
+ private readonly theme = inject(ThemeService);
140
+ this.theme.toggleTheme(); // light ⇄ dark
141
+ this.theme.setTheme('cyberpunk'); // any custom theme name
142
+ ```
143
+
144
+ To add a theme, copy a palette block from `styles/theme.css` and change the attribute
145
+ value. A theme only needs to declare what it actually changes — the component tokens are
146
+ re-derived from whatever palette is in scope, so a swapped `--gog-accent-color` reaches every
147
+ component without listing any of them:
148
+
149
+ ```css
150
+ :root[data-theme='cyberpunk'],
151
+ [data-theme='cyberpunk'] {
152
+ color-scheme: dark;
153
+ --gog-background-color: #050816;
154
+ --gog-accent-color: #ff4edb;
155
+ --gog-radius: 22px;
156
+ }
157
+ ```
158
+
159
+ The second selector is what lets a theme apply to a *subtree* rather than the whole page
160
+ — put `data-theme="cyberpunk"` on any element and everything inside it re-derives from
161
+ that palette, so one page can show several themes side by side (see the showcase's Theme
162
+ lab). That works because `theme.css` re-declares its derived layer on `:root, [data-theme]`:
163
+ a custom property's `var()` references are substituted where the property is *declared*,
164
+ so a derived token declared only on `:root` would freeze to the root palette.
165
+
166
+ Corollary worth knowing when writing your own themes: **anything you declare that reads
167
+ another token must sit on the theme scope itself**, not on `:root`, or it will not follow
168
+ a nested theme.
169
+
170
+ ### Optional font preset
171
+
172
+ `styles/index.css` intentionally leaves fonts alone — generic system stacks, no webfont
173
+ download. For the showcase's typography (Cinzel / Inter / JetBrains Mono, pulled from
174
+ Google Fonts) add `@guildofgleks/ui/styles/fonts.css` as well.
175
+
176
+ ## Components
177
+
178
+ `gog-accordion`, `gog-button`, `gog-checkbox`, `gog-chip`, `gog-dialog`, `gog-icon`,
179
+ `gog-inputfield`, `gog-multiselect`, `gog-paginator`, `gog-select`, `gog-skeleton`,
180
+ `gog-slider`, `gog-spinner`, `gog-spinner-overlay`, `gog-table`, `gog-tag`, `gog-toast`.
181
+
182
+ Services: `DialogService`, `ToastService`, `ThemeService`.
183
+
184
+ `gog-checkbox`, `gog-inputfield`, `gog-select`, `gog-multiselect` and `gog-slider`
185
+ implement `ControlValueAccessor`, so they work with `[formControl]`, `formControlName`
186
+ and `ngModel`. With a form control attached, the error message appears once the control
187
+ is both touched and invalid; without one it shows for as long as `errorMessage` is
188
+ non-empty, and the consumer decides when to clear it.
189
+
190
+ ## License
191
+
192
+ MIT © Roman Malitskyi