@deay/ui 0.0.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.
@@ -0,0 +1,7 @@
1
+ {
2
+ "$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
3
+ "dest": "../../dist/ui",
4
+ "lib": {
5
+ "entryFile": "src/public-api.ts"
6
+ }
7
+ }
package/package.json ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "@deay/ui",
3
+ "version": "0.0.1",
4
+ "type": "module",
5
+ "peerDependencies": {
6
+ "@angular/core": "^19.0.0",
7
+ "@angular/common": "^19.0.0",
8
+ "@angular/forms": "^19.0.0"
9
+ },
10
+ "dependencies": {
11
+ "tslib": "^2.3.0"
12
+ },
13
+ "scripts": {
14
+ "build": "ng-packagr -p ng-package.json"
15
+ }
16
+ }
@@ -0,0 +1,153 @@
1
+ import { Component, input, computed } from '@angular/core';
2
+ import type { CvButtonVariant, CvButtonSize } from './button.variants';
3
+
4
+ @Component({
5
+ selector: 'dai-button',
6
+ standalone: true,
7
+ template: `
8
+ <button
9
+ [class]="computedClasses()"
10
+ [disabled]="isDisabled()"
11
+ [attr.aria-disabled]="isDisabled()"
12
+ [attr.aria-busy]="loading()"
13
+ >
14
+ @if (loading()) {
15
+ <span class="dai-spinner" aria-hidden="true"></span>
16
+ }
17
+ <ng-content />
18
+ </button>
19
+ `,
20
+ styles: [
21
+ `
22
+ :host {
23
+ display: inline-block;
24
+ }
25
+
26
+ button {
27
+ display: inline-flex;
28
+ align-items: center;
29
+ justify-content: center;
30
+ gap: 4px;
31
+ font-family: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
32
+ font-weight: 400;
33
+ line-height: 1.5;
34
+ border-radius: 50px;
35
+ cursor: pointer;
36
+ transition: all 150ms ease-in-out;
37
+ border: 1px solid transparent;
38
+ box-sizing: border-box;
39
+ }
40
+
41
+ button:focus-visible {
42
+ outline: none;
43
+ }
44
+
45
+ button:disabled {
46
+ cursor: not-allowed;
47
+ opacity: 1;
48
+ }
49
+
50
+ /* Sizes */
51
+ .dai-button-sm {
52
+ padding: 2px 8px;
53
+ height: 24px;
54
+ font-size: 12px;
55
+ line-height: 1.5em;
56
+ }
57
+
58
+ .dai-button-md {
59
+ padding: 6px 12px;
60
+ height: 32px;
61
+ font-size: 14px;
62
+ line-height: 1.4285714285714286em;
63
+ }
64
+
65
+ .dai-button-lg {
66
+ padding: 8px 16px;
67
+ height: 40px;
68
+ font-size: 16px;
69
+ line-height: 1.375em;
70
+ }
71
+
72
+ /* Primary Variant - Default State */
73
+ .dai-button-primary {
74
+ background-color: #2047F4;
75
+ color: #FFFFFF;
76
+ }
77
+
78
+ .dai-button-primary:hover:not(:disabled) {
79
+ background-color: #5164F7;
80
+ }
81
+
82
+ .dai-button-primary:focus-visible {
83
+ background-color: #2047F4;
84
+ border-color: #112EAC;
85
+ box-shadow: 0 0 0 1px #112EAC;
86
+ }
87
+
88
+ .dai-button-primary:disabled,
89
+ .dai-button-primary.dai-button-loading {
90
+ background-color: #9098FA;
91
+ }
92
+
93
+ .dai-button-primary.dai-button-loading {
94
+ cursor: wait;
95
+ }
96
+
97
+ /* Spinner sizes */
98
+ .dai-button-sm .dai-spinner {
99
+ width: 14px;
100
+ height: 14px;
101
+ }
102
+
103
+ .dai-button-md .dai-spinner {
104
+ width: 16px;
105
+ height: 16px;
106
+ }
107
+
108
+ .dai-button-lg .dai-spinner {
109
+ width: 22px;
110
+ height: 22px;
111
+ }
112
+
113
+ .dai-spinner {
114
+ display: inline-block;
115
+ border: 2px solid #FFFFFF;
116
+ border-right-color: transparent;
117
+ border-radius: 50%;
118
+ animation: dai-spin 0.6s linear infinite;
119
+ }
120
+
121
+ @keyframes dai-spin {
122
+ to {
123
+ transform: rotate(360deg);
124
+ }
125
+ }
126
+ `,
127
+ ],
128
+ })
129
+ export class DaiButtonComponent {
130
+ // Signal Inputs (Angular 19+)
131
+ readonly variant = input<CvButtonVariant>('primary');
132
+ readonly size = input<CvButtonSize>('md');
133
+ readonly disabled = input<boolean>(false);
134
+ readonly loading = input<boolean>(false);
135
+
136
+ // Computed properties for dynamic classes
137
+ protected computedClasses = computed(() => {
138
+ const classes = [
139
+ 'dai-button',
140
+ `dai-button-${this.variant()}`,
141
+ `dai-button-${this.size()}`,
142
+ ];
143
+
144
+ if (this.loading()) {
145
+ classes.push('dai-button-loading');
146
+ }
147
+
148
+ return classes.join(' ');
149
+ });
150
+
151
+ // Computed disabled state (disabled or loading)
152
+ protected isDisabled = computed(() => this.disabled() || this.loading());
153
+ }
@@ -0,0 +1,3 @@
1
+ // Only primary variant based on Figma design
2
+ export type CvButtonVariant = 'primary';
3
+ export type CvButtonSize = 'sm' | 'md' | 'lg';
@@ -0,0 +1,209 @@
1
+ import { Component, input, output, model, forwardRef, computed } from '@angular/core';
2
+ import { CommonModule } from '@angular/common';
3
+ import {
4
+ type ControlValueAccessor,
5
+ NG_VALUE_ACCESSOR,
6
+ } from '@angular/forms';
7
+
8
+ export type CvInputSize = 'sm' | 'md' | 'lg';
9
+
10
+ @Component({
11
+ selector: 'dai-input',
12
+ standalone: true,
13
+ imports: [CommonModule],
14
+ template: `
15
+ <div class="dai-input-wrapper" [class.dai-input-error]="hasError()">
16
+ <label [for]="inputId()" class="dai-input-label">
17
+ {{ label() }}
18
+ </label>
19
+
20
+ <input
21
+ [id]="inputId()"
22
+ [type]="type()"
23
+ [placeholder]="placeholder()"
24
+ [value]="value()"
25
+ (input)="onInput($event)"
26
+ (blur)="onTouched()"
27
+ [disabled]="disabled()"
28
+ [class.dai-input-field]="true"
29
+ [class.dai-input-sm]="size() === 'sm'"
30
+ [class.dai-input-md]="size() === 'md'"
31
+ [class.dai-input-lg]="size() === 'lg'"
32
+ [attr.aria-invalid]="hasError()"
33
+ [attr.aria-describedby]="hasError() ? errorId() : null"
34
+ />
35
+
36
+ @if (hasError() && errorMessage()) {
37
+ <span [id]="errorId()" class="dai-input-error-message" role="alert">
38
+ {{ errorMessage() }}
39
+ </span>
40
+ }
41
+ </div>
42
+ `,
43
+ styles: [
44
+ `
45
+ :host {
46
+ display: block;
47
+ width: 100%;
48
+ }
49
+
50
+ .dai-input-wrapper {
51
+ display: flex;
52
+ flex-direction: column;
53
+ gap: 8px;
54
+ width: 100%;
55
+ }
56
+
57
+ .dai-input-label {
58
+ display: block;
59
+ font-family: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
60
+ font-size: 16px;
61
+ font-weight: 400;
62
+ line-height: 1.5em;
63
+ color: #000000;
64
+ }
65
+
66
+ .dai-input-field {
67
+ width: 100%;
68
+ font-family: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
69
+ font-size: 14px;
70
+ font-weight: 400;
71
+ line-height: 1.5em;
72
+ color: #000000;
73
+ background-color: #FFFFFF;
74
+ border: 1px solid #E5E0EB;
75
+ border-radius: 50px;
76
+ box-sizing: border-box;
77
+ outline: none;
78
+ transition: all 150ms ease-in-out;
79
+ }
80
+
81
+ .dai-input-field::placeholder {
82
+ color: #ABA7AF;
83
+ }
84
+
85
+ /* Sizes */
86
+ .dai-input-sm {
87
+ padding: 8px 12px;
88
+ }
89
+
90
+ .dai-input-md {
91
+ padding: 12px;
92
+ height: 44px;
93
+ }
94
+
95
+ .dai-input-lg {
96
+ padding: 14px 12px;
97
+ height: 50px;
98
+ }
99
+
100
+ /* Focus State */
101
+ .dai-input-sm:focus {
102
+ border-color: #061764;
103
+ border-width: 2px;
104
+ padding: 7px 11px; /* Adjust for 2px border */
105
+ }
106
+
107
+ .dai-input-md:focus,
108
+ .dai-input-lg:focus {
109
+ border-color: #112EAC;
110
+ border-width: 1px;
111
+ }
112
+
113
+ /* Disabled State */
114
+ .dai-input-field:disabled {
115
+ background-color: #DFDFDF;
116
+ border-color: #DFDFDF;
117
+ color: #ABA7AF;
118
+ cursor: not-allowed;
119
+ }
120
+
121
+ /* Error State */
122
+ .dai-input-error .dai-input-field {
123
+ border-color: #D51A52;
124
+ border-width: 2px;
125
+ }
126
+
127
+ .dai-input-error .dai-input-sm {
128
+ padding: 7px 11px; /* Adjust for 2px border */
129
+ }
130
+
131
+ .dai-input-error .dai-input-md {
132
+ padding: 11px; /* Adjust for 2px border */
133
+ }
134
+
135
+ .dai-input-error .dai-input-lg {
136
+ padding: 13px 11px; /* Adjust for 2px border */
137
+ }
138
+
139
+ .dai-input-error-message {
140
+ display: block;
141
+ font-family: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
142
+ font-size: 14px;
143
+ font-weight: 400;
144
+ line-height: 1.5em;
145
+ color: #D51A52;
146
+ }
147
+ `,
148
+ ],
149
+ providers: [
150
+ {
151
+ provide: NG_VALUE_ACCESSOR,
152
+ useExisting: forwardRef(() => DaiInputComponent),
153
+ multi: true,
154
+ },
155
+ ],
156
+ })
157
+ export class DaiInputComponent implements ControlValueAccessor {
158
+ // Signal Inputs
159
+ readonly label = input<string>('');
160
+ readonly placeholder = input<string>('Text');
161
+ readonly type = input<'text' | 'password' | 'email'>('text');
162
+ readonly disabled = input<boolean>(false);
163
+ readonly errorMessage = input<string>('');
164
+ readonly size = input<CvInputSize>('md');
165
+ readonly inputId = input<string>(`dai-input-${Math.random().toString(36).substr(2, 9)}`);
166
+
167
+ // Model for two-way binding (Angular 19+)
168
+ readonly value = model<string>('');
169
+
170
+ // Outputs for custom handling
171
+ readonly valueChange = output<string>();
172
+ readonly blur = output<void>();
173
+
174
+ // Internal state
175
+ private onChange: (value: string) => void = () => {};
176
+ onTouched: () => void = () => {};
177
+
178
+ // Computed error state
179
+ protected hasError = computed(() => !!this.errorMessage());
180
+
181
+ // Unique error message ID
182
+ protected errorId = () => `${this.inputId()}-error`;
183
+
184
+ // Handle input changes
185
+ protected onInput(event: Event): void {
186
+ const target = event.target as HTMLInputElement;
187
+ const newValue = target.value;
188
+ this.value.set(newValue);
189
+ this.onChange(newValue);
190
+ this.valueChange.emit(newValue);
191
+ }
192
+
193
+ // ControlValueAccessor implementation
194
+ writeValue(value: string): void {
195
+ this.value.set(value || '');
196
+ }
197
+
198
+ registerOnChange(fn: (value: string) => void): void {
199
+ this.onChange = fn;
200
+ }
201
+
202
+ registerOnTouched(fn: () => void): void {
203
+ this.onTouched = fn;
204
+ }
205
+
206
+ setDisabledState(isDisabled: boolean): void {
207
+ // Handled through the disabled input signal
208
+ }
209
+ }
@@ -0,0 +1,8 @@
1
+ /*
2
+ * Public API Surface of @deay/ui
3
+ */
4
+
5
+ // Export components
6
+ export * from './lib/button/button.component';
7
+ export * from './lib/button/button.variants';
8
+ export * from './lib/input/input.component';
@@ -0,0 +1,12 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "outDir": "../../dist/out-tsc/packages/ui",
5
+ "declaration": true,
6
+ "declarationMap": true,
7
+ "inlineSources": true,
8
+ "types": []
9
+ },
10
+ "include": ["src/**/*.ts"],
11
+ "exclude": ["src/test.ts", "**/*.spec.ts"]
12
+ }