@xipkg/button 1.2.0 → 1.3.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.
Files changed (2) hide show
  1. package/Button.tsx +26 -0
  2. package/package.json +1 -1
package/Button.tsx CHANGED
@@ -4,6 +4,8 @@ import * as React from 'react';
4
4
 
5
5
  import { cn } from '@xipkg/utils';
6
6
 
7
+ const spinner = 'before:content-[""] before:animate-spin before:rounded-full before:border-gray-60 before:border-2 before:border-t-transparent disabled:opacity-100';
8
+
7
9
  export const buttonVariants = cva(
8
10
  'inline-flex border-box justify-center items-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50',
9
11
  {
@@ -19,6 +21,12 @@ export const buttonVariants = cva(
19
21
  'bg-green-80 text-gray-0 hover:bg-green-100 active:bg-green-100 focus:bg-green-100',
20
22
  'secondary-error':
21
23
  'bg-red-0 text-red-100 border-2 border-red-100 disabled:text-red-20 disabled:border-red-20 hover:bg-red-20 active:bg-red-20 focus:bg-red-20',
24
+ 'default-spinner':
25
+ `bg-gray-10 ${spinner}`,
26
+ 'secondary-spinner':
27
+ `bg-gray-0 border-gray-30 border-2 ${spinner}`,
28
+ 'ghost-spinner':
29
+ `bg-gray-0 border-0 ${spinner}`,
22
30
  },
23
31
  size: {
24
32
  l: 'h-14 rounded-xl px-8 text-[20px] pb-[3px]',
@@ -26,6 +34,23 @@ export const buttonVariants = cva(
26
34
  s: 'h-8 rounded-md px-3 text-[14px] pb-[2px]',
27
35
  },
28
36
  },
37
+ compoundVariants: [
38
+ {
39
+ variant: ['default-spinner', 'secondary-spinner', 'ghost-spinner'],
40
+ size: 'l',
41
+ class: 'before:w-8 before:h-8 p-0',
42
+ },
43
+ {
44
+ variant: ['default-spinner', 'secondary-spinner', 'ghost-spinner'],
45
+ size: 'm',
46
+ class: 'before:w-6 before:h-6 p-0',
47
+ },
48
+ {
49
+ variant: ['default-spinner', 'secondary-spinner', 'ghost-spinner'],
50
+ size: 's',
51
+ class: 'before:w-4 before:h-4 p-0',
52
+ }
53
+ ],
29
54
  defaultVariants: {
30
55
  variant: 'default',
31
56
  size: 'm',
@@ -42,6 +67,7 @@ export interface ButtonProps
42
67
  export const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
43
68
  ({ className, variant, size, asChild = false, children, ...props }, ref) => {
44
69
  const Comp = asChild ? Slot : 'button';
70
+
45
71
  return (
46
72
  <Comp className={cn(buttonVariants({ variant, size, className }))} ref={ref} {...props}>
47
73
  {children}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xipkg/button",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "license": "MIT",