@bouko/react 2.1.2 → 2.1.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,12 +1,11 @@
1
- import { Component } from "../../core/types";
1
+ import type { Component } from "../../core/types";
2
2
  type Props = Component & {
3
- variant?: "accent" | "background";
4
3
  color?: string;
5
4
  };
6
- export declare const Badge: ({ style, variant, color, children }: Props) => import("react/jsx-runtime").JSX.Element | undefined;
5
+ export declare const Badge: ({ style, color, children }: Props) => import("react/jsx-runtime").JSX.Element | undefined;
7
6
  export default Badge;
8
7
  /**
9
8
  * Problems:
10
9
  *
11
- * - Ugly code
10
+ * - Perfect `opacitize`
12
11
  **/
@@ -1,24 +1,17 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { cn, tv } from "@bouko/style";
3
- export const Badge = ({ style, variant, color, children }) => {
2
+ import { cn, css, opacitize } from "@bouko/style";
3
+ export const Badge = ({ style, color = "var(--color-accent)", children }) => {
4
4
  if (children)
5
- return (_jsx("span", { className: cn(styles({ variant }), style), style: overrideStyle(color), children: children }));
5
+ return (_jsx("span", { className: cn(styles(color), style), children: children }));
6
6
  };
7
- const overrideStyle = (color) => {
8
- if (color)
9
- return {
10
- background: color + "50",
11
- borderColor: color
12
- };
13
- };
14
- const styles = tv({
15
- base: "w-min px-3 py-1 border rounded-full text-xs font-semibold text-primary",
16
- defaultVariants: { variant: "accent" },
17
- variants: {
18
- variant: {
19
- accent: "bg-accent-light/50 border-accent-light",
20
- background: "bg-background-lighter/50 border-background-lighter"
21
- }
22
- }
7
+ const styles = (color) => css({
8
+ width: "min-content",
9
+ padding: "0.25rem 0.75rem",
10
+ background: opacitize(color),
11
+ border: `1px solid ${color}`,
12
+ borderRadius: "100%",
13
+ fontSize: "0.75rem",
14
+ fontWeight: "600",
15
+ color: "var(--color-primary)"
23
16
  });
24
17
  export default Badge;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
 
3
3
  "name": "@bouko/react",
4
- "version": "2.1.2",
4
+ "version": "2.1.3",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "license": "MIT",