wally-ui 1.10.0 → 1.11.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.
@@ -8,34 +8,171 @@ export const ButtonCodeExamples = {
8
8
  componentImport: `@Component({
9
9
  selector: 'app-example',
10
10
  imports: [Button],
11
- templateUrl: './example.html',
12
- styleUrl: './example.css'
11
+ templateUrl: './example.html'
13
12
  })`,
14
13
 
15
14
  // Basic usage
16
- basicUsage: `<wally-button>Wally Button</wally-button>`,
15
+ basicUsage: `<wally-button>Click me</wally-button>`,
17
16
 
18
- // Variants
19
- primaryVariant: `<wally-button variant="primary">Primary Button</wally-button>`,
17
+ // === VARIANTS ===
18
+
19
+ // Primary (Default)
20
+ primaryVariant: `<!-- Default variant -->
21
+ <wally-button>Primary Button</wally-button>
22
+
23
+ <!-- Explicit primary -->
24
+ <wally-button variant="primary">Primary Button</wally-button>`,
25
+
26
+ // Secondary
20
27
  secondaryVariant: `<wally-button variant="secondary">Secondary Button</wally-button>`,
21
28
 
22
- // States
29
+ // Destructive
30
+ destructiveVariant: `<wally-button variant="destructive">Delete Account</wally-button>`,
31
+
32
+ // Outline
33
+ outlineVariant: `<wally-button variant="outline">Outline Button</wally-button>`,
34
+
35
+ // Ghost
36
+ ghostVariant: `<wally-button variant="ghost">Ghost Button</wally-button>`,
37
+
38
+ // Link
39
+ linkVariant: `<!-- Internal navigation -->
40
+ <wally-button variant="link" href="/components">View Components</wally-button>
41
+
42
+ <!-- External link -->
43
+ <wally-button variant="link" href="https://github.com">GitHub</wally-button>`,
44
+
45
+ // === STATES ===
46
+
23
47
  disabled: `<wally-button [disabled]="true">Disabled</wally-button>`,
24
- loading: `<wally-button [loading]="true">Loading</wally-button>`,
48
+
49
+ loading: `<wally-button [loading]="true">Loading...</wally-button>`,
50
+
25
51
  notification: `<wally-button [showNotification]="true">Messages</wally-button>`,
26
52
 
27
- // Types
53
+ // === PRODUCTION EXAMPLES ===
54
+
55
+ // CTA Button
56
+ ctaExample: `<!-- Call-to-Action Example -->
57
+ <wally-button>
58
+ Get Started Free
59
+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
60
+ stroke-width="2" stroke="currentColor" class="size-5">
61
+ <path stroke-linecap="round" stroke-linejoin="round"
62
+ d="M13.5 4.5 21 12m0 0-7.5 7.5M21 12H3" />
63
+ </svg>
64
+ </wally-button>`,
65
+
66
+ // Login Form
67
+ loginExample: `<!-- Login Form Example -->
68
+ <form (ngSubmit)="onLogin()">
69
+ <!-- ... form fields ... -->
70
+
71
+ <div class="flex gap-2">
72
+ <wally-button
73
+ type="submit"
74
+ [loading]="isLoggingIn()"
75
+ [disabled]="!loginForm.valid">
76
+ Sign In
77
+ </wally-button>
78
+
79
+ <wally-button
80
+ variant="secondary"
81
+ type="button"
82
+ (click)="goToSignUp()">
83
+ Create Account
84
+ </wally-button>
85
+ </div>
86
+ </form>`,
87
+
88
+ loginExampleTs: `export class LoginComponent {
89
+ isLoggingIn = signal(false);
90
+ loginForm: FormGroup;
91
+
92
+ onLogin() {
93
+ this.isLoggingIn.set(true);
94
+
95
+ this.authService.login(this.loginForm.value)
96
+ .subscribe({
97
+ next: () => this.router.navigate(['/dashboard']),
98
+ error: () => this.isLoggingIn.set(false)
99
+ });
100
+ }
101
+ }`,
102
+
103
+ // Delete Confirmation
104
+ deleteExample: `<!-- Delete Confirmation Modal -->
105
+ <div class="modal">
106
+ <h2>Delete Account?</h2>
107
+ <p>This action cannot be undone.</p>
108
+
109
+ <div class="flex gap-2 justify-end">
110
+ <wally-button
111
+ variant="ghost"
112
+ (click)="closeModal()">
113
+ Cancel
114
+ </wally-button>
115
+
116
+ <wally-button
117
+ variant="destructive"
118
+ [loading]="isDeleting()"
119
+ (click)="confirmDelete()">
120
+ Delete Account
121
+ </wally-button>
122
+ </div>
123
+ </div>`,
124
+
125
+ // Dashboard Actions
126
+ dashboardExample: `<!-- Dashboard Actions -->
127
+ <div class="dashboard-header">
128
+ <wally-button variant="outline" (click)="exportData()">
129
+ Export
130
+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
131
+ stroke-width="1.5" stroke="currentColor" class="size-5">
132
+ <path stroke-linecap="round" stroke-linejoin="round"
133
+ d="M3 16.5v2.25A2.25 2.25 0 0 0 5.25 21h13.5A2.25 2.25 0 0 0 21 18.75V16.5M16.5 12 12 16.5m0 0L7.5 12m4.5 4.5V3" />
134
+ </svg>
135
+ </wally-button>
136
+
137
+ <wally-button (click)="createNew()">
138
+ Create New
139
+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
140
+ stroke-width="2" stroke="currentColor" class="size-5">
141
+ <path stroke-linecap="round" stroke-linejoin="round" d="M12 4.5v15m7.5-7.5h-15" />
142
+ </svg>
143
+ </wally-button>
144
+ </div>`,
145
+
146
+ // Icon Button with Notification
147
+ notificationButton: `<!-- Notification Icon Button -->
148
+ <wally-button
149
+ [showNotification]="hasUnreadMessages()"
150
+ ariaLabel="View messages">
151
+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
152
+ stroke-width="1.5" stroke="currentColor" class="size-5">
153
+ <path stroke-linecap="round" stroke-linejoin="round"
154
+ d="M21.75 6.75v10.5a2.25 2.25 0 0 1-2.25 2.25h-15a2.25 2.25 0 0 1-2.25-2.25V6.75m19.5 0A2.25 2.25 0 0 0 19.5 4.5h-15a2.25 2.25 0 0 0-2.25 2.25m19.5 0v.243a2.25 2.25 0 0 1-1.07 1.916l-7.5 4.615a2.25 2.25 0 0 1-2.36 0L3.32 8.91a2.25 2.25 0 0 1-1.07-1.916V6.75" />
155
+ </svg>
156
+ </wally-button>`,
157
+
158
+ // === BUTTON TYPES ===
159
+
28
160
  submit: `<wally-button type="submit">Submit Form</wally-button>`,
161
+ reset: `<wally-button type="reset" variant="ghost">Reset</wally-button>`,
162
+
163
+ // === EVENTS ===
29
164
 
30
- // Events
31
165
  clickTemplate: `<wally-button (click)="handleClick()">Click Me</wally-button>`,
166
+
32
167
  clickMethod: `handleClick(): void {
33
- this.clickMessage.set('Button clicked!');
168
+ console.log('Button clicked!');
169
+ // Your logic here
34
170
  }`,
35
171
 
36
- // Icons
172
+ // === ICONS ===
173
+
37
174
  iconWithText: `<wally-button>
38
- Save
175
+ Save Changes
39
176
  <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
40
177
  stroke-width="1.5" stroke="currentColor" class="size-5">
41
178
  <path stroke-linecap="round" stroke-linejoin="round"
@@ -43,7 +180,7 @@ export const ButtonCodeExamples = {
43
180
  </svg>
44
181
  </wally-button>`,
45
182
 
46
- iconOnly: `<wally-button>
183
+ iconOnly: `<wally-button ariaLabel="Notifications">
47
184
  <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
48
185
  stroke-width="1.5" stroke="currentColor" class="size-5">
49
186
  <path stroke-linecap="round" stroke-linejoin="round"
@@ -51,8 +188,19 @@ export const ButtonCodeExamples = {
51
188
  </svg>
52
189
  </wally-button>`,
53
190
 
54
- // Accessibility
55
- ariaLabel: `<wally-button ariaLabel="Save document">
191
+ iconLeft: `<wally-button>
192
+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
193
+ stroke-width="2" stroke="currentColor" class="size-5">
194
+ <path stroke-linecap="round" stroke-linejoin="round"
195
+ d="M10.5 19.5 3 12m0 0 7.5-7.5M3 12h18" />
196
+ </svg>
197
+ Back
198
+ </wally-button>`,
199
+
200
+ // === ACCESSIBILITY ===
201
+
202
+ ariaLabel: `<!-- Essential for icon-only buttons -->
203
+ <wally-button ariaLabel="Save document">
56
204
  <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
57
205
  stroke-width="1.5" stroke="currentColor" class="size-5">
58
206
  <path stroke-linecap="round" stroke-linejoin="round"
@@ -60,20 +208,135 @@ export const ButtonCodeExamples = {
60
208
  </svg>
61
209
  </wally-button>`,
62
210
 
63
- ariaPressed: `<wally-button [ariaPressed]="isToggled">
64
- Toggle Setting
211
+ ariaPressed: `<!-- For toggle buttons -->
212
+ <wally-button [ariaPressed]="isMuted()">
213
+ {{ isMuted() ? 'Unmute' : 'Mute' }}
214
+ </wally-button>`,
215
+
216
+ ariaBusy: `<!-- Automatically set when loading="true" -->
217
+ <wally-button [loading]="isSaving()">
218
+ Save Changes
65
219
  </wally-button>`,
66
220
 
67
- ariaBusy: `<wally-button [loading]="true">
68
- Processing...
221
+ ariaDescribedBy: `<!-- Connect button to description -->
222
+ <wally-button ariaDescribedBy="save-description">
223
+ Save
224
+ </wally-button>
225
+ <p id="save-description" class="sr-only">
226
+ Saves your changes permanently
227
+ </p>`,
228
+
229
+ // === EDGE CASES & ADVANCED ===
230
+
231
+ // Form Integration
232
+ formIntegration: `<!-- Button with form validation -->
233
+ <form [formGroup]="myForm" (ngSubmit)="onSubmit()">
234
+ <!-- form fields -->
235
+
236
+ <wally-button
237
+ type="submit"
238
+ [disabled]="!myForm.valid"
239
+ [loading]="isSubmitting()">
240
+ Submit
241
+ </wally-button>
242
+ </form>`,
243
+
244
+ formIntegrationTs: `export class MyComponent {
245
+ myForm = new FormGroup({
246
+ name: new FormControl('', Validators.required)
247
+ });
248
+
249
+ isSubmitting = signal(false);
250
+
251
+ onSubmit() {
252
+ if (this.myForm.valid) {
253
+ this.isSubmitting.set(true);
254
+ // API call...
255
+ }
256
+ }
257
+ }`,
258
+
259
+ // Router Integration
260
+ routerExample: `<!-- Using with Angular Router -->
261
+ <wally-button variant="link" href="/dashboard">
262
+ Go to Dashboard
263
+ </wally-button>
264
+
265
+ <!-- Programmatic navigation -->
266
+ <wally-button (click)="navigateToProfile()">
267
+ View Profile
69
268
  </wally-button>`,
70
269
 
71
- // Properties
72
- propertyType: `type: string = 'button';`,
73
- propertyDisabled: `disabled: boolean = false;`,
74
- propertyLoading: `loading: boolean = false;`,
75
- propertyShowNotification: `showNotification: boolean = false;`,
76
- propertyAriaLabel: `ariaLabel: string = '';`,
77
- propertyAriaPressed: `ariaPressed: boolean | undefined = undefined;`,
78
- propertyAriaDescribedBy: `ariaDescribedBy: string = '';`,
79
- };
270
+ routerExampleTs: `constructor(private router: Router) {}
271
+
272
+ navigateToProfile() {
273
+ this.router.navigate(['/profile', this.userId]);
274
+ }`,
275
+
276
+ // Loading + Disabled behavior
277
+ loadingDisabledExample: `<!-- Loading takes precedence over disabled -->
278
+ <wally-button
279
+ [disabled]="formInvalid()"
280
+ [loading]="isSaving()">
281
+ Save
282
+ </wally-button>
283
+
284
+ <!-- Result: When loading=true, button is disabled regardless of disabled prop -->`,
285
+
286
+ // Icon recommendations
287
+ iconRecommendations: `<!-- Recommended: Heroicons with size-5 (20px) -->
288
+ <wally-button>
289
+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
290
+ stroke-width="1.5" stroke="currentColor" class="size-5">
291
+ <path stroke-linecap="round" stroke-linejoin="round" d="..." />
292
+ </svg>
293
+ Action
294
+ </wally-button>
295
+
296
+ <!-- Also works with: Lucide, Phosphor, Font Awesome SVG -->`,
297
+
298
+ // Signals pattern
299
+ signalsPattern: `<!-- Using Angular Signals (reactive) -->
300
+ export class MyComponent {
301
+ isLoading = signal(false);
302
+ isDisabled = computed(() => !this.form.valid);
303
+
304
+ async handleSubmit() {
305
+ this.isLoading.set(true);
306
+ await this.api.save();
307
+ this.isLoading.set(false);
308
+ }
309
+ }
310
+
311
+ <!-- Template -->
312
+ <wally-button
313
+ [loading]="isLoading()"
314
+ [disabled]="isDisabled()"
315
+ (click)="handleSubmit()">
316
+ Submit
317
+ </wally-button>`,
318
+
319
+ // Button vs type="button"
320
+ buttonTypeExplained: `<!-- GOOD: Explicit type prevents accidental form submission -->
321
+ <wally-button type="button" (click)="openModal()">
322
+ Open
323
+ </wally-button>
324
+
325
+ <!-- CAUTION: Default type="button" is safe, but explicit is better -->
326
+ <wally-button (click)="openModal()">Open</wally-button>
327
+
328
+ <!-- GOOD: Use type="submit" for form submission -->
329
+ <form (ngSubmit)="save()">
330
+ <wally-button type="submit">Save</wally-button>
331
+ </form>`,
332
+
333
+ // Href without link variant
334
+ hrefBehavior: `<!-- href only works with variant="link" -->
335
+
336
+ <!-- CORRECT: Works as expected -->
337
+ <wally-button variant="link" href="/page">Link</wally-button>
338
+
339
+ <!-- INCORRECT: href is ignored, just a regular button -->
340
+ <wally-button href="/page">Button</wally-button>`,
341
+
342
+ };