@bouko/react 1.9.9 → 2.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/dist/components/badge.d.ts +5 -0
- package/dist/components/badge.js +4 -0
- package/dist/components/flex.d.ts +16 -0
- package/dist/components/flex.js +8 -0
- package/dist/components/layout/heading.d.ts +23 -16
- package/dist/components/layout/heading.js +17 -40
- package/dist/components/search/index.d.ts +6 -0
- package/dist/components/search/index.js +12 -0
- package/dist/core/functions.d.ts +1 -0
- package/dist/core/functions.js +15 -0
- package/dist/hooks/color.d.ts +7 -0
- package/dist/hooks/color.js +8 -0
- package/package.json +2 -2
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
export default function Badge({ style, children }) {
|
|
3
|
+
return (_jsx("span", { className: "w-min px-3 py-1 bg-accent/20 border border-accent-dark rounded-full text-xs text-accent-dark font-semibold", children: children }));
|
|
4
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
type Props = Position & {
|
|
3
|
+
style?: string;
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
};
|
|
6
|
+
type Position = {
|
|
7
|
+
center?: boolean;
|
|
8
|
+
centerX?: boolean;
|
|
9
|
+
centerY?: boolean;
|
|
10
|
+
};
|
|
11
|
+
export declare function ColumnBox({ style, center, centerX, centerY, children }: Props): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export declare function RowBox({ style, children }: {
|
|
13
|
+
style?: string;
|
|
14
|
+
children: ReactNode;
|
|
15
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "@bouko/style";
|
|
3
|
+
export function ColumnBox({ style, center, centerX, centerY, children }) {
|
|
4
|
+
return (_jsx("div", { className: cn("flex flex-col", center && "items-center justify-center", centerX && "items-center", centerY && "justify-center", style), children: children }));
|
|
5
|
+
}
|
|
6
|
+
export function RowBox({ style, children }) {
|
|
7
|
+
return (_jsx("div", { className: cn("flex", style), children: children }));
|
|
8
|
+
}
|
|
@@ -1,24 +1,31 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
|
-
type
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
type Props = {
|
|
3
|
+
badge?: string;
|
|
4
|
+
title: ReactNode;
|
|
5
|
+
subtitle?: ReactNode;
|
|
6
|
+
style?: Styles;
|
|
5
7
|
};
|
|
6
8
|
type Styles = {
|
|
7
9
|
container?: string;
|
|
8
|
-
|
|
10
|
+
badge?: string;
|
|
9
11
|
title?: string;
|
|
10
12
|
subtitle?: string;
|
|
11
13
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
reverse?: boolean;
|
|
22
|
-
};
|
|
23
|
-
export default function Heading({ styles, options, badge, icon, title, subtitle, reverse }: Props): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
/**
|
|
15
|
+
* Text heading with badge, title, subtitle.
|
|
16
|
+
*
|
|
17
|
+
* @param {string} badge - Little note above the title (optional).
|
|
18
|
+
* @param {ReactNode} title - Main title content.
|
|
19
|
+
* @param {ReactNode} subtitle - Subtitle content (optional).
|
|
20
|
+
* @param {Styles} style - Additional styles (optional).
|
|
21
|
+
**/
|
|
22
|
+
export default function Heading({ badge, title, subtitle, style }: Props): import("react/jsx-runtime").JSX.Element;
|
|
24
23
|
export {};
|
|
24
|
+
/**
|
|
25
|
+
* Problems
|
|
26
|
+
*
|
|
27
|
+
* - Perfect `mergeStyles`
|
|
28
|
+
* - Perfect `RowBox`
|
|
29
|
+
* - Perfect `ColumnBox`
|
|
30
|
+
* - Perfect `Badge`
|
|
31
|
+
**/
|
|
@@ -1,45 +1,22 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import { RowBox, ColumnBox } from "
|
|
4
|
-
import Badge from "../text/badge";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
import { mergeStyles } from "@bouko/style";
|
|
3
|
+
import { RowBox, ColumnBox } from "./flex";
|
|
4
|
+
import { default as Badge } from "../text/badge";
|
|
5
|
+
/**
|
|
6
|
+
* Text heading with badge, title, subtitle.
|
|
7
|
+
*
|
|
8
|
+
* @param {string} badge - Little note above the title (optional).
|
|
9
|
+
* @param {ReactNode} title - Main title content.
|
|
10
|
+
* @param {ReactNode} subtitle - Subtitle content (optional).
|
|
11
|
+
* @param {Styles} style - Additional styles (optional).
|
|
12
|
+
**/
|
|
13
|
+
export default function Heading({ badge, title, subtitle, style = {} }) {
|
|
14
|
+
const styles = mergeStyles(base, style);
|
|
15
|
+
return (_jsxs(ColumnBox, { style: styles.container, children: [_jsx(Badge, { style: styles.badge, children: badge }), _jsx(RowBox, { style: styles.title, children: title }), _jsx(RowBox, { style: styles.subtitle, children: subtitle })] }));
|
|
8
16
|
}
|
|
9
17
|
const base = {
|
|
10
|
-
container: "
|
|
18
|
+
container: "items-center",
|
|
11
19
|
badge: "mb-2",
|
|
20
|
+
title: "items-center gap-2 text-xl sm:text-2xl 2xl:text-3xl font-bold text-primary",
|
|
21
|
+
subtitle: "items-center gap-2 max-sm:text-sm 2xl:text-lg text-primary-light dark:text-primary-dark"
|
|
12
22
|
};
|
|
13
|
-
const test = tv({
|
|
14
|
-
slots: {
|
|
15
|
-
subcontainer: "grow",
|
|
16
|
-
title: "items-center gap-2 text-xl font-bold text-primary",
|
|
17
|
-
subtitle: "items-center gap-2 font-semibold text-primary-light dark:text-primary-dark"
|
|
18
|
-
},
|
|
19
|
-
defaultVariants: {
|
|
20
|
-
size: "md",
|
|
21
|
-
align: "center"
|
|
22
|
-
},
|
|
23
|
-
variants: {
|
|
24
|
-
size: {
|
|
25
|
-
md: {
|
|
26
|
-
title: "text-xl 2xl:text-2xl",
|
|
27
|
-
subtitle: "text-base 2xl:text-lg"
|
|
28
|
-
},
|
|
29
|
-
lg: {
|
|
30
|
-
subcontainer: "gap-3",
|
|
31
|
-
title: "text-5xl 2xl:text-6xl",
|
|
32
|
-
subtitle: "text-sm sm:text-base 2xl:text-lg"
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
align: {
|
|
36
|
-
left: {
|
|
37
|
-
subcontainer: "items-start"
|
|
38
|
-
},
|
|
39
|
-
center: {
|
|
40
|
-
subcontainer: "items-center",
|
|
41
|
-
subtitle: "justify-center text-center"
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { RowBox } from "../flex";
|
|
5
|
+
import { Button } from "../button";
|
|
6
|
+
export default function SearchBar({ placeholder, action }) {
|
|
7
|
+
const [query, search] = useState("");
|
|
8
|
+
return (_jsxs(RowBox, { style: styles.container, children: [_jsxs("div", { className: "relative grow", children: [_jsx("input", { className: "w-full outline-none lowercase text-lg placeholder-slate-500 tracking-wide", placeholder: placeholder, value: query, onChange: (e) => search(e.target.value), onKeyUp: (e) => e.key === "Enter" ? action(query) : null }), _jsx("div", { className: "absolute top-0 right-0 w-12 h-full bg-gradient-to-l from-slate-950" })] }), _jsx(Button, { size: "sm", style: "gap-[0.4rem] font-extrabold py-1 px-3 font-mono", onClick: () => action(query), children: "GO" })] }));
|
|
9
|
+
}
|
|
10
|
+
const styles = {
|
|
11
|
+
container: "items-center gap-6 w-xl pl-5 pr-4 py-3 bg-slate-950 border border-border rounded-md"
|
|
12
|
+
};
|
package/dist/core/functions.d.ts
CHANGED
package/dist/core/functions.js
CHANGED
|
@@ -13,6 +13,21 @@ export const getFileData = (files) => Promise.all(files.map((file) => {
|
|
|
13
13
|
reader.readAsDataURL(file);
|
|
14
14
|
});
|
|
15
15
|
}));
|
|
16
|
+
export const getAudioDuration = (file) => {
|
|
17
|
+
return new Promise((resolve, reject) => {
|
|
18
|
+
const url = URL.createObjectURL(file);
|
|
19
|
+
const audio = new Audio(url);
|
|
20
|
+
audio.addEventListener("loadedmetadata", () => {
|
|
21
|
+
const durationMs = audio.duration * 1000;
|
|
22
|
+
URL.revokeObjectURL(url);
|
|
23
|
+
resolve(durationMs);
|
|
24
|
+
});
|
|
25
|
+
audio.addEventListener("error", (e) => {
|
|
26
|
+
URL.revokeObjectURL(url);
|
|
27
|
+
reject(new Error("Failed to load audio metadata"));
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
};
|
|
16
31
|
export const getEnv = (key) => {
|
|
17
32
|
const value = process.env[key];
|
|
18
33
|
if (!value)
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useEffect } from "react";
|
|
3
|
+
export default function useColor({ variable, color, original }) {
|
|
4
|
+
useEffect(() => {
|
|
5
|
+
document.documentElement.style.setProperty(`--${variable}`, color);
|
|
6
|
+
return () => document.documentElement.style.setProperty(`--${variable}`, original);
|
|
7
|
+
}, []);
|
|
8
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
|
|
3
3
|
"name": "@bouko/react",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "2.0.1",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"license": "MIT",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
},
|
|
21
21
|
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@bouko/style": "^0.1.
|
|
23
|
+
"@bouko/style": "^0.1.3",
|
|
24
24
|
"clsx": "^2.1.1",
|
|
25
25
|
"framer-motion": "^12.23.6",
|
|
26
26
|
"tailwind-merge": "^3.3.0",
|