@purr-react-tailwindcss/components.button 0.0.1

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,4 @@
1
+ import { default as React } from 'react';
2
+ import { IButtonProps } from './_types';
3
+
4
+ export declare const Button: ({ variant, size, loading, loadingComponent, classes, htmlAttributes, children, onClick, }: IButtonProps) => React.JSX.Element;
@@ -0,0 +1,19 @@
1
+ import { ClassValue } from 'clsx';
2
+ import { ButtonHTMLAttributes, MouseEventHandler, ReactNode } from 'react';
3
+ import { IExtendable } from '@purr-core/utils.definitions';
4
+
5
+ export type TButtonSize = "small" | "medium" | "large";
6
+ export type TButtonVariant = "outlined" | "contained" | "text";
7
+ export interface IButtonClasses {
8
+ container?: ClassValue;
9
+ }
10
+ export interface IButtonProps {
11
+ size?: TButtonSize;
12
+ variant?: TButtonVariant;
13
+ onClick?: MouseEventHandler<HTMLButtonElement>;
14
+ loading?: boolean;
15
+ loadingComponent?: ReactNode;
16
+ classes?: IButtonClasses;
17
+ children?: ReactNode;
18
+ htmlAttributes?: ButtonHTMLAttributes<HTMLButtonElement> & IExtendable;
19
+ }
package/dist/index.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("react/jsx-runtime"),a=require("clsx"),d=require("react"),c=require("@purr-react-tailwindcss/components.icon"),x={container:"animate-spin text-blue-300 w-4 h-4"},m=({variant:e="text",size:t="medium",loading:n=!1,loadingComponent:o,classes:r,htmlAttributes:i,children:u,onClick:l})=>{const s=d.useMemo(()=>n?o??b.jsx(c.Icon,{name:"loader-2",classes:x}):u,[u,n,o]);return b.jsx("button",{onClick:l,className:a("flex","items-center","justify-center","transition-all","duration-200","ease-in-out","shadow-none","outline-none","overflow-hidden","rounded","min-w-16","text-sm","font-medium","cursor-pointer","button",t==="small"?"h-6 px-4":"",t==="medium"?"h-9 px-5":"",t==="large"?"h-12 px-6":"",e==="contained"?"text-gray-900 bg-blue-300 border border-blue-300 hover:bg-blue-400":"",e==="outlined"?"text-blue-300 bg-transparent border border-blue-300 hover:border-blue-200 hover:text-blue-200":"",e==="text"?"text-blue-300 bg-transparent border border-transparent hover:text-blue-200":"",r==null?void 0:r.container),...i,children:s})};exports.Button=m;
@@ -0,0 +1,2 @@
1
+ export * from './_components';
2
+ export * from './_types';
package/dist/index.js ADDED
@@ -0,0 +1,56 @@
1
+ import { jsx as b } from "react/jsx-runtime";
2
+ import i from "clsx";
3
+ import { useMemo as a } from "react";
4
+ import { Icon as x } from "@purr-react-tailwindcss/components.icon";
5
+ const s = {
6
+ container: "animate-spin text-blue-300 w-4 h-4"
7
+ }, g = ({
8
+ variant: e = "text",
9
+ size: t = "medium",
10
+ loading: o = !1,
11
+ loadingComponent: n,
12
+ classes: r,
13
+ htmlAttributes: m,
14
+ children: u,
15
+ onClick: l
16
+ }) => {
17
+ const d = a(() => o ? n ?? /* @__PURE__ */ b(x, { name: "loader-2", classes: s }) : u, [u, o, n]);
18
+ return /* @__PURE__ */ b(
19
+ "button",
20
+ {
21
+ onClick: l,
22
+ className: i(
23
+ "flex",
24
+ "items-center",
25
+ "justify-center",
26
+ "transition-all",
27
+ "duration-200",
28
+ "ease-in-out",
29
+ "shadow-none",
30
+ "outline-none",
31
+ "overflow-hidden",
32
+ "rounded",
33
+ "min-w-16",
34
+ "text-sm",
35
+ "font-medium",
36
+ "cursor-pointer",
37
+ "button",
38
+ t === "small" ? "h-6 px-4" : "",
39
+ t === "medium" ? "h-9 px-5" : "",
40
+ t === "large" ? "h-12 px-6" : "",
41
+ // variant === "contained"
42
+ // ? "text-gray-900 !bg-blue-300 border border-blue-300 hover:!bg-blue-400"
43
+ // : "",
44
+ e === "contained" ? "text-gray-900 bg-blue-300 border border-blue-300 hover:bg-blue-400" : "",
45
+ e === "outlined" ? "text-blue-300 bg-transparent border border-blue-300 hover:border-blue-200 hover:text-blue-200" : "",
46
+ e === "text" ? "text-blue-300 bg-transparent border border-transparent hover:text-blue-200" : "",
47
+ r == null ? void 0 : r.container
48
+ ),
49
+ ...m,
50
+ children: d
51
+ }
52
+ );
53
+ };
54
+ export {
55
+ g as Button
56
+ };
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@purr-react-tailwindcss/components.button",
3
+ "version": "0.0.1",
4
+ "type": "module",
5
+ "main": "dist/index.cjs",
6
+ "module": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": {
11
+ "types": "./dist/index.d.ts",
12
+ "default": "./dist/index.js"
13
+ },
14
+ "require": {
15
+ "types": "./dist/index.d.ts",
16
+ "default": "./dist/index.cjs"
17
+ }
18
+ }
19
+ },
20
+ "files": [
21
+ "dist"
22
+ ],
23
+ "peerDependencies": {
24
+ "typescript": "*",
25
+ "react": "*",
26
+ "clsx": "*",
27
+ "@purr-core/utils.definitions": "0.0.5",
28
+ "@purr-react-tailwindcss/components.icon": "0.0.1"
29
+ },
30
+ "author": "@DinhThienPhuc",
31
+ "license": "ISC",
32
+ "description": "",
33
+ "sideEffects": false,
34
+ "scripts": {
35
+ "dev": "vite build --watch",
36
+ "build": "tsc && vite build",
37
+ "lint": "eslint . --ext ts,tsx --max-warnings 0"
38
+ }
39
+ }