@edux-design/buttons 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.
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@edux-design/buttons",
3
+ "version": "0.0.1",
4
+ "private": false,
5
+ "sideEffects": [
6
+ "**/*.css"
7
+ ],
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.mjs",
11
+ "require": "./dist/index.js"
12
+ }
13
+ },
14
+ "scripts": {
15
+ "lint": "eslint . --max-warnings 0",
16
+ "build": "tsup src/index.js --format esm,cjs",
17
+ "dev": "tsup src/index.js --watch --format esm,cjs",
18
+ "generate:component": "turbo gen react-component",
19
+ "check-types": "tsc --noEmit"
20
+ },
21
+ "devDependencies": {
22
+ "typescript": "^5.9.2",
23
+ "tailwindcss": "^4.1.12",
24
+ "postcss": "^8.5.6",
25
+ "tsup": "^8.5.0",
26
+ "@tailwindcss/cli": "^4.1.12",
27
+ "@tailwindcss/postcss": "^4.1.12"
28
+ },
29
+ "dependencies": {
30
+ "react": "^19.1.0",
31
+ "react-dom": "^19.1.0",
32
+ "@edux-design/utils": "*"
33
+ }
34
+ }
@@ -0,0 +1,79 @@
1
+ import React, { forwardRef } from "react";
2
+ import { cx } from "@edux-design/utils";
3
+
4
+ export const Button = forwardRef(
5
+ (
6
+ {
7
+ children,
8
+ size = "medium",
9
+ isSecondary,
10
+ isDanger,
11
+ isBare,
12
+ isStretched,
13
+ disabled,
14
+ className,
15
+ ...props
16
+ },
17
+ ref
18
+ ) => {
19
+ let variant = "primary";
20
+ if (isBare) variant = "bare";
21
+ if (isSecondary) variant = "secondary";
22
+ if (isDanger) variant = "danger";
23
+ if (disabled) variant = "disabled";
24
+
25
+ // handle conflicting props - the last bool wins. i.e. The priority we are accepting is isbare, isSecondary, isDanger, disabled
26
+
27
+ if (process.env.NODE_ENV !== "production") {
28
+ const count = [isSecondary, isDanger, isBare].filter(Boolean).length;
29
+ if (count > 1) {
30
+ console.warn(
31
+ "[Button]: Multiple variant props passed. Using the highest priority only."
32
+ );
33
+ }
34
+ }
35
+
36
+ const defaults =
37
+ "flex justify-center items-center focus:shadow-focus focus-visible:shadow-focus outline-none transition-all duration-300 ease-in-out";
38
+
39
+ const fonts =
40
+ "text-bold tracking-normal hover:underline hover:underline-offset-(--underline-offset-btn) active:underline active:underline-offset-(--underline-offset-btn)";
41
+
42
+ //FIX-ME - Remove hardcoded values
43
+ const sizes = {
44
+ small: "h-[36px] py-8 px-16 rounded-lg text-sm",
45
+ medium: "h-[44px] py-8 px-16 rounded-lg text-base",
46
+ large: "h-[56px] py-8 px-16 rounded-lg text-lg",
47
+ };
48
+
49
+ const width = isStretched ? "w-full" : "w-fit-content";
50
+
51
+ const variants = {
52
+ primary:
53
+ "border-2 border-border-primary-emphasis bg-bg-primary-base text-white hover:bg-border-focus hover:text-fg-base hover:border-border-emphasis hover:shadow-md active:bg-border-focus active:bg-bg-focus-overlay active:text-fg-base",
54
+ secondary:
55
+ "border-2 border-border-primary-base bg-bg-base text-fg-primary-emphasis hover:shadow-md hover:bg-bg-primary-subtle active:bg-bg-primary-subtle-90",
56
+ bare: "bg-bg-base text-fg-primary-emphasis hover:bg-bg-minimal active:bg-bg-minimal-5",
57
+ danger:
58
+ "bg-bg-danger-base border-2 border-border-danger-emphasis text-white hover:bg-bg-danger-base-5 active:bg-bg-danger-base-10",
59
+ disabled:
60
+ "border-2 border-border-subtle bg-bg-inactive text-fg-inactive hover:no-underline",
61
+ };
62
+
63
+ const STYLES = cx(defaults, sizes[size], width, fonts, variants[variant]);
64
+
65
+ return (
66
+ <button
67
+ role="button"
68
+ type="button"
69
+ aria-disabled={disabled}
70
+ disabled={disabled}
71
+ className={STYLES}
72
+ ref={ref}
73
+ {...props}
74
+ >
75
+ {children}
76
+ </button>
77
+ );
78
+ }
79
+ );
@@ -0,0 +1,20 @@
1
+ import React from "react";
2
+ import { MenuButtonContext } from "../util/MenuButtonContext";
3
+ import { cx } from "@edux-design/utils";
4
+ import { Chevron } from "@edux-design/icons";
5
+
6
+ export function MenuButton({ children, size }) {
7
+ const SPLIT_BUTTON_STYLES = cx(
8
+ "w-[36px] border-l-[1px] border-l-black flex flex-row justify-center items-center",
9
+ {
10
+ "h-[32px]": size === "small",
11
+ "h-[40px] py-2": size === "medium" || size === undefined,
12
+ }
13
+ );
14
+ return (
15
+ <MenuButtonContext.Provider value>
16
+ <div>{children}</div>
17
+ <Chevron />
18
+ </MenuButtonContext.Provider>
19
+ );
20
+ }
package/src/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { Button } from "./elements/Button";
2
+ export { MenuButton } from "./elements/MenuButton";
@@ -0,0 +1,3 @@
1
+ import React, { createContext, useContext } from "react";
2
+
3
+ export const MenuButtonContext = createContext();