b44ui 0.0.3 → 0.0.5
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/README.md +41 -0
- package/example/pnpm-lock.yaml +1499 -0
- package/example/vite.config.ts +3 -0
- package/{comps.tsx → index.tsx} +22 -21
- package/package.json +14 -5
- package/Markdown.tsx +0 -12
- package/cn.ts +0 -4
- package/index.ts +0 -3
package/example/vite.config.ts
CHANGED
package/{comps.tsx → index.tsx}
RENAMED
|
@@ -1,21 +1,16 @@
|
|
|
1
|
-
import { type ReactNode, Children, useState } from "react"
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
1
|
+
import { type ReactNode, Children, useMemo, useState } from "react"
|
|
2
|
+
import { Marked } from "marked"
|
|
3
|
+
import { markedHighlight } from "marked-highlight"
|
|
4
|
+
import hljs from "highlight.js"
|
|
5
|
+
import type { ClassValue } from "clsx"
|
|
6
|
+
import clsx from "clsx"
|
|
7
|
+
import { twMerge } from "tailwind-merge"
|
|
4
8
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
red: 'bg-red-500/20 border-red-500',
|
|
9
|
-
purple: 'bg-purple-500/20 border-purple-500',
|
|
10
|
-
} as const
|
|
9
|
+
export type Color = 'red' | 'blue' | 'orange' | 'purple' | 'yellow'
|
|
10
|
+
const tintCn = (c: Color) => `bg-${c}-500/20 border-${c}-500`
|
|
11
|
+
const colorCn = (c: Color) => `bg-${c}-600 hover:bg-${c}-500`
|
|
11
12
|
|
|
12
|
-
const
|
|
13
|
-
blue: 'bg-blue-600 hover:bg-blue-500',
|
|
14
|
-
red: 'bg-red-600 hover:bg-red-500',
|
|
15
|
-
green: 'bg-green-600 hover:bg-green-500',
|
|
16
|
-
} as const
|
|
17
|
-
|
|
18
|
-
export type Color = keyof typeof btnColors
|
|
13
|
+
export const CN = (...inputs: ClassValue[]) => twMerge(clsx(inputs))
|
|
19
14
|
|
|
20
15
|
export type DProps = { children?: ReactNode, cn?: any, style?: React.CSSProperties, grow?: boolean }
|
|
21
16
|
export const D = ({ children, cn, style, grow }: DProps) =>
|
|
@@ -51,10 +46,10 @@ export const Card = ({ children, cn, grow }: DProps) =>
|
|
|
51
46
|
export const Col = ({ children, cn, grow }: DProps) =>
|
|
52
47
|
<D cn={["flex flex-col gap-3", cn]} grow={grow}>{children}</D>
|
|
53
48
|
|
|
54
|
-
export const Popover = ({ children, text, color, cn }: DProps & { text: ReactNode, color?:
|
|
49
|
+
export const Popover = ({ children, text, color, cn }: DProps & { text: ReactNode, color?: Color }) => {
|
|
55
50
|
const [open, setOpen] = useState(false)
|
|
56
51
|
return <span className="relative inline-block" onMouseEnter={() => setOpen(true)} onMouseLeave={() => setOpen(false)}>
|
|
57
|
-
<span className={CN("cursor-pointer", color &&
|
|
52
|
+
<span className={CN("cursor-pointer", color && tintCn(color), color && "border-b-2", cn)}>{children}</span>
|
|
58
53
|
{open && <div className="absolute left-0 top-full z-10 mt-1">
|
|
59
54
|
<Card cn="w-64 p-3 shadow-lg text-sm">{text}</Card>
|
|
60
55
|
</div>}
|
|
@@ -66,11 +61,11 @@ export const Muted = ({ children, cn, grow }: DProps) =>
|
|
|
66
61
|
|
|
67
62
|
export const Btn = ({ children, cn, grow, click, color, ghost, ...rest }: DProps & { click?: () => void, color?: Color, ghost?: boolean } & React.ButtonHTMLAttributes<HTMLButtonElement>) =>
|
|
68
63
|
<button className={CN("rounded px-4 py-2 text-sm cursor-pointer",
|
|
69
|
-
ghost ? "bg-transparent text-zinc-400 hover:bg-zinc-800" : color ?
|
|
64
|
+
ghost ? "bg-transparent text-zinc-400 hover:bg-zinc-800" : color ? colorCn(color) : "bg-zinc-800 hover:bg-zinc-700", grow && "flex-1", cn)}
|
|
70
65
|
onClick={click} {...rest}>{children}</button>
|
|
71
66
|
|
|
72
|
-
export const Tint = ({ children, color, cn, grow }: DProps & { color:
|
|
73
|
-
<D cn={["p-3 rounded text-sm",
|
|
67
|
+
export const Tint = ({ children, color, cn, grow }: DProps & { color: Color }) =>
|
|
68
|
+
<D cn={["p-3 rounded text-sm", tintCn(color), cn]} grow={grow}>{children}</D>
|
|
74
69
|
|
|
75
70
|
export const Row = ({ children, ratio, align, cn, grow }: DProps & { ratio?: number, align?: 'mid' | 'start' | 'end' }) =>
|
|
76
71
|
<div className={CN("flex gap-2 items-center", align === 'mid' && "justify-between", align == 'end' && "justify-end", align == 'start' && "justify-start", grow && "flex-1", cn)}
|
|
@@ -92,3 +87,9 @@ export const Select = ({ cn, grow, ...rest }: { cn?: any, grow?: boolean } & Rea
|
|
|
92
87
|
|
|
93
88
|
export const Grid = ({ children, cols, cn, grow }: DProps & { cols?: number }) =>
|
|
94
89
|
<D cn={["grid gap-4", cn]} grow={grow} style={{ gridTemplateColumns: `repeat(${cols ?? Children.count(children)}, 1fr)` }}>{children}</D>
|
|
90
|
+
|
|
91
|
+
const marked = new Marked(markedHighlight({ langPrefix: "hljs language-", highlight: c => hljs.highlightAuto(c).value }))
|
|
92
|
+
export const Md = ({ children, className }: { children: string, className?: string }) => {
|
|
93
|
+
const html = useMemo(() => marked.parse(children) as string, [children])
|
|
94
|
+
return <div className={CN("ui-markdown", className)} dangerouslySetInnerHTML={{ __html: html }} />
|
|
95
|
+
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "b44ui",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"scripts": {
|
|
6
|
-
|
|
5
|
+
"scripts": {
|
|
6
|
+
"dev": "npm run dev --prefix example"
|
|
7
|
+
},
|
|
8
|
+
"exports": {
|
|
9
|
+
".": "./index.tsx",
|
|
10
|
+
"./styles.css": "./styles.css"
|
|
11
|
+
},
|
|
7
12
|
"dependencies": {
|
|
8
13
|
"clsx": "^2.1.1",
|
|
9
14
|
"highlight.js": "^11.11.0",
|
|
@@ -11,6 +16,10 @@
|
|
|
11
16
|
"marked-highlight": "^2.2.0",
|
|
12
17
|
"tailwind-merge": "^3.0.0"
|
|
13
18
|
},
|
|
14
|
-
"peerDependencies": {
|
|
15
|
-
|
|
19
|
+
"peerDependencies": {
|
|
20
|
+
"react": "^19.0.0"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@types/react": "^19.2.14"
|
|
24
|
+
}
|
|
16
25
|
}
|
package/Markdown.tsx
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { useMemo } from "react"
|
|
2
|
-
import { Marked } from "marked"
|
|
3
|
-
import { markedHighlight } from "marked-highlight"
|
|
4
|
-
import hljs from "highlight.js"
|
|
5
|
-
import cn from "./cn"
|
|
6
|
-
|
|
7
|
-
const marked = new Marked(markedHighlight({ langPrefix: "hljs language-", highlight: c => hljs.highlightAuto(c).value }))
|
|
8
|
-
|
|
9
|
-
export const Md = ({ children, className }: { children: string, className?: string }) => {
|
|
10
|
-
const html = useMemo(() => marked.parse(children) as string, [children])
|
|
11
|
-
return <div className={cn("ui-markdown", className)} dangerouslySetInnerHTML={{ __html: html }} />
|
|
12
|
-
}
|
package/cn.ts
DELETED
package/index.ts
DELETED