@jinaan/uikit 0.1.18 → 0.1.20

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jinaan/uikit",
3
- "version": "0.1.18",
3
+ "version": "0.1.20",
4
4
  "description": "Reusable React and Tailwind UI components for Jinaan projects.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
package/src/button.tsx CHANGED
@@ -94,6 +94,7 @@ export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
94
94
  buttonVariants({ variant, size }),
95
95
  iconOnly && "aspect-square px-0",
96
96
  fullWidth && "w-full",
97
+ loading && "disabled:opacity-100",
97
98
  className,
98
99
  )}
99
100
  {...props}
@@ -101,21 +102,37 @@ export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
101
102
  {asChild ? (
102
103
  children
103
104
  ) : (
104
- <>
105
- {loading ? (
106
- <Spinner className={cn("text-current", icon)} aria-hidden />
107
- ) : leadingIcon ? (
108
- <span className={cn("inline-flex shrink-0", icon)} aria-hidden>
109
- {leadingIcon}
110
- </span>
111
- ) : null}
112
- {children}
113
- {!loading && trailingIcon ? (
114
- <span className={cn("inline-flex shrink-0", icon)} aria-hidden>
115
- {trailingIcon}
116
- </span>
117
- ) : null}
118
- </>
105
+ <span className="relative inline-flex items-center justify-center gap-[var(--control-gap)]">
106
+ <span
107
+ className={cn(
108
+ "inline-flex items-center justify-center gap-[var(--control-gap)] transition-[opacity,translate] duration-150 ease-out motion-reduce:transition-none",
109
+ loading && "translate-y-2 opacity-0",
110
+ )}
111
+ aria-hidden={loading || undefined}
112
+ >
113
+ {!loading && leadingIcon ? (
114
+ <span className={cn("inline-flex shrink-0", icon)} aria-hidden>
115
+ {leadingIcon}
116
+ </span>
117
+ ) : null}
118
+ {children}
119
+ {!loading && trailingIcon ? (
120
+ <span className={cn("inline-flex shrink-0", icon)} aria-hidden>
121
+ {trailingIcon}
122
+ </span>
123
+ ) : null}
124
+ </span>
125
+ <span
126
+ data-button-spinner
127
+ className={cn(
128
+ "pointer-events-none absolute inset-0 flex items-center justify-center transition-[opacity,translate] duration-150 ease-out motion-reduce:transition-none",
129
+ loading ? "translate-y-0 opacity-100" : "-translate-y-2 opacity-0",
130
+ )}
131
+ aria-hidden
132
+ >
133
+ <Spinner className={cn("text-current", icon)} />
134
+ </span>
135
+ </span>
119
136
  )}
120
137
  </Comp>
121
138
  );