@poly-x/react 0.1.0-alpha.8 → 0.1.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/dist/styles.css CHANGED
@@ -10,8 +10,33 @@
10
10
  * (`:root`, a wrapper div, …) — that is the supported theming surface. Dark mode
11
11
  * follows the OS by default and defers to an explicit `.dark` / `[data-theme]`
12
12
  * on a host ancestor when one is present.
13
+ *
14
+ * ---------------------------------------------------------------------------
15
+ * Cascade: everything here lives in the `polyx` layer, and that is load-bearing.
16
+ *
17
+ * Unlayered CSS beats layered CSS outright — not by specificity, but by rank; no
18
+ * import order or selector weight changes it. Shipping these rules unlayered
19
+ * therefore beat every Tailwind utility a host wrote (Tailwind emits utilities
20
+ * into `@layer utilities`), so `className`/`triggerClassName` silently did
21
+ * nothing and hosts were pushed toward `!important`. Layering hands that control
22
+ * back: a host's utilities and unlayered CSS both outrank us now.
23
+ *
24
+ * The statement below fixes where `polyx` sits. It must land AFTER `base` —
25
+ * Tailwind's preflight puts `*, ::before, ::after { border: 0 solid }` there, and
26
+ * that would erase our own borders if we ranked lower — and BEFORE `utilities`,
27
+ * so host utilities still win. Naming Tailwind's layers costs nothing when the
28
+ * host doesn't use Tailwind: the names simply resolve to empty layers.
29
+ *
30
+ * Layer order is set by first declaration, so this only holds if our stylesheet
31
+ * is imported BEFORE the host's Tailwind entry. Import it later and `polyx` is
32
+ * appended last, which puts us back to outranking utilities — no worse than the
33
+ * unlayered behaviour, but not the fix either. Import us first.
13
34
  */
14
35
 
36
+ @layer theme, base, polyx, components, utilities;
37
+
38
+ @layer polyx {
39
+
15
40
  .polyx-signin {
16
41
  /* Colors */
17
42
  --polyx-brand: #4f46e5;
@@ -208,6 +233,13 @@
208
233
  margin-bottom: 0.75rem;
209
234
  }
210
235
 
236
+ /* Branding logo fetched from the app's tokens (FR-BRND). */
237
+ .polyx-signin__brand-logo {
238
+ max-height: 2.25rem;
239
+ width: auto;
240
+ object-fit: contain;
241
+ }
242
+
211
243
  .polyx-signin__heading {
212
244
  margin: 0;
213
245
  font-size: 1.375rem;
@@ -270,6 +302,56 @@
270
302
  cursor: not-allowed;
271
303
  }
272
304
 
305
+ /* --- Password reveal toggle --------------------------------------------- */
306
+
307
+ .polyx-signin__input-wrap {
308
+ position: relative;
309
+ display: flex;
310
+ align-items: center;
311
+ }
312
+
313
+ /* Leave room for the reveal button so masked text never slides under it. */
314
+ .polyx-signin__input--has-reveal {
315
+ padding-right: 2.75rem;
316
+ }
317
+
318
+ .polyx-signin__reveal {
319
+ position: absolute;
320
+ right: 0.25rem;
321
+ display: inline-flex;
322
+ align-items: center;
323
+ justify-content: center;
324
+ width: 2rem;
325
+ height: 2rem;
326
+ padding: 0;
327
+ color: var(--polyx-muted-fg);
328
+ background: transparent;
329
+ border: none;
330
+ border-radius: var(--polyx-radius-sm);
331
+ cursor: pointer;
332
+ transition: color 0.15s ease, box-shadow 0.15s ease;
333
+ }
334
+
335
+ .polyx-signin__reveal:hover:not(:disabled) {
336
+ color: var(--polyx-fg);
337
+ }
338
+
339
+ .polyx-signin__reveal:focus-visible {
340
+ outline: none;
341
+ color: var(--polyx-fg);
342
+ box-shadow: 0 0 0 3px var(--polyx-ring);
343
+ }
344
+
345
+ .polyx-signin__reveal:disabled {
346
+ cursor: not-allowed;
347
+ opacity: 0.6;
348
+ }
349
+
350
+ .polyx-signin__reveal svg {
351
+ width: 1.125rem;
352
+ height: 1.125rem;
353
+ }
354
+
273
355
  /* --- Buttons ------------------------------------------------------------- */
274
356
 
275
357
  .polyx-signin__submit,
@@ -440,3 +522,194 @@
440
522
  background: var(--polyx-input-bg);
441
523
  border-color: var(--polyx-brand);
442
524
  }
