b44ui 0.0.9 → 0.0.11

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/index.tsx CHANGED
@@ -112,6 +112,34 @@ export const Muted = (props: DProps) => {
112
112
  return <span className={CN("text-sm text-zinc-400", grow && "flex-1", rcn(props))}>{children}</span>
113
113
  }
114
114
 
115
+ export const A = ({
116
+ children, cn, cnIgnoreWrongUsage, grow, gap, p, style, click, href, onClick, onKeyDown, role, tabIndex, ...rest
117
+ }: DProps & { click?: () => void } & React.AnchorHTMLAttributes<HTMLAnchorElement>) => {
118
+ const c = rcn({ cn, cnIgnoreWrongUsage })
119
+ const fire = (e: React.MouseEvent<HTMLAnchorElement> | React.KeyboardEvent<HTMLAnchorElement>) => {
120
+ click?.()
121
+ onClick?.(e as React.MouseEvent<HTMLAnchorElement>)
122
+ }
123
+ const buttonLike = !href
124
+
125
+ return <a
126
+ {...rest}
127
+ href={href}
128
+ role={buttonLike ? role ?? 'button' : role}
129
+ tabIndex={buttonLike ? tabIndex ?? 0 : tabIndex}
130
+ className={CN("inline-flex items-center gap-1 text-zinc-300 underline underline-offset-4 cursor-pointer hover:text-zinc-100", grow && "flex-1", c)}
131
+ style={dStyle({ gap, p, style })}
132
+ onClick={fire}
133
+ onKeyDown={e => {
134
+ if (buttonLike && (e.key === 'Enter' || e.key === ' ')) {
135
+ e.preventDefault()
136
+ fire(e)
137
+ }
138
+ onKeyDown?.(e)
139
+ }}
140
+ >{children}</a>
141
+ }
142
+
115
143
  export const Btn = ({ children, grow, gap, p, click, color, ghost, sm, ...rest }: DProps & { click?: () => void, color?: Color, ghost?: boolean, sm?: boolean } & React.ButtonHTMLAttributes<HTMLButtonElement>) => {
116
144
  const c = rcn(rest as DProps)
117
145
  return <button className={CN("rounded cursor-pointer", sm ? "px-3 py-1 text-xs" : "px-4 py-2 text-sm",
package/package.json CHANGED
@@ -1,12 +1,18 @@
1
1
  {
2
2
  "name": "b44ui",
3
- "version": "0.0.9",
3
+ "version": "0.0.11",
4
4
  "type": "module",
5
+ "files": [
6
+ "index.tsx",
7
+ "styles.css",
8
+ "tailwind.css"
9
+ ],
5
10
  "scripts": {
6
11
  "dev": "npm run dev --prefix example"
7
12
  },
8
13
  "exports": {
9
14
  ".": "./index.tsx",
15
+ "./tailwind.css": "./tailwind.css",
10
16
  "./styles.css": "./styles.css"
11
17
  },
12
18
  "dependencies": {
@@ -17,9 +23,11 @@
17
23
  "tailwind-merge": "^3.0.0"
18
24
  },
19
25
  "peerDependencies": {
20
- "react": "^19.0.0"
26
+ "react": "^19.0.0",
27
+ "tailwindcss": "^4.0.0"
21
28
  },
22
29
  "devDependencies": {
23
- "@types/react": "^19.2.14"
30
+ "@types/react": "^19.2.14",
31
+ "tailwindcss": "^4.0.0"
24
32
  }
25
33
  }
@@ -3,15 +3,25 @@
3
3
  minimal dark-mode react components, via tailwind
4
4
 
5
5
  ```bash
6
- # setup
6
+ npm add b44ui
7
+ ```
8
+
9
+ ```css
10
+ @import "b44ui/tailwind.css";
11
+ ```
12
+
13
+ if your app already has `@import "tailwindcss";`, replace that line with the one above.
7
14
 
8
- pnpm add b44ui
15
+ the host app still needs tailwind v4 processing. with vite:
9
16
 
10
- echo 'optimizeDeps: { include: ["b44ui", "highlight.js"] }' >> vite.config.ts
17
+ ```ts
18
+ import { defineConfig } from "vite"
19
+ import react from "@vitejs/plugin-react"
20
+ import tailwindcss from "@tailwindcss/vite"
11
21
 
12
- echo '@import "tailwindcss";
13
- @source "../node_modules/b44ui/index.tsx";
14
- @import "b44ui/styles.css";' > src/index.css
22
+ export default defineConfig({
23
+ plugins: [react(), tailwindcss()],
24
+ })
15
25
  ```
16
26
 
17
27
  | Component | Props | Description |
@@ -21,11 +31,13 @@ echo '@import "tailwindcss";
21
31
  | `D` | `cn`, `style`, `grow` | Plain div with `cn` |
22
32
  | `Row` | `align`, `ratio`, `cn`, `grow` | Flex row, `align`: `start \| mid \| end` |
23
33
  | `Col` | `cn`, `grow` | Flex column |
34
+ | `Code` | `highlight` | Code block |
24
35
  | `Grid` | `cols`, `cn`, `grow` | CSS grid, defaults to one column per child |
25
36
  | `Card` | `cn`, `grow` | Bordered zinc-900 card |
26
37
  | `Block` | `label`, `row`, `dashed`, `cn`, `grow` | Padded container with optional label |
27
38
  | `BlockSm` | `dashed`, `cn`, `grow` | Smaller padded container |
28
39
  | `Btn` | `click`, `color`, `ghost`, `cn`, `grow` | Button, supports `Color` and ghost style |
40
+ | `A` | `href`, `click`, `cn`, `grow` | Link-styled anchor, works with `onClick` or `href` |
29
41
  | `Chip` | `click`, `cn` | Small inline badge, clickable if `click` provided |
30
42
  | `Tint` | `color`, `cn`, `grow` | Tinted background block |
31
43
  | `Muted` | `cn`, `grow` | Small muted text |
package/tailwind.css ADDED
@@ -0,0 +1,3 @@
1
+ @import "tailwindcss";
2
+ @source "./index.tsx";
3
+ @import "./styles.css";
@@ -1,12 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
- <title>ui kitchen sink</title>
7
- </head>
8
- <body>
9
- <div id="root"></div>
10
- <script type="module" src="/src/main.tsx"></script>
11
- </body>
12
- </html>
@@ -1,22 +0,0 @@
1
- {
2
- "name": "ui-kitchen-sink",
3
- "private": true,
4
- "type": "module",
5
- "scripts": {
6
- "dev": "vite"
7
- },
8
- "dependencies": {
9
- "react": "^19.0.0",
10
- "react-dom": "^19.0.0",
11
- "ui": "file:.."
12
- },
13
- "devDependencies": {
14
- "@types/react": "^19.0.0",
15
- "@types/react-dom": "^19.0.0",
16
- "@tailwindcss/vite": "^4.0.0",
17
- "tailwindcss": "^4.0.0",
18
- "typescript": "^5.7.0",
19
- "vite": "^6.0.0",
20
- "@vitejs/plugin-react": "^4.3.0"
21
- }
22
- }