@pk-design/react-tailwind 1.13.1 → 1.13.2
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/cjs/components/Button/Button.js +34 -14
- package/dist/cjs/components/Button/Button.js.map +1 -1
- package/dist/es/components/Button/Button.js +34 -14
- package/dist/es/components/Button/Button.js.map +1 -1
- package/dist/react-tailwind.cjs.js +34 -14
- package/dist/react-tailwind.cjs.js.map +1 -1
- package/dist/react-tailwind.es.js +34 -14
- package/dist/react-tailwind.es.js.map +1 -1
- package/package.json +1 -1
|
@@ -147,27 +147,36 @@ const THEMED_BTN_CLASS = {
|
|
|
147
147
|
plain: 'text-[var(--ui-danger-text)] hover:bg-current/10 active:bg-current/15 focus-visible:outline-[var(--ui-danger-ring)]',
|
|
148
148
|
},
|
|
149
149
|
secondary: {
|
|
150
|
-
default: 'text-gray-
|
|
151
|
-
outlined: 'text-gray-
|
|
150
|
+
default: 'text-gray-800 bg-gray-200 hover:bg-gray-300 active:bg-gray-300 dark:text-white dark:bg-gray-700 dark:hover:bg-gray-600 dark:active:bg-gray-600 focus-visible:outline-[var(--ui-focus-ring)]',
|
|
151
|
+
outlined: 'text-gray-800 bg-white border border-gray-300 shadow-xs hover:bg-gray-100 active:bg-gray-200 dark:text-gray-100 dark:bg-transparent dark:border-gray-600 dark:shadow-none dark:hover:bg-white/10 dark:active:bg-white/15 focus-visible:outline-[var(--ui-focus-ring)]',
|
|
152
152
|
plain: 'text-gray-700 hover:bg-current/10 active:bg-current/15 dark:text-gray-200 focus-visible:outline-[var(--ui-focus-ring)]',
|
|
153
153
|
},
|
|
154
154
|
success: {
|
|
155
|
-
default: 'text-white bg-emerald-
|
|
156
|
-
outlined: 'text-emerald-700 hover:text-white border border-emerald-
|
|
155
|
+
default: 'text-white bg-emerald-700 hover:bg-emerald-800 focus-visible:outline-emerald-500',
|
|
156
|
+
outlined: 'text-emerald-700 hover:text-white border border-emerald-700 hover:bg-emerald-700 dark:text-emerald-400 dark:border-emerald-500 focus-visible:outline-emerald-500',
|
|
157
157
|
plain: 'text-emerald-700 hover:bg-current/10 active:bg-current/15 dark:text-emerald-400 focus-visible:outline-emerald-500',
|
|
158
158
|
},
|
|
159
159
|
warning: {
|
|
160
|
-
default: 'text-
|
|
161
|
-
outlined: 'text-amber-700 hover:text-
|
|
160
|
+
default: 'text-gray-900 bg-amber-500 hover:bg-amber-400 focus-visible:outline-amber-500',
|
|
161
|
+
outlined: 'text-amber-700 hover:text-gray-900 border border-amber-500 hover:bg-amber-500 dark:text-amber-400 dark:border-amber-500 focus-visible:outline-amber-500',
|
|
162
162
|
plain: 'text-amber-700 hover:bg-current/10 active:bg-current/15 dark:text-amber-400 focus-visible:outline-amber-500',
|
|
163
163
|
},
|
|
164
164
|
};
|
|
165
165
|
const SIZE_CLASSES = {
|
|
166
|
-
xs: {
|
|
167
|
-
|
|
168
|
-
|
|
166
|
+
xs: {
|
|
167
|
+
normal: 'min-h-7 px-2.5 py-1 rounded-sm gap-1 text-xs',
|
|
168
|
+
iconOnly: 'h-7 w-7 p-1 rounded-sm text-xs',
|
|
169
|
+
},
|
|
170
|
+
sm: {
|
|
171
|
+
normal: 'min-h-8 px-3 py-1 rounded gap-1.5 text-sm',
|
|
172
|
+
iconOnly: 'h-8 w-8 p-1.5 rounded text-sm',
|
|
173
|
+
},
|
|
174
|
+
md: {
|
|
175
|
+
normal: 'min-h-9 px-4 py-1.5 rounded-md gap-2 text-sm',
|
|
176
|
+
iconOnly: 'h-9 w-9 p-2 rounded-md text-sm',
|
|
177
|
+
},
|
|
169
178
|
lg: {
|
|
170
|
-
normal: 'h-10 px-5 rounded-lg gap-2 text-base',
|
|
179
|
+
normal: 'min-h-10 px-5 py-2 rounded-lg gap-2 text-base',
|
|
171
180
|
iconOnly: 'h-10 w-10 p-2.5 rounded-lg text-base',
|
|
172
181
|
},
|
|
173
182
|
};
|
|
@@ -182,12 +191,18 @@ const LOADER_SIZE = {
|
|
|
182
191
|
*
|
|
183
192
|
* Disabled styling is keyed off both the native `disabled` attribute and
|
|
184
193
|
* `aria-disabled`, so non-button elements rendered via `as` look disabled too.
|
|
194
|
+
*
|
|
195
|
+
* On touch screens an invisible layer makes the tappable area at least 44px,
|
|
196
|
+
* whatever the button's size, without changing how it looks.
|
|
185
197
|
*/
|
|
186
|
-
const BASE_BTN_CLASS = 'font-medium inline-flex items-center justify-center shrink-0 cursor-pointer select-none ' +
|
|
198
|
+
const BASE_BTN_CLASS = 'relative font-medium inline-flex items-center justify-center text-center shrink-0 cursor-pointer select-none ' +
|
|
187
199
|
'transition-[color,background-color,border-color,box-shadow,opacity,transform] duration-150 ease-out ' +
|
|
188
200
|
'active:scale-[0.98] focus:outline-none ' +
|
|
189
201
|
'disabled:pointer-events-none disabled:opacity-50 disabled:shadow-none ' +
|
|
190
|
-
'aria-disabled:pointer-events-none aria-disabled:opacity-50 aria-disabled:shadow-none'
|
|
202
|
+
'aria-disabled:pointer-events-none aria-disabled:opacity-50 aria-disabled:shadow-none ' +
|
|
203
|
+
'pointer-coarse:after:absolute pointer-coarse:after:top-1/2 pointer-coarse:after:left-1/2 ' +
|
|
204
|
+
'pointer-coarse:after:-translate-x-1/2 pointer-coarse:after:-translate-y-1/2 ' +
|
|
205
|
+
'pointer-coarse:after:w-full pointer-coarse:after:min-w-11 pointer-coarse:after:h-full pointer-coarse:after:min-h-11';
|
|
191
206
|
const Button = forwardRef(({ as, type, ...props }, ref) => {
|
|
192
207
|
const { className = '', children, theme = 'primary', variant = 'default', size = 'md', leftIcon, rightIcon, fullWidth = false, loading = false, loadingText = '', rounded = false, disabled, iconOnly = false, noOutlineOnFocus = false, active, onClick, ...restProps } = props;
|
|
193
208
|
const Component = as || 'button';
|
|
@@ -239,7 +254,10 @@ const Button = forwardRef(({ as, type, ...props }, ref) => {
|
|
|
239
254
|
const elementProps = isNativeButton
|
|
240
255
|
? {
|
|
241
256
|
type: type !== null && type !== void 0 ? type : 'button',
|
|
242
|
-
disabled:
|
|
257
|
+
// Not `disabled` while loading: that would drop keyboard focus from the
|
|
258
|
+
// button just pressed. handleClick ignores presses until it's done.
|
|
259
|
+
disabled: Boolean(disabled),
|
|
260
|
+
'aria-disabled': loading && !disabled ? true : undefined,
|
|
243
261
|
role,
|
|
244
262
|
tabIndex,
|
|
245
263
|
onClick: handleClick,
|
|
@@ -269,7 +287,9 @@ const Button = forwardRef(({ as, type, ...props }, ref) => {
|
|
|
269
287
|
return buildClassName(BASE_BTN_CLASS, ((_a = THEMED_BTN_CLASS[theme]) === null || _a === void 0 ? void 0 : _a[variant]) || THEMED_BTN_CLASS.primary.default, iconOnly ? sizeObj.iconOnly : sizeObj.normal,
|
|
270
288
|
// An outline (not a ring) so the offset gap stays transparent on any surface/mode.
|
|
271
289
|
!noOutlineOnFocus &&
|
|
272
|
-
'focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-solid', rounded && 'rounded-full', fullWidth && 'w-full',
|
|
290
|
+
'focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-solid', rounded && 'rounded-full', fullWidth && 'w-full',
|
|
291
|
+
// Secondary default is a flat grey fill; a shadow would bring back the outlined look.
|
|
292
|
+
variant === 'default' && theme !== 'secondary' && 'shadow-xs hover:shadow-none', active && 'ring-2 ring-current', className);
|
|
273
293
|
}, [theme, variant, sizeObj, iconOnly, noOutlineOnFocus, rounded, fullWidth, active, className]);
|
|
274
294
|
// The spinner and loading text inherit the button's text colour.
|
|
275
295
|
const loaderIcon = (jsx(Loader, { "data-testid": "btn-loader-icon", size: LOADER_SIZE[size] || 'xs', className: "text-current" }));
|