@bouku/core 0.2.4 → 0.2.6

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.
@@ -1,8 +1,9 @@
1
1
  type Props = {
2
+ style?: string;
2
3
  label: string;
3
4
  value?: string | number | null;
4
5
  units?: string;
5
6
  note?: string;
6
7
  };
7
- export declare const Card: ({ label, value, units, note }: Props) => import("react").JSX.Element;
8
- export default Card;
8
+ export declare const CalloutCard: ({ style, label, value, units, note }: Props) => import("react").JSX.Element;
9
+ export default CalloutCard;
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Card = void 0;
3
+ exports.CalloutCard = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
- const flex_1 = require("../container/flex");
6
- const Card = ({ label, value, units, note }) => ((0, jsx_runtime_1.jsxs)(flex_1.ColumnBox, { style: s.card, children: [(0, jsx_runtime_1.jsx)("span", { className: s.label, children: label }), (0, jsx_runtime_1.jsxs)("span", { className: s.value, children: [formatValue(value), " ", units] }), (0, jsx_runtime_1.jsx)("span", { className: s.note, children: note })] }));
7
- exports.Card = Card;
5
+ const _1 = require("../container/_");
6
+ const utils_1 = require("../../utils");
7
+ const CalloutCard = ({ style, label, value, units, note }) => ((0, jsx_runtime_1.jsxs)(_1.ColumnBox, { style: (0, utils_1.cn)(s.card, style), children: [(0, jsx_runtime_1.jsx)("span", { className: s.label, children: label }), (0, jsx_runtime_1.jsxs)("span", { className: s.value, children: [formatValue(value), " ", units] }), (0, jsx_runtime_1.jsx)("span", { className: s.note, children: note })] }));
8
+ exports.CalloutCard = CalloutCard;
8
9
  const formatValue = (x) => {
9
10
  if (!x)
10
11
  return "N/A";
@@ -14,9 +15,9 @@ const formatValue = (x) => {
14
15
  return x.toLocaleString("en-US");
15
16
  };
16
17
  const s = {
17
- card: "gap-2 flex-1 p-5 bg-surface border border-border-light rounded-md shadow hover:brightness-120 duration-200",
18
- label: "text-sm font-mono tracking-wide text-primary-dark uppercase",
19
- value: "text-5xl font-bold",
20
- note: "text-xs text-primary-dark"
18
+ card: "gap-1 flex-1 p-4 bg-surface border border-border rounded-md shadow hover:brightness-120 duration-200",
19
+ label: "text-sm font-mono text-primary-dark uppercase whitespace-nowrap",
20
+ value: "text-4xl font-bold whitespace-nowrap",
21
+ note: "text-xs text-primary-dark whitespace-nowrap"
21
22
  };
22
- exports.default = exports.Card;
23
+ exports.default = exports.CalloutCard;
@@ -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: "xs", children: badge })] }), subtitle && ((0, jsx_runtime_1.jsx)("span", { className: `text-xs text-primary-dark ${styles.subtitle}`, children: subtitle }))] })] }));
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?: "xs" | "sm" | "md";
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, icon, children }: Props): import("react").JSX.Element | null;
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", icon, children }) {
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
- xs: "px-1 py-px text-[0.5rem]",
37
- sm: "px-1 py-px text-xs",
38
- md: "px-2 py-1 text-sm"
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)
@@ -23,6 +23,10 @@ export type Hoverable = {
23
23
  export type ListItem = {
24
24
  index: number;
25
25
  };
26
+ export type LabeledItem = {
27
+ id: string;
28
+ label: string;
29
+ };
26
30
  export interface NavItem {
27
31
  label: string;
28
32
  href: string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
 
3
3
  "name": "@bouku/core",
4
- "version": "0.2.4",
4
+ "version": "0.2.6",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "license": "MIT",