@purr-react-styled-components/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, className, htmlAttributes, children, onClick, }: IButtonProps) => React.JSX.Element;
@@ -0,0 +1,8 @@
1
+ import { TButtonSize, TButtonVariant } from './_types';
2
+
3
+ export declare const Styled: {
4
+ Container: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components/dist/types').Substitute<import('react').DetailedHTMLProps<import('react').ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, {
5
+ $size: TButtonSize;
6
+ $variant: TButtonVariant;
7
+ }>> & string;
8
+ };
@@ -0,0 +1,15 @@
1
+ import { ButtonHTMLAttributes, MouseEventHandler, ReactNode } from 'react';
2
+ import { IExtendable } from '@purr-core/utils.definitions';
3
+
4
+ export type TButtonSize = "small" | "medium" | "large";
5
+ export type TButtonVariant = "outlined" | "contained" | "text";
6
+ export interface IButtonProps {
7
+ size?: TButtonSize;
8
+ variant?: TButtonVariant;
9
+ onClick?: MouseEventHandler<HTMLButtonElement>;
10
+ loading?: boolean;
11
+ loadingComponent?: ReactNode;
12
+ className?: string;
13
+ children?: ReactNode;
14
+ htmlAttributes?: ButtonHTMLAttributes<HTMLButtonElement> & IExtendable;
15
+ }
package/dist/index.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),l=require("clsx"),b=require("react"),g=require("@purr-react-styled-components/components.loading-ripple"),t=require("styled-components"),x=e=>(e==null?void 0:e.$size)==="small"?t.css(["height:24px;padding:0 16px;"]):(e==null?void 0:e.$size)==="medium"?t.css(["height:36px;padding:0 20px;"]):t.css(["height:48px;padding:0 24px;"]),f=e=>(e==null?void 0:e.$variant)==="contained"?t.css(["color:rgba(0,0,0,0.87);background-color:rgb(144,202,249);border:1px solid rgb(144,202,249);&:hover{background-color:rgb(66,165,245);}"]):(e==null?void 0:e.$variant)==="outlined"?t.css(["color:rgb(144,202,249);background-color:transparent;border:1px solid rgba(144,202,249,0.5);&:hover{background-color:rgba(144,202,249,0.08);border:1px solid rgb(144,202,249);}"]):t.css(["color:rgb(144,202,249);background-color:transparent;border:1px solid transparent;&:hover{background-color:rgba(144,202,249,0.08);}"]),h={Container:t.button.withConfig({displayName:"_style__Container",componentId:"sc-1ssweka-0"})(["display:flex;align-items:center;justify-content:center;transition:all 0.2s ease;background-color:transparent;box-shadow:none;outline:none;overflow:hidden;border-radius:4px;min-width:64px;padding:6px 12px;font-weight:500;cursor:pointer;",";",";&:hover,&:focus{outline:0;text-decoration:none;}"],x,f)},m=({variant:e="text",size:r="medium",loading:n=!1,loadingComponent:o,className:c,htmlAttributes:s,children:i,onClick:u})=>{const d=b.useMemo(()=>n?o??a.jsx(g.LoadingRipple,{size:16,fullScreen:!1}):i,[i,n,o]);return a.jsx(h.Container,{...s,$variant:e,$size:r,onClick:u,className:l("button",`button--size-${r}`,`button--variant-${e}`,n&&"button--loading",c),children:d})};exports.Button=m;
@@ -0,0 +1,2 @@
1
+ export * from './_components';
2
+ export * from './_types';
package/dist/index.js ADDED
@@ -0,0 +1,26 @@
1
+ import { jsx as a } from "react/jsx-runtime";
2
+ import b from "clsx";
3
+ import { useMemo as g } from "react";
4
+ import { LoadingRipple as s } from "@purr-react-styled-components/components.loading-ripple";
5
+ import m, { css as r } from "styled-components";
6
+ const f = (t) => (t == null ? void 0 : t.$size) === "small" ? r(["height:24px;padding:0 16px;"]) : (t == null ? void 0 : t.$size) === "medium" ? r(["height:36px;padding:0 20px;"]) : r(["height:48px;padding:0 24px;"]), x = (t) => (t == null ? void 0 : t.$variant) === "contained" ? r(["color:rgba(0,0,0,0.87);background-color:rgb(144,202,249);border:1px solid rgb(144,202,249);&:hover{background-color:rgb(66,165,245);}"]) : (t == null ? void 0 : t.$variant) === "outlined" ? r(["color:rgb(144,202,249);background-color:transparent;border:1px solid rgba(144,202,249,0.5);&:hover{background-color:rgba(144,202,249,0.08);border:1px solid rgb(144,202,249);}"]) : r(["color:rgb(144,202,249);background-color:transparent;border:1px solid transparent;&:hover{background-color:rgba(144,202,249,0.08);}"]), h = {
7
+ Container: m.button.withConfig({
8
+ displayName: "_style__Container",
9
+ componentId: "sc-1ssweka-0"
10
+ })(["display:flex;align-items:center;justify-content:center;transition:all 0.2s ease;background-color:transparent;box-shadow:none;outline:none;overflow:hidden;border-radius:4px;min-width:64px;padding:6px 12px;font-weight:500;cursor:pointer;", ";", ";&:hover,&:focus{outline:0;text-decoration:none;}"], f, x)
11
+ }, z = ({
12
+ variant: t = "text",
13
+ size: e = "medium",
14
+ loading: n = !1,
15
+ loadingComponent: o,
16
+ className: d,
17
+ htmlAttributes: c,
18
+ children: i,
19
+ onClick: l
20
+ }) => {
21
+ const u = g(() => n ? o ?? /* @__PURE__ */ a(s, { size: 16, fullScreen: !1 }) : i, [i, n, o]);
22
+ return /* @__PURE__ */ a(h.Container, { ...c, $variant: t, $size: e, onClick: l, className: b("button", `button--size-${e}`, `button--variant-${t}`, n && "button--loading", d), children: u });
23
+ };
24
+ export {
25
+ z as Button
26
+ };
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@purr-react-styled-components/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
+ "styled-components": "*",
28
+ "@purr-core/utils.definitions": "0.0.4",
29
+ "@purr-react-styled-components/components.loading-ripple": "0.0.1"
30
+ },
31
+ "author": "@DinhThienPhuc",
32
+ "license": "ISC",
33
+ "description": "",
34
+ "sideEffects": false,
35
+ "scripts": {
36
+ "dev": "vite build --watch",
37
+ "build": "tsc && vite build",
38
+ "lint": "eslint . --ext ts,tsx --max-warnings 0"
39
+ }
40
+ }