525
+
526
+ /* --- User button --------------------------------------------------------- */
527
+
528
+ /* The root carries `polyx-signin` too, so the theme tokens above (and any consumer
529
+ override of them) reach this menu without a second declaration to keep in sync. */
530
+
531
+ .polyx-userbutton {
532
+ position: relative;
533
+ display: inline-block;
534
+ }
535
+
536
+ .polyx-userbutton__trigger {
537
+ display: inline-flex;
538
+ align-items: center;
539
+ gap: 0.5rem;
540
+ padding: 0.125rem;
541
+ color: var(--polyx-fg);
542
+ background: none;
543
+ border: none;
544
+ border-radius: 999px;
545
+ cursor: pointer;
546
+ font: inherit;
547
+ }
548
+
549
+ .polyx-userbutton__trigger:focus-visible {
550
+ outline: none;
551
+ box-shadow: 0 0 0 3px var(--polyx-ring);
552
+ }
553
+
554
+ .polyx-userbutton__trigger-name {
555
+ padding-right: 0.25rem;
556
+ font-size: 0.875rem;
557
+ font-weight: 500;
558
+ }
559
+
560
+ .polyx-userbutton__avatar {
561
+ display: inline-flex;
562
+ flex: none;
563
+ align-items: center;
564
+ justify-content: center;
565
+ overflow: hidden;
566
+ border-radius: 999px;
567
+ background: color-mix(in srgb, var(--polyx-brand) 12%, transparent);
568
+ color: var(--polyx-brand);
569
+ font-size: 0.75rem;
570
+ font-weight: 600;
571
+ letter-spacing: 0.02em;
572
+ object-fit: cover;
573
+ user-select: none;
574
+ }
575
+
576
+ /* Placement is expressed as data attributes and resolved in CSS: the component measures which
577
+ side has room and says so; where that lands is a styling concern. `--polyx-gap` is the space
578
+ between trigger and menu, and the JS assumes the same 8px when it measures. */
579
+ .polyx-userbutton__menu {
580
+ --polyx-gap: 0.5rem;
581
+ position: absolute;
582
+ z-index: 50;
583
+ min-width: 15rem;
584
+ padding: 0.375rem;
585
+ background: var(--polyx-bg);
586
+ border: 1px solid var(--polyx-border);
587
+ border-radius: var(--polyx-radius);
588
+ box-shadow: var(--polyx-shadow);
589
+ }
590
+
591
+ /* Vertical sides: offset above/below, then align along the horizontal axis. */
592
+ .polyx-userbutton__menu[data-polyx-side="bottom"] {
593
+ top: calc(100% + var(--polyx-gap));
594
+ }
595
+ .polyx-userbutton__menu[data-polyx-side="top"] {
596
+ bottom: calc(100% + var(--polyx-gap));
597
+ }
598
+ .polyx-userbutton__menu[data-polyx-side="bottom"][data-polyx-align="end"],
599
+ .polyx-userbutton__menu[data-polyx-side="top"][data-polyx-align="end"] {
600
+ right: 0;
601
+ }
602
+ .polyx-userbutton__menu[data-polyx-side="bottom"][data-polyx-align="start"],
603
+ .polyx-userbutton__menu[data-polyx-side="top"][data-polyx-align="start"] {
604
+ left: 0;
605
+ }
606
+ .polyx-userbutton__menu[data-polyx-side="bottom"][data-polyx-align="center"],
607
+ .polyx-userbutton__menu[data-polyx-side="top"][data-polyx-align="center"] {
608
+ left: 50%;
609
+ transform: translateX(-50%);
610
+ }
611
+
612
+ /* Horizontal sides: offset left/right, then align along the vertical axis. */
613
+ .polyx-userbutton__menu[data-polyx-side="right"] {
614
+ left: calc(100% + var(--polyx-gap));
615
+ }
616
+ .polyx-userbutton__menu[data-polyx-side="left"] {
617
+ right: calc(100% + var(--polyx-gap));
618
+ }
619
+ .polyx-userbutton__menu[data-polyx-side="right"][data-polyx-align="end"],
620
+ .polyx-userbutton__menu[data-polyx-side="left"][data-polyx-align="end"] {
621
+ bottom: 0;
622
+ }
623
+ .polyx-userbutton__menu[data-polyx-side="right"][data-polyx-align="start"],
624
+ .polyx-userbutton__menu[data-polyx-side="left"][data-polyx-align="start"] {
625
+ top: 0;
626
+ }
627
+ .polyx-userbutton__menu[data-polyx-side="right"][data-polyx-align="center"],
628
+ .polyx-userbutton__menu[data-polyx-side="left"][data-polyx-align="center"] {
629
+ top: 50%;
630
+ transform: translateY(-50%);
631
+ }
632
+
633
+ /* Consumer-supplied rows: give them room and get out of the way — no colours, no type, no
634
+ cursor. Whatever they render is theirs. */
635
+ .polyx-userbutton__custom {
636
+ padding: 0.375rem 0.625rem;
637
+ }
638
+
639
+ .polyx-userbutton__identity {
640
+ display: flex;
641
+ align-items: center;
642
+ gap: 0.625rem;
643
+ padding: 0.5rem 0.625rem 0.625rem;
644
+ border-bottom: 1px solid var(--polyx-border);
645
+ }
646
+
647
+ .polyx-userbutton__identity-text {
648
+ display: flex;
649
+ min-width: 0;
650
+ flex-direction: column;
651
+ }
652
+
653
+ /* Names and emails are user data: let them truncate rather than stretch the menu. */
654
+ .polyx-userbutton__name,
655
+ .polyx-userbutton__email {
656
+ overflow: hidden;
657
+ text-overflow: ellipsis;
658
+ white-space: nowrap;
659
+ }
660
+
661
+ .polyx-userbutton__name {
662
+ font-size: 0.875rem;
663
+ font-weight: 600;
664
+ }
665
+
666
+ .polyx-userbutton__email {
667
+ font-size: 0.75rem;
668
+ color: var(--polyx-muted-fg);
669
+ }
670
+
671
+ .polyx-userbutton__items {
672
+ display: flex;
673
+ flex-direction: column;
674
+ margin: 0.375rem 0 0;
675
+ padding: 0;
676
+ list-style: none;
677
+ }
678
+
679
+ .polyx-userbutton__item {
680
+ display: flex;
681
+ width: 100%;
682
+ align-items: center;
683
+ gap: 0.5rem;
684
+ padding: 0.5rem 0.625rem;
685
+ color: var(--polyx-fg);
686
+ background: none;
687
+ border: none;
688
+ border-radius: var(--polyx-radius-sm);
689
+ cursor: pointer;
690
+ font: inherit;
691
+ font-size: 0.875rem;
692
+ text-align: left;
693
+ text-decoration: none;
694
+ }
695
+
696
+ .polyx-userbutton__item:hover {
697
+ background: color-mix(in srgb, var(--polyx-fg) 6%, transparent);
698
+ }
699
+
700
+ .polyx-userbutton__item:focus-visible {
701
+ outline: none;
702
+ box-shadow: 0 0 0 2px var(--polyx-ring);
703
+ }
704
+
705
+ .polyx-userbutton__icon {
706
+ flex: none;
707
+ width: 1rem;
708
+ height: 1rem;
709
+ color: var(--polyx-muted-fg);
710
+ }
711
+
712
+ /* Closes `@layer polyx` — opened at the top of the file. The rules above are left
713
+ unindented deliberately: wrapping the sheet in a layer is a cascade change, not a
714
+ reformat, and re-indenting 600 lines would bury it in the diff. */
715
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@poly-x/react",
3
- "version": "0.1.0-alpha.8",
3
+ "version": "0.1.0",
4
4
  "description": "PolyX SDK for React SPAs - provider, hooks, drop-in auth UI",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -27,7 +27,7 @@
27
27
  "module": "./dist/index.mjs",
28
28
  "types": "./dist/index.d.cts",
29
29
  "dependencies": {
30
- "@poly-x/core": "0.1.0-alpha.8"
30
+ "@poly-x/core": "0.1.0"
31
31
  },
32
32
  "peerDependencies": {
33
33
  "react": ">=18",