@brut-ui/react 0.0.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.
package/dist/index.cjs ADDED
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ Button: () => Button
24
+ });
25
+ module.exports = __toCommonJS(index_exports);
26
+
27
+ // src/components/button/button.tsx
28
+ var import_react = require("react");
29
+
30
+ // src/components/button/button.constants.ts
31
+ var BUTTON_DEFAULTS = {
32
+ variant: "default",
33
+ size: "medium"
34
+ };
35
+
36
+ // src/components/button/button.tsx
37
+ var import_jsx_runtime = require("react/jsx-runtime");
38
+ var Button = (0, import_react.forwardRef)(
39
+ function Button2({
40
+ as,
41
+ variant = BUTTON_DEFAULTS.variant,
42
+ size = BUTTON_DEFAULTS.size,
43
+ children,
44
+ disabled,
45
+ ...rest
46
+ }, ref) {
47
+ const Component = as || "button";
48
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
49
+ Component,
50
+ {
51
+ ref,
52
+ "data-brut-button": "",
53
+ "data-variant": variant,
54
+ "data-size": size,
55
+ "data-disabled": disabled || void 0,
56
+ disabled: Component === "button" ? disabled : void 0,
57
+ "aria-disabled": Component !== "button" ? disabled : void 0,
58
+ ...rest,
59
+ children
60
+ }
61
+ );
62
+ }
63
+ );
64
+ // Annotate the CommonJS export names for ESM import in node:
65
+ 0 && (module.exports = {
66
+ Button
67
+ });
package/dist/index.css ADDED
@@ -0,0 +1,59 @@
1
+ /* src/components/button/button.css */
2
+ [data-brut-button] {
3
+ display: inline-block;
4
+ box-sizing: border-box;
5
+ font-family: var(--brut-font-mono);
6
+ font-weight: 700;
7
+ text-transform: uppercase;
8
+ letter-spacing: 0.08em;
9
+ cursor: pointer;
10
+ border: var(--brut-border);
11
+ border-radius: var(--brut-radius);
12
+ background: var(--brut-black);
13
+ color: var(--brut-white);
14
+ padding: var(--brut-space-sm) var(--brut-space-md);
15
+ line-height: 1.2;
16
+ text-decoration: none;
17
+ }
18
+ [data-brut-button][data-size=small] {
19
+ font-size: 0.75rem;
20
+ padding: var(--brut-space-xs) var(--brut-space-md);
21
+ }
22
+ [data-brut-button][data-size=medium] {
23
+ font-size: 0.875rem;
24
+ }
25
+ [data-brut-button][data-size=large] {
26
+ font-size: 1.125rem;
27
+ padding: var(--brut-space-sm) var(--brut-space-lg);
28
+ }
29
+ [data-brut-button][data-variant=outline] {
30
+ background: var(--brut-white);
31
+ color: var(--brut-black);
32
+ }
33
+ [data-brut-button][data-variant=ghost] {
34
+ background: transparent;
35
+ color: var(--brut-black);
36
+ border-color: transparent;
37
+ }
38
+ [data-brut-button][data-variant=default]:hover:not([data-disabled]) {
39
+ background: var(--brut-white);
40
+ color: var(--brut-black);
41
+ }
42
+ [data-brut-button][data-variant=outline]:hover:not([data-disabled]) {
43
+ background: var(--brut-black);
44
+ color: var(--brut-white);
45
+ }
46
+ [data-brut-button][data-variant=ghost]:hover:not([data-disabled]) {
47
+ border-color: var(--brut-black);
48
+ }
49
+ [data-brut-button]:active:not([data-disabled]) {
50
+ transform: translate(2px, 2px);
51
+ }
52
+ [data-brut-button]:focus-visible {
53
+ outline: var(--brut-focus-outline);
54
+ outline-offset: var(--brut-focus-offset);
55
+ }
56
+ [data-brut-button][data-disabled] {
57
+ opacity: 0.4;
58
+ cursor: not-allowed;
59
+ }
@@ -0,0 +1,40 @@
1
+ import { ElementType, ReactNode, ComponentPropsWithRef } from 'react';
2
+
3
+ /** Available visual variants for Button. */
4
+ declare const BUTTON_VARIANTS: readonly ["default", "outline", "ghost"];
5
+ type ButtonVariant = (typeof BUTTON_VARIANTS)[number];
6
+ /** Available size presets for Button. */
7
+ declare const BUTTON_SIZES: readonly ["small", "medium", "large"];
8
+ type ButtonSize = (typeof BUTTON_SIZES)[number];
9
+
10
+ /**
11
+ * Button — a brutalist action trigger.
12
+ *
13
+ * Renders an accessible, polymorphic button with thick square borders
14
+ * and monospace typography. Supports `default`, `outline`, and `ghost` variants.
15
+ *
16
+ * Uses native `disabled` for `<button>` elements and `aria-disabled` for
17
+ * non-native elements (e.g., `<a>`) to preserve accessibility semantics.
18
+ *
19
+ * @example
20
+ * ```tsx
21
+ * <Button variant="outline" size="large">Submit</Button>
22
+ * <Button as="a" href="/next">Continue</Button>
23
+ * ```
24
+ */
25
+ interface ButtonProps<T extends ElementType = "button"> {
26
+ /** Render as a different element (e.g., `"a"` for links). */
27
+ as?: T;
28
+ /** Visual variant. @default "default" */
29
+ variant?: ButtonVariant;
30
+ /** Size preset. @default "medium" */
31
+ size?: ButtonSize;
32
+ /** Disabled state — sets `data-disabled` and appropriate aria/native attributes. */
33
+ disabled?: boolean;
34
+ /** Content to render inside the button. */
35
+ children: ReactNode;
36
+ }
37
+ type PolymorphicButtonProps<T extends ElementType = "button"> = ButtonProps<T> & Omit<ComponentPropsWithRef<T>, keyof ButtonProps<T>>;
38
+ declare const Button: <T extends ElementType = "button">(props: PolymorphicButtonProps<T>) => ReactNode;
39
+
40
+ export { Button, type ButtonProps, type ButtonSize, type ButtonVariant };
@@ -0,0 +1,40 @@
1
+ import { ElementType, ReactNode, ComponentPropsWithRef } from 'react';
2
+
3
+ /** Available visual variants for Button. */
4
+ declare const BUTTON_VARIANTS: readonly ["default", "outline", "ghost"];
5
+ type ButtonVariant = (typeof BUTTON_VARIANTS)[number];
6
+ /** Available size presets for Button. */
7
+ declare const BUTTON_SIZES: readonly ["small", "medium", "large"];
8
+ type ButtonSize = (typeof BUTTON_SIZES)[number];
9
+
10
+ /**
11
+ * Button — a brutalist action trigger.
12
+ *
13
+ * Renders an accessible, polymorphic button with thick square borders
14
+ * and monospace typography. Supports `default`, `outline`, and `ghost` variants.
15
+ *
16
+ * Uses native `disabled` for `<button>` elements and `aria-disabled` for
17
+ * non-native elements (e.g., `<a>`) to preserve accessibility semantics.
18
+ *
19
+ * @example
20
+ * ```tsx
21
+ * <Button variant="outline" size="large">Submit</Button>
22
+ * <Button as="a" href="/next">Continue</Button>
23
+ * ```
24
+ */
25
+ interface ButtonProps<T extends ElementType = "button"> {
26
+ /** Render as a different element (e.g., `"a"` for links). */
27
+ as?: T;
28
+ /** Visual variant. @default "default" */
29
+ variant?: ButtonVariant;
30
+ /** Size preset. @default "medium" */
31
+ size?: ButtonSize;
32
+ /** Disabled state — sets `data-disabled` and appropriate aria/native attributes. */
33
+ disabled?: boolean;
34
+ /** Content to render inside the button. */
35
+ children: ReactNode;
36
+ }
37
+ type PolymorphicButtonProps<T extends ElementType = "button"> = ButtonProps<T> & Omit<ComponentPropsWithRef<T>, keyof ButtonProps<T>>;
38
+ declare const Button: <T extends ElementType = "button">(props: PolymorphicButtonProps<T>) => ReactNode;
39
+
40
+ export { Button, type ButtonProps, type ButtonSize, type ButtonVariant };
package/dist/index.js ADDED
@@ -0,0 +1,40 @@
1
+ // src/components/button/button.tsx
2
+ import { forwardRef } from "react";
3
+
4
+ // src/components/button/button.constants.ts
5
+ var BUTTON_DEFAULTS = {
6
+ variant: "default",
7
+ size: "medium"
8
+ };
9
+
10
+ // src/components/button/button.tsx
11
+ import { jsx } from "react/jsx-runtime";
12
+ var Button = forwardRef(
13
+ function Button2({
14
+ as,
15
+ variant = BUTTON_DEFAULTS.variant,
16
+ size = BUTTON_DEFAULTS.size,
17
+ children,
18
+ disabled,
19
+ ...rest
20
+ }, ref) {
21
+ const Component = as || "button";
22
+ return /* @__PURE__ */ jsx(
23
+ Component,
24
+ {
25
+ ref,
26
+ "data-brut-button": "",
27
+ "data-variant": variant,
28
+ "data-size": size,
29
+ "data-disabled": disabled || void 0,
30
+ disabled: Component === "button" ? disabled : void 0,
31
+ "aria-disabled": Component !== "button" ? disabled : void 0,
32
+ ...rest,
33
+ children
34
+ }
35
+ );
36
+ }
37
+ );
38
+ export {
39
+ Button
40
+ };
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "@brut-ui/react",
3
+ "version": "0.0.0",
4
+ "description": "Ultra-light brutalist React component library",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/xdebbie/brut.git",
8
+ "directory": "packages/brut-ui"
9
+ },
10
+ "publishConfig": {
11
+ "provenance": true,
12
+ "access": "public"
13
+ },
14
+ "type": "module",
15
+ "main": "./dist/index.cjs",
16
+ "module": "./dist/index.js",
17
+ "types": "./dist/index.d.ts",
18
+ "exports": {
19
+ ".": {
20
+ "types": "./dist/index.d.ts",
21
+ "import": "./dist/index.js",
22
+ "require": "./dist/index.cjs"
23
+ },
24
+ "./styles.css": "./dist/styles.css"
25
+ },
26
+ "files": [
27
+ "dist"
28
+ ],
29
+ "sideEffects": [
30
+ "**/*.css"
31
+ ],
32
+ "scripts": {
33
+ "build": "tsup",
34
+ "test": "vitest run",
35
+ "test:watch": "vitest",
36
+ "test:coverage": "vitest run --coverage"
37
+ },
38
+ "peerDependencies": {
39
+ "react": ">=18",
40
+ "react-dom": ">=18"
41
+ },
42
+ "devDependencies": {
43
+ "@storybook/react-vite": "^10.2.0",
44
+ "@testing-library/jest-dom": "^6.6.3",
45
+ "@testing-library/react": "^16.1.0",
46
+ "@testing-library/user-event": "^14.5.0",
47
+ "@types/react": "^19.0.0",
48
+ "@types/react-dom": "^19.0.0",
49
+ "jsdom": "^25.0.0",
50
+ "react": "^19.0.0",
51
+ "react-dom": "^19.0.0",
52
+ "tsup": "^8.3.0",
53
+ "typescript": "^5.7.0",
54
+ "@vitest/coverage-v8": "^3.0.0",
55
+ "vitest": "^3.0.0"
56
+ }
57
+ }