b44ui 0.0.10 → 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.
Files changed (3) hide show
  1. package/index.tsx +28 -0
  2. package/package.json +1 -1
  3. package/readme.md +1 -0
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,6 +1,6 @@
1
1
  {
2
2
  "name": "b44ui",
3
- "version": "0.0.10",
3
+ "version": "0.0.11",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "index.tsx",
package/readme.md CHANGED
@@ -37,6 +37,7 @@ export default defineConfig({
37
37
  | `Block` | `label`, `row`, `dashed`, `cn`, `grow` | Padded container with optional label |
38
38
  | `BlockSm` | `dashed`, `cn`, `grow` | Smaller padded container |
39
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` |
40
41
  | `Chip` | `click`, `cn` | Small inline badge, clickable if `click` provided |
41
42
  | `Tint` | `color`, `cn`, `grow` | Tinted background block |
42
43
  | `Muted` | `cn`, `grow` | Small muted text |