@bouko/react 2.5.5 → 2.5.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.
@@ -0,0 +1,9 @@
1
+ import type { ReactNode } from "react";
2
+ import type { Clickable } from "../../core/types";
3
+ declare type Props = Clickable & {
4
+ color?: string;
5
+ icon: ReactNode;
6
+ disabled?: boolean;
7
+ };
8
+ export default function IconButton({ color, icon, action, disabled }: Props): import("react/jsx-runtime").JSX.Element;
9
+ export {};
@@ -0,0 +1,19 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { opacitize } from "@bouko/style";
3
+ export default function IconButton({ color = "--color-accent", icon, action, disabled = false }) {
4
+ return (_jsx("button", { className: "hover:brightness-115 disabled:cursor-not-allowed", style: styles(color), onClick: action, disabled: !action || disabled, children: icon }, void 0));
5
+ }
6
+ const styles = (color) => ({
7
+ display: "flex",
8
+ justifyContent: "center",
9
+ itemsCenter: "center",
10
+ padding: "0.5rem",
11
+ background: opacitize(color, 60),
12
+ border: `1px solid var(${color})`,
13
+ borderRadius: "100%",
14
+ fontSize: "0.75rem",
15
+ fontWeight: "600",
16
+ color: opacitize("--color-primary", 80),
17
+ transitionDuration: "200ms",
18
+ cursor: "pointer"
19
+ });
@@ -29,6 +29,7 @@ const styles = tv({
29
29
  },
30
30
  size: {
31
31
  xs: "px-3 py-1 text-xs",
32
+ circle: "px-2 py-2 text-xs rounded-full",
32
33
  sm: "px-3 py-2 text-xs sm:text-sm",
33
34
  md: "px-4 py-2",
34
35
  lg: "px-5 py-3 text-lg"
@@ -4,6 +4,7 @@ export { default as Heading } from "./heading/normal";
4
4
  export { default as PageHeading } from "./heading/page";
5
5
  export * from "./layout/flex";
6
6
  export { default as Button } from "./button/normal";
7
+ export { default as IconButton } from "./button/icon";
7
8
  export { default as Badge } from "./text/badge";
8
9
  export { default as Dropdown } from "./dropdown/normal";
9
10
  export { default as FileUploader } from "./upload/file";
@@ -4,6 +4,7 @@ export { default as Heading } from "./heading/normal";
4
4
  export { default as PageHeading } from "./heading/page";
5
5
  export * from "./layout/flex";
6
6
  export { default as Button } from "./button/normal";
7
+ export { default as IconButton } from "./button/icon";
7
8
  export { default as Badge } from "./text/badge";
8
9
  export { default as Dropdown } from "./dropdown/normal";
9
10
  export { default as FileUploader } from "./upload/file";
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { cn, css, opacitize } from "@bouko/style";
2
+ import { opacitize } from "@bouko/style";
3
3
  /**
4
4
  * Color-themed badge component.
5
5
  *
@@ -13,9 +13,9 @@ import { cn, css, opacitize } from "@bouko/style";
13
13
  export function Badge({ style, color = "--color-accent", children }) {
14
14
  if (!children)
15
15
  return null;
16
- return (_jsx("span", { className: cn(styles(color), style), children: children }, void 0));
16
+ return (_jsx("span", { className: style, style: styles(color), children: children }, void 0));
17
17
  }
18
- const styles = (color) => css({
18
+ const styles = (color) => ({
19
19
  width: "min-content",
20
20
  padding: "0.25rem 0.75rem",
21
21
  background: opacitize(color),
@@ -11,4 +11,5 @@ export declare type Component = {
11
11
  };
12
12
  export declare type Clickable = {
13
13
  action: () => void;
14
+ disabled?: boolean;
14
15
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
 
3
3
  "name": "@bouko/react",
4
- "version": "2.5.5",
4
+ "version": "2.5.6",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "license": "MIT",