@bouko/react 2.4.2 → 2.4.3

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 +1,25 @@
1
- export default function PageHeading(): import("react/jsx-runtime").JSX.Element;
1
+ import { ReactNode } from "react";
2
+ declare type Props = {
3
+ style?: Styles;
4
+ badge?: string;
5
+ icon?: ReactNode;
6
+ title: string;
7
+ subtitle?: string;
8
+ };
9
+ declare type Styles = {
10
+ container?: string;
11
+ badge?: string;
12
+ title?: string;
13
+ subtitle?: string;
14
+ };
15
+ /**
16
+ * Text heading with badge, title, subtitle.
17
+ *
18
+ * @param {Styles} style - Additional styles. (optional)
19
+ * @param {string} badge - Little note above the title. (optional)
20
+ * @param {ReactNode} icon - Component displayed left of title. (optional)
21
+ * @param {string} title - Main title content.
22
+ * @param {string} subtitle - Subtitle content. (optional)
23
+ **/
24
+ export default function PageHeading({ style, badge, icon, title, subtitle }: Props): import("react/jsx-runtime").JSX.Element;
25
+ export {};
@@ -1,5 +1,23 @@
1
- import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
2
- // bring from unvault
3
- export default function PageHeading() {
4
- return (_jsx(_Fragment, {}, void 0));
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { mergeStyles } from "@bouko/style";
3
+ import { RowBox, ColumnBox } from "../layout/flex";
4
+ import { Badge } from "../text/badge";
5
+ /**
6
+ * Text heading with badge, title, subtitle.
7
+ *
8
+ * @param {Styles} style - Additional styles. (optional)
9
+ * @param {string} badge - Little note above the title. (optional)
10
+ * @param {ReactNode} icon - Component displayed left of title. (optional)
11
+ * @param {string} title - Main title content.
12
+ * @param {string} subtitle - Subtitle content. (optional)
13
+ **/
14
+ export default function PageHeading({ style = {}, badge, icon, title, subtitle }) {
15
+ const styles = mergeStyles(base, style);
16
+ return (_jsxs(ColumnBox, { style: styles.container, children: [_jsx(Badge, { style: styles.badge, children: badge }, void 0), _jsxs(RowBox, { style: styles.title, children: [icon, title] }, void 0), _jsx(RowBox, { style: styles.subtitle, children: subtitle }, void 0)] }, void 0));
5
17
  }
18
+ const base = {
19
+ container: "w-full items-center font-mono",
20
+ badge: "mb-2",
21
+ title: "items-center gap-2 mb-3 text-4xl sm:text-5xl 2xl:text-6xl text-center font-bold text-primary",
22
+ subtitle: "items-center gap-2 text-sm sm:text-base 2xl:text-lg text-center text-primary-light dark:text-primary-dark"
23
+ };
@@ -2,10 +2,15 @@ import type { Component } from "../../core/types";
2
2
  declare type Props = Component & {
3
3
  color?: string;
4
4
  };
5
- export declare const Badge: ({ style, color, children }: Props) => import("react/jsx-runtime").JSX.Element | null;
6
- export default Badge;
7
5
  /**
8
- * Problems:
6
+ * Color-themed badge component.
7
+ *
8
+ * To use a CSS variable it must exist and be passed in the
9
+ * form `--variable-name`. Any other format may cause unexpected
10
+ * results. CSS variables use 'color-mix' which is not supported in
11
+ * some old browsers such as Safari 15.3 and Internet Explorer.
9
12
  *
10
- * - Perfect `opacitize`
11
- **/
13
+ * @param {string} color - Color of badge. (optional, default = accent)
14
+ **/
15
+ export declare function Badge({ style, color, children }: Props): import("react/jsx-runtime").JSX.Element | null;
16
+ export default Badge;
@@ -1,15 +1,25 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { cn, css, opacitize } from "@bouko/style";
3
- export const Badge = ({ style, color = "var(--color-accent)", children }) => {
3
+ /**
4
+ * Color-themed badge component.
5
+ *
6
+ * To use a CSS variable it must exist and be passed in the
7
+ * form `--variable-name`. Any other format may cause unexpected
8
+ * results. CSS variables use 'color-mix' which is not supported in
9
+ * some old browsers such as Safari 15.3 and Internet Explorer.
10
+ *
11
+ * @param {string} color - Color of badge. (optional, default = accent)
12
+ **/
13
+ export function Badge({ style, color = "--color-accent", children }) {
4
14
  if (!children)
5
15
  return null;
6
16
  return (_jsx("span", { className: cn(styles(color), style), children: children }, void 0));
7
- };
17
+ }
8
18
  const styles = (color) => css({
9
19
  width: "min-content",
10
20
  padding: "0.25rem 0.75rem",
11
21
  background: opacitize(color),
12
- border: `1px solid ${color}`,
22
+ border: `1px solid var(${color})`,
13
23
  borderRadius: "100%",
14
24
  fontSize: "0.75rem",
15
25
  fontWeight: "600",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
 
3
3
  "name": "@bouko/react",
4
- "version": "2.4.2",
4
+ "version": "2.4.3",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "license": "MIT",