shogun-button-react 1.0.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.
@@ -0,0 +1,5 @@
1
+ import { ShogunButton, ShogunButtonProvider, useShogun } from './components/ShogunButton.js';
2
+ import { ShogunConnectorOptions, ShogunConnectorResult } from './types/connector-options';
3
+ export { ShogunButton, ShogunButtonProvider, useShogun };
4
+ export * from './types.js';
5
+ export { ShogunConnectorOptions, ShogunConnectorResult };
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ import { ShogunButton, ShogunButtonProvider, useShogun } from './components/ShogunButton.js';
2
+ // Export components
3
+ export { ShogunButton, ShogunButtonProvider, useShogun };
4
+ // Export all types
5
+ export * from './types.js';
@@ -0,0 +1,723 @@
1
+ /* Base styles */
2
+ :root {
3
+ --shogun-primary: #3b82f6;
4
+ --shogun-primary-hover: #2563eb;
5
+ --shogun-secondary: #6b7280;
6
+ --shogun-success: #10b981;
7
+ --shogun-danger: #ef4444;
8
+ --shogun-warning: #f59e0b;
9
+ --shogun-text: #1f2937;
10
+ --shogun-text-secondary: #6b7280;
11
+ --shogun-bg: #ffffff;
12
+ --shogun-bg-secondary: #f3f4f6;
13
+ --shogun-border: #e5e7eb;
14
+ --shogun-border-radius: 12px;
15
+ --shogun-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
16
+ --shogun-transition: all 0.2s ease;
17
+ --shogun-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
18
+ }
19
+
20
+ /* Dark mode support */
21
+ @media (prefers-color-scheme: dark) {
22
+ :root {
23
+ --shogun-text: #f3f4f6;
24
+ --shogun-text-secondary: #9ca3af;
25
+ --shogun-bg: #1f2937;
26
+ --shogun-bg-secondary: #374151;
27
+ --shogun-border: #4b5563;
28
+ }
29
+ }
30
+
31
+ /* Connect Button */
32
+ .shogun-connect-button {
33
+ display: flex;
34
+ align-items: center;
35
+ justify-content: center;
36
+ gap: 8px;
37
+ background-color: var(--shogun-primary);
38
+ color: white;
39
+ border: none;
40
+ border-radius: var(--shogun-border-radius);
41
+ padding: 10px 16px;
42
+ font-family: var(--shogun-font);
43
+ font-weight: 600;
44
+ font-size: 14px;
45
+ cursor: pointer;
46
+ transition: var(--shogun-transition);
47
+ box-shadow: var(--shogun-shadow);
48
+ }
49
+
50
+ .shogun-connect-button:hover {
51
+ background-color: var(--shogun-primary-hover);
52
+ }
53
+
54
+ .shogun-connect-button:focus {
55
+ outline: none;
56
+ box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5);
57
+ }
58
+
59
+ /* Logged in state */
60
+ .shogun-logged-in-container {
61
+ position: relative;
62
+ }
63
+
64
+ .shogun-dropdown {
65
+ position: relative;
66
+ }
67
+
68
+ .shogun-button.shogun-logged-in {
69
+ display: flex;
70
+ align-items: center;
71
+ gap: 8px;
72
+ background-color: var(--shogun-bg-secondary);
73
+ color: var(--shogun-text);
74
+ border: 1px solid var(--shogun-border);
75
+ border-radius: var(--shogun-border-radius);
76
+ padding: 8px 12px;
77
+ font-family: var(--shogun-font);
78
+ font-size: 14px;
79
+ cursor: pointer;
80
+ transition: var(--shogun-transition);
81
+ }
82
+
83
+ .shogun-button.shogun-logged-in:hover {
84
+ background-color: var(--shogun-bg);
85
+ }
86
+
87
+ .shogun-avatar {
88
+ width: 24px;
89
+ height: 24px;
90
+ background-color: var(--shogun-primary);
91
+ color: white;
92
+ border-radius: 50%;
93
+ display: flex;
94
+ align-items: center;
95
+ justify-content: center;
96
+ font-weight: 600;
97
+ font-size: 12px;
98
+ }
99
+
100
+ .shogun-username {
101
+ font-weight: 500;
102
+ }
103
+
104
+ .shogun-dropdown-menu {
105
+ position: absolute;
106
+ top: calc(100% + 8px);
107
+ right: 0;
108
+ background-color: var(--shogun-bg);
109
+ border: 1px solid var(--shogun-border);
110
+ border-radius: var(--shogun-border-radius);
111
+ box-shadow: var(--shogun-shadow);
112
+ width: 240px;
113
+ z-index: 100;
114
+ overflow: hidden;
115
+ animation: shogun-dropdown-fade 0.2s ease;
116
+ }
117
+
118
+ @keyframes shogun-dropdown-fade {
119
+ from {
120
+ opacity: 0;
121
+ transform: translateY(-8px);
122
+ }
123
+ to {
124
+ opacity: 1;
125
+ transform: translateY(0);
126
+ }
127
+ }
128
+
129
+ .shogun-dropdown-header {
130
+ padding: 16px;
131
+ border-bottom: 1px solid var(--shogun-border);
132
+ display: flex;
133
+ align-items: center;
134
+ gap: 12px;
135
+ }
136
+
137
+ .shogun-avatar-large {
138
+ width: 40px;
139
+ height: 40px;
140
+ background-color: var(--shogun-primary);
141
+ color: white;
142
+ border-radius: 50%;
143
+ display: flex;
144
+ align-items: center;
145
+ justify-content: center;
146
+ font-weight: 600;
147
+ font-size: 16px;
148
+ }
149
+
150
+ .shogun-user-info {
151
+ display: flex;
152
+ flex-direction: column;
153
+ }
154
+
155
+ .shogun-username-full {
156
+ font-weight: 600;
157
+ color: var(--shogun-text);
158
+ font-size: 14px;
159
+ }
160
+
161
+ .shogun-dropdown-item {
162
+ padding: 12px 16px;
163
+ display: flex;
164
+ align-items: center;
165
+ gap: 12px;
166
+ color: var(--shogun-text);
167
+ font-size: 14px;
168
+ cursor: pointer;
169
+ transition: var(--shogun-transition);
170
+ }
171
+
172
+ .shogun-dropdown-item:hover {
173
+ background-color: var(--shogun-bg-secondary);
174
+ }
175
+
176
+ /* Modal */
177
+ .shogun-modal-overlay {
178
+ position: fixed;
179
+ top: 0;
180
+ left: 0;
181
+ right: 0;
182
+ bottom: 0;
183
+ background-color: rgba(0, 0, 0, 0.5);
184
+ display: flex;
185
+ align-items: center;
186
+ justify-content: center;
187
+ z-index: 1000;
188
+ animation: shogun-fade-in 0.2s ease;
189
+ }
190
+
191
+ @keyframes shogun-fade-in {
192
+ from {
193
+ opacity: 0;
194
+ }
195
+ to {
196
+ opacity: 1;
197
+ }
198
+ }
199
+
200
+ .shogun-modal {
201
+ background-color: var(--shogun-bg);
202
+ border-radius: var(--shogun-border-radius);
203
+ box-shadow: var(--shogun-shadow);
204
+ width: 90%;
205
+ max-width: 400px;
206
+ max-height: 90vh;
207
+ overflow-y: auto;
208
+ animation: shogun-scale-in 0.2s ease;
209
+ }
210
+
211
+ @keyframes shogun-scale-in {
212
+ from {
213
+ opacity: 0;
214
+ transform: scale(0.95);
215
+ }
216
+ to {
217
+ opacity: 1;
218
+ transform: scale(1);
219
+ }
220
+ }
221
+
222
+ .shogun-modal-header {
223
+ display: flex;
224
+ justify-content: space-between;
225
+ align-items: center;
226
+ padding: 16px 20px;
227
+ border-bottom: 1px solid var(--shogun-border);
228
+ }
229
+
230
+ .shogun-modal-header h2 {
231
+ margin: 0;
232
+ font-size: 18px;
233
+ font-weight: 600;
234
+ color: var(--shogun-text);
235
+ }
236
+
237
+ .shogun-close-button {
238
+ background: none;
239
+ border: none;
240
+ cursor: pointer;
241
+ color: var(--shogun-text-secondary);
242
+ padding: 4px;
243
+ display: flex;
244
+ align-items: center;
245
+ justify-content: center;
246
+ border-radius: 50%;
247
+ transition: var(--shogun-transition);
248
+ }
249
+
250
+ .shogun-close-button:hover {
251
+ background-color: var(--shogun-bg-secondary);
252
+ color: var(--shogun-text);
253
+ }
254
+
255
+ .shogun-modal-content {
256
+ padding: 20px;
257
+ }
258
+
259
+ /* Auth options */
260
+ .shogun-auth-options {
261
+ display: flex;
262
+ flex-direction: column;
263
+ gap: 12px;
264
+ margin-bottom: 24px;
265
+ }
266
+
267
+ .shogun-auth-option-button {
268
+ display: flex;
269
+ align-items: center;
270
+ justify-content: center;
271
+ gap: 12px;
272
+ background-color: var(--shogun-bg);
273
+ color: var(--shogun-text);
274
+ border: 1px solid var(--shogun-border);
275
+ border-radius: var(--shogun-border-radius);
276
+ padding: 12px 16px;
277
+ font-family: var(--shogun-font);
278
+ font-weight: 500;
279
+ font-size: 14px;
280
+ cursor: pointer;
281
+ transition: var(--shogun-transition);
282
+ width: 100%;
283
+ }
284
+
285
+ .shogun-auth-option-button:hover {
286
+ background-color: var(--shogun-bg-secondary);
287
+ }
288
+
289
+ .shogun-auth-option-button:disabled {
290
+ opacity: 0.6;
291
+ cursor: not-allowed;
292
+ }
293
+
294
+ .shogun-google-button {
295
+ border-color: #4285F4;
296
+ }
297
+
298
+ /* Divider */
299
+ .shogun-divider {
300
+ display: flex;
301
+ align-items: center;
302
+ margin: 20px 0;
303
+ color: var(--shogun-text-secondary);
304
+ font-size: 14px;
305
+ }
306
+
307
+ .shogun-divider::before,
308
+ .shogun-divider::after {
309
+ content: "";
310
+ flex: 1;
311
+ border-bottom: 1px solid var(--shogun-border);
312
+ }
313
+
314
+ .shogun-divider span {
315
+ padding: 0 10px;
316
+ }
317
+
318
+ /* Form */
319
+ .shogun-auth-form {
320
+ display: flex;
321
+ flex-direction: column;
322
+ gap: 16px;
323
+ }
324
+
325
+ .shogun-form-group {
326
+ display: flex;
327
+ flex-direction: column;
328
+ gap: 8px;
329
+ }
330
+
331
+ .shogun-form-group label {
332
+ display: flex;
333
+ align-items: center;
334
+ gap: 8px;
335
+ font-size: 14px;
336
+ font-weight: 500;
337
+ color: var(--shogun-text);
338
+ }
339
+
340
+ .shogun-form-group input {
341
+ padding: 12px;
342
+ border: 1px solid var(--shogun-border);
343
+ border-radius: var(--shogun-border-radius);
344
+ background-color: var(--shogun-bg);
345
+ color: var(--shogun-text);
346
+ font-size: 14px;
347
+ transition: var(--shogun-transition);
348
+ }
349
+
350
+ .shogun-form-group input:focus {
351
+ outline: none;
352
+ border-color: var(--shogun-primary);
353
+ box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
354
+ }
355
+
356
+ .shogun-submit-button {
357
+ background-color: var(--shogun-primary);
358
+ color: white;
359
+ border: none;
360
+ border-radius: var(--shogun-border-radius);
361
+ padding: 12px 16px;
362
+ font-family: var(--shogun-font);
363
+ font-weight: 600;
364
+ font-size: 14px;
365
+ cursor: pointer;
366
+ transition: var(--shogun-transition);
367
+ margin-top: 8px;
368
+ }
369
+
370
+ .shogun-submit-button:hover:not(:disabled) {
371
+ background-color: var(--shogun-primary-hover);
372
+ }
373
+
374
+ .shogun-submit-button:disabled {
375
+ opacity: 0.6;
376
+ cursor: not-allowed;
377
+ }
378
+
379
+ /* Footer */
380
+ .shogun-form-footer {
381
+ margin-top: 20px;
382
+ text-align: center;
383
+ font-size: 14px;
384
+ color: var(--shogun-text-secondary);
385
+ }
386
+
387
+ .shogun-toggle-mode {
388
+ background: none;
389
+ border: none;
390
+ color: var(--shogun-primary);
391
+ font-weight: 600;
392
+ cursor: pointer;
393
+ padding: 0;
394
+ margin-left: 4px;
395
+ transition: var(--shogun-transition);
396
+ }
397
+
398
+ .shogun-toggle-mode:hover {
399
+ text-decoration: underline;
400
+ }
401
+
402
+ .shogun-toggle-mode:disabled {
403
+ opacity: 0.6;
404
+ cursor: not-allowed;
405
+ }
406
+
407
+ /* Error message */
408
+ .shogun-error-message {
409
+ background-color: rgba(239, 68, 68, 0.1);
410
+ color: var(--shogun-danger);
411
+ padding: 12px;
412
+ border-radius: var(--shogun-border-radius);
413
+ margin-bottom: 16px;
414
+ font-size: 14px;
415
+ border: 1px solid rgba(239, 68, 68, 0.2);
416
+ }
417
+
418
+ /* Shogun Button Styles */
419
+
420
+ .shogun-button {
421
+ display: flex;
422
+ align-items: center;
423
+ justify-content: center;
424
+ padding: 12px 20px;
425
+ background-color: #3861fb;
426
+ color: white;
427
+ border: none;
428
+ border-radius: 8px;
429
+ font-size: 16px;
430
+ font-weight: 600;
431
+ cursor: pointer;
432
+ transition: all 0.2s ease;
433
+ min-width: 150px;
434
+ box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
435
+ }
436
+
437
+ .shogun-button:hover {
438
+ background-color: #2d4fd6;
439
+ transform: translateY(-1px);
440
+ box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
441
+ }
442
+
443
+ .shogun-button:active {
444
+ transform: translateY(0);
445
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
446
+ }
447
+
448
+ .shogun-button.shogun-logged-in {
449
+ background-color: #4CAF50;
450
+ }
451
+
452
+ .shogun-button.shogun-logged-in:hover {
453
+ background-color: #43a047;
454
+ }
455
+
456
+ .shogun-button-custom {
457
+ cursor: pointer;
458
+ display: inline-flex;
459
+ align-items: center;
460
+ }
461
+
462
+ /* Tema scuro */
463
+ [data-shogun-theme="dark"] .shogun-button {
464
+ background-color: #4a5568;
465
+ color: white;
466
+ }
467
+
468
+ [data-shogun-theme="dark"] .shogun-button:hover {
469
+ background-color: #2d3748;
470
+ }
471
+
472
+ [data-shogun-theme="dark"] .shogun-button.shogun-logged-in {
473
+ background-color: #38a169;
474
+ }
475
+
476
+ [data-shogun-theme="dark"] .shogun-button.shogun-logged-in:hover {
477
+ background-color: #2f855a;
478
+ }
479
+
480
+ /* Stili per il modale di login/registrazione */
481
+ .shogun-modal-overlay {
482
+ position: fixed;
483
+ top: 0;
484
+ left: 0;
485
+ width: 100%;
486
+ height: 100%;
487
+ background-color: rgba(0, 0, 0, 0.5);
488
+ display: flex;
489
+ justify-content: center;
490
+ align-items: center;
491
+ z-index: 1000;
492
+ }
493
+
494
+ .shogun-modal {
495
+ background-color: white;
496
+ border-radius: 8px;
497
+ box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
498
+ width: 100%;
499
+ max-width: 420px;
500
+ overflow: hidden;
501
+ }
502
+
503
+ .shogun-modal-header {
504
+ display: flex;
505
+ justify-content: space-between;
506
+ align-items: center;
507
+ padding: 16px 20px;
508
+ border-bottom: 1px solid #e0e0e0;
509
+ }
510
+
511
+ .shogun-modal-header h2 {
512
+ margin: 0;
513
+ font-size: 20px;
514
+ font-weight: 600;
515
+ color: #333;
516
+ }
517
+
518
+ .shogun-close-button {
519
+ background: none;
520
+ border: none;
521
+ font-size: 24px;
522
+ color: #666;
523
+ cursor: pointer;
524
+ }
525
+
526
+ .shogun-modal-content {
527
+ padding: 20px;
528
+ }
529
+
530
+ .shogun-error-message {
531
+ background-color: #ffebee;
532
+ color: #d32f2f;
533
+ border-radius: 4px;
534
+ padding: 10px;
535
+ margin-bottom: 16px;
536
+ font-size: 14px;
537
+ }
538
+
539
+ .shogun-form-group {
540
+ margin-bottom: 16px;
541
+ }
542
+
543
+ .shogun-form-group label {
544
+ display: block;
545
+ margin-bottom: 6px;
546
+ font-size: 14px;
547
+ font-weight: 500;
548
+ color: #333;
549
+ }
550
+
551
+ .shogun-form-group input {
552
+ width: 100%;
553
+ padding: 10px 12px;
554
+ border: 1px solid #ccc;
555
+ border-radius: 4px;
556
+ font-size: 14px;
557
+ }
558
+
559
+ .shogun-submit-button {
560
+ width: 100%;
561
+ background-color: #4a2afd;
562
+ color: white;
563
+ border: none;
564
+ border-radius: 4px;
565
+ padding: 12px;
566
+ font-size: 16px;
567
+ font-weight: 600;
568
+ cursor: pointer;
569
+ transition: background-color 0.2s;
570
+ margin-top: 8px;
571
+ }
572
+
573
+ .shogun-submit-button:hover {
574
+ background-color: #3115d6;
575
+ }
576
+
577
+ .shogun-submit-button:disabled {
578
+ background-color: #a9a9a9;
579
+ cursor: not-allowed;
580
+ }
581
+
582
+ .shogun-divider {
583
+ display: flex;
584
+ align-items: center;
585
+ text-align: center;
586
+ margin: 16px 0;
587
+ color: #666;
588
+ font-size: 14px;
589
+ }
590
+
591
+ .shogun-divider::before,
592
+ .shogun-divider::after {
593
+ content: '';
594
+ flex: 1;
595
+ border-bottom: 1px solid #e0e0e0;
596
+ }
597
+
598
+ .shogun-divider::before {
599
+ margin-right: 10px;
600
+ }
601
+
602
+ .shogun-divider::after {
603
+ margin-left: 10px;
604
+ }
605
+
606
+ .shogun-metamask-button,
607
+ .shogun-webauthn-button,
608
+ .shogun-nostr-button,
609
+ .shogun-oauth-button {
610
+ width: 100%;
611
+ background-color: #fff;
612
+ color: #333;
613
+ border: 1px solid #ccc;
614
+ border-radius: 4px;
615
+ padding: 12px;
616
+ font-size: 14px;
617
+ font-weight: 500;
618
+ cursor: pointer;
619
+ transition: background-color 0.2s;
620
+ margin-bottom: 8px;
621
+ display: flex;
622
+ align-items: center;
623
+ justify-content: center;
624
+ }
625
+
626
+ .shogun-metamask-button:hover,
627
+ .shogun-webauthn-button:hover,
628
+ .shogun-nostr-button:hover,
629
+ .shogun-oauth-button:hover {
630
+ background-color: #f5f5f5;
631
+ }
632
+
633
+ .shogun-metamask-button:disabled,
634
+ .shogun-webauthn-button:disabled,
635
+ .shogun-nostr-button:disabled,
636
+ .shogun-oauth-button:disabled {
637
+ background-color: #f5f5f5;
638
+ color: #a9a9a9;
639
+ cursor: not-allowed;
640
+ }
641
+
642
+ .shogun-form-footer {
643
+ text-align: center;
644
+ margin-top: 16px;
645
+ font-size: 14px;
646
+ color: #666;
647
+ }
648
+
649
+ .shogun-toggle-mode {
650
+ background: none;
651
+ border: none;
652
+ color: #4a2afd;
653
+ font-weight: 600;
654
+ cursor: pointer;
655
+ padding: 0;
656
+ margin-left: 4px;
657
+ }
658
+
659
+ .shogun-toggle-mode:disabled {
660
+ color: #a9a9a9;
661
+ cursor: not-allowed;
662
+ }
663
+
664
+ /* Stili per i container DID */
665
+ .shogun-logged-in-container {
666
+ display: flex;
667
+ flex-direction: column;
668
+ align-items: center;
669
+ gap: 10px;
670
+ }
671
+
672
+ .shogun-did-container {
673
+ max-width: 100%;
674
+ padding: 10px;
675
+ background-color: #f5f5f5;
676
+ border-radius: 5px;
677
+ margin-top: 5px;
678
+ word-break: break-all;
679
+ text-align: center;
680
+ }
681
+
682
+ .shogun-did-text {
683
+ font-size: 12px;
684
+ color: #555;
685
+ margin: 0 0 10px 0;
686
+ word-break: break-all;
687
+ }
688
+
689
+ .shogun-register-did-button {
690
+ padding: 6px 12px;
691
+ background-color: #4a56e2;
692
+ color: white;
693
+ border: none;
694
+ border-radius: 4px;
695
+ cursor: pointer;
696
+ font-size: 13px;
697
+ transition: background-color 0.3s;
698
+ }
699
+
700
+ .shogun-register-did-button:hover {
701
+ background-color: #3a46c2;
702
+ }
703
+
704
+ .shogun-register-did-button:disabled {
705
+ background-color: #a0a0a0;
706
+ cursor: not-allowed;
707
+ }
708
+
709
+ .shogun-logout-button {
710
+ padding: 6px 12px;
711
+ background-color: #e74c3c;
712
+ color: white;
713
+ border: none;
714
+ border-radius: 4px;
715
+ cursor: pointer;
716
+ font-size: 13px;
717
+ margin-top: 5px;
718
+ transition: background-color 0.3s;
719
+ }
720
+
721
+ .shogun-logout-button:hover {
722
+ background-color: #c0392b;
723
+ }