@bouko/react 1.9.8 → 2.0.0

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,24 +1,31 @@
1
1
  import { ReactNode } from "react";
2
- type Options = {
3
- size?: "md" | "lg";
4
- align?: "left" | "center";
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
- text?: string;
10
+ badge?: string;
9
11
  title?: string;
10
12
  subtitle?: string;
11
13
  };
12
- type Props = {
13
- options?: Options;
14
- styles?: Styles;
15
- badge?: string;
16
- icon?: ReactNode;
17
- title: ReactNode;
18
- size?: "md" | "lg";
19
- align?: "left" | "center";
20
- subtitle?: ReactNode;
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 { cn, tv } from "@bouko/style";
3
- import { RowBox, ColumnBox } from "..";
4
- import Badge from "../text/badge";
5
- export default function Heading({ styles = {}, options = {}, badge, icon, title, subtitle, reverse }) {
6
- const custom = test(options);
7
- return (_jsxs(RowBox, { style: cn(base.container, styles.container), children: [icon, _jsxs(ColumnBox, { style: cn(custom.subcontainer(), reverse && "flex-col-reverse"), children: [badge && _jsx(Badge, { style: base.badge, children: badge }), _jsx(RowBox, { style: cn(custom.title(), styles.title, styles.text), children: title }), subtitle && _jsx(RowBox, { style: cn(custom.subtitle(), styles.subtitle, styles.text), children: subtitle })] })] }));
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: "gap-2 items-center",
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
- });
@@ -1,9 +1,8 @@
1
- import type { ReactNode } from "react";
2
1
  type Color = "accent" | "orange" | "dark";
3
2
  type Props = {
4
3
  style?: string;
5
4
  color?: Color;
6
- children: ReactNode;
5
+ children?: string;
7
6
  };
8
7
  export default function Badge({ style, color, children }: Props): import("react/jsx-runtime").JSX.Element;
9
8
  export {};
@@ -1,6 +1,8 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
2
2
  import { cn, tv } from "@bouko/style";
3
3
  export default function Badge({ style, color, children }) {
4
+ if (!children)
5
+ return _jsx(_Fragment, {});
4
6
  return (_jsx("span", { className: cn(styles({ color }), style), children: children }));
5
7
  }
6
8
  const styles = tv({
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
 
3
3
  "name": "@bouko/react",
4
- "version": "1.9.8",
4
+ "version": "2.0.0",
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.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",