@bouku/core 0.2.4 → 0.2.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.
|
@@ -6,5 +6,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
7
|
const flex_1 = require("../container/flex");
|
|
8
8
|
const badge_1 = __importDefault(require("../text/badge"));
|
|
9
|
-
const MediaCard = ({ media, title, subtitle, badge, styles = {}, }) => ((0, jsx_runtime_1.jsxs)(flex_1.RowBox, { style: `items-center gap-3 ${styles.container ?? ""}`, children: [(0, jsx_runtime_1.jsx)("img", { src: media, className: "size-10 w-10 h-10 border border-border rounded", alt: title }), (0, jsx_runtime_1.jsxs)(flex_1.ColumnBox, { style: "gap-px min-w-0", children: [(0, jsx_runtime_1.jsxs)(flex_1.RowBox, { style: "items-center gap-2 min-w-0", children: [(0, jsx_runtime_1.jsx)("span", { className: `text-primary text-sm font-semibold truncate ${styles.title ?? ""}`, children: title }), badge && (0, jsx_runtime_1.jsx)(badge_1.default, { size: "
|
|
9
|
+
const MediaCard = ({ media, title, subtitle, badge, styles = {}, }) => ((0, jsx_runtime_1.jsxs)(flex_1.RowBox, { style: `items-center gap-3 ${styles.container ?? ""}`, children: [(0, jsx_runtime_1.jsx)("img", { src: media, className: "size-10 w-10 h-10 border border-border rounded", alt: title }), (0, jsx_runtime_1.jsxs)(flex_1.ColumnBox, { style: "gap-px min-w-0", children: [(0, jsx_runtime_1.jsxs)(flex_1.RowBox, { style: "items-center gap-2 min-w-0", children: [(0, jsx_runtime_1.jsx)("span", { className: `text-primary text-sm font-semibold truncate ${styles.title ?? ""}`, children: title }), badge && (0, jsx_runtime_1.jsx)(badge_1.default, { size: "sm", children: badge })] }), subtitle && ((0, jsx_runtime_1.jsx)("span", { className: `text-xs text-primary-dark ${styles.subtitle}`, children: subtitle }))] })] }));
|
|
10
10
|
exports.default = MediaCard;
|
|
@@ -2,7 +2,7 @@ import type { Component } from "../../utils";
|
|
|
2
2
|
type Props = Component & {
|
|
3
3
|
color?: string;
|
|
4
4
|
icon?: React.ReactNode;
|
|
5
|
-
size?: "
|
|
5
|
+
size?: "sm" | "md" | "lg";
|
|
6
6
|
};
|
|
7
7
|
/**
|
|
8
8
|
* Color-themed badge component.
|
|
@@ -14,5 +14,5 @@ type Props = Component & {
|
|
|
14
14
|
*
|
|
15
15
|
* @param {string} color - Color of badge. (optional, default = accent)
|
|
16
16
|
**/
|
|
17
|
-
export declare function Badge({ style, color, size,
|
|
17
|
+
export declare function Badge({ style, color, size, children }: Props): import("react").JSX.Element | null;
|
|
18
18
|
export default Badge;
|
|
@@ -14,11 +14,9 @@ const tailwind_variants_1 = require("tailwind-variants");
|
|
|
14
14
|
*
|
|
15
15
|
* @param {string} color - Color of badge. (optional, default = accent)
|
|
16
16
|
**/
|
|
17
|
-
function Badge({ style, color = "--color-accent", size = "md",
|
|
17
|
+
function Badge({ style, color = "--color-accent", size = "md", children }) {
|
|
18
18
|
if (!children)
|
|
19
19
|
return null;
|
|
20
|
-
if (color === "future")
|
|
21
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-2 test-badge", children: [icon && (0, jsx_runtime_1.jsx)("div", { className: "text-primary-dark", children: icon }), (0, jsx_runtime_1.jsx)("span", { children: children })] }));
|
|
22
20
|
return ((0, jsx_runtime_1.jsx)("span", { className: (0, style_1.cn)(base({ size }), style), style: styles(color), children: children }));
|
|
23
21
|
}
|
|
24
22
|
const styles = (color) => ({
|
|
@@ -30,12 +28,12 @@ const styles = (color) => ({
|
|
|
30
28
|
color: "var(--color-primary)"
|
|
31
29
|
});
|
|
32
30
|
const base = (0, tailwind_variants_1.tv)({
|
|
33
|
-
base: "w-min",
|
|
31
|
+
base: "w-min px-2 py-1",
|
|
34
32
|
variants: {
|
|
35
33
|
size: {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
sm: "text-xs",
|
|
35
|
+
md: "text-sm",
|
|
36
|
+
lg: "text-base"
|
|
39
37
|
}
|
|
40
38
|
}
|
|
41
39
|
});
|
|
@@ -51,10 +51,17 @@ function opacitize(color, opacity = 0.5) {
|
|
|
51
51
|
transparent
|
|
52
52
|
)
|
|
53
53
|
`;
|
|
54
|
+
if (color.startsWith("--"))
|
|
55
|
+
return `
|
|
56
|
+
color-mix(
|
|
57
|
+
in srgb,
|
|
58
|
+
var(${color}) ${opacity * 100}%,
|
|
59
|
+
transparent
|
|
60
|
+
)
|
|
61
|
+
`;
|
|
54
62
|
const { r, g, b } = parseHex(color);
|
|
55
63
|
return `rgba(${r}, ${g}, ${b}, ${opacity})`;
|
|
56
64
|
}
|
|
57
|
-
;
|
|
58
65
|
const parseHex = (input) => {
|
|
59
66
|
let hex = input.replace("#", "");
|
|
60
67
|
if (hex.length === 3)
|