@stevederico/skateboard-ui 3.7.0 → 3.7.1
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.
- package/CHANGELOG.md +4 -0
- package/package.json +1 -1
- package/shadcn/ui/button.jsx +21 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
+
3.7.1
|
|
4
|
+
|
|
5
|
+
Fix: `Button` now bridges shadcn-style `asChild` onto Base UI's `render` prop instead of leaking it onto the DOM `<button>` — removes the "React does not recognize the `asChild` prop" warning for `<Button asChild><a/></Button>` (e.g. LandingSpecSheet "Learn more")
|
|
6
|
+
|
|
3
7
|
3.7.0
|
|
4
8
|
|
|
5
9
|
Breaking (peer dep rename): `react-router-dom` → `react-router`
|
package/package.json
CHANGED
package/shadcn/ui/button.jsx
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Children } from "react";
|
|
1
2
|
import { Button as ButtonPrimitive } from "../lib/base-ui/button.js"
|
|
2
3
|
import { cva } from "../lib/cva.js";
|
|
3
4
|
|
|
@@ -42,19 +43,37 @@ const buttonVariants = cva(
|
|
|
42
43
|
* @param {string} [props.className] - Additional CSS classes
|
|
43
44
|
* @param {"default"|"outline"|"secondary"|"ghost"|"destructive"|"link"|"gradient"} [props.variant="default"] - Visual style
|
|
44
45
|
* @param {"default"|"xs"|"sm"|"lg"|"icon"|"icon-xs"|"icon-sm"|"icon-lg"|"cta"} [props.size="default"] - Button size
|
|
46
|
+
* @param {boolean} [props.asChild=false] - Render the single child element styled as a button (shadcn-style). Bridged onto Base UI's `render` prop.
|
|
45
47
|
* @returns {JSX.Element}
|
|
46
48
|
*/
|
|
47
49
|
function Button({
|
|
48
50
|
className,
|
|
49
51
|
variant = "default",
|
|
50
52
|
size = "default",
|
|
53
|
+
asChild = false,
|
|
54
|
+
children,
|
|
51
55
|
...props
|
|
52
56
|
}) {
|
|
57
|
+
const classes = cn(buttonVariants({ variant, size, className }));
|
|
58
|
+
// Base UI has no `asChild` — it uses a `render` prop. Bridge the shadcn-style
|
|
59
|
+
// `asChild` API so `<Button asChild><a .../></Button>` renders the child element
|
|
60
|
+
// (merged with button props) instead of leaking `asChild` onto the DOM <button>.
|
|
61
|
+
if (asChild) {
|
|
62
|
+
return (
|
|
63
|
+
<ButtonPrimitive
|
|
64
|
+
data-slot="button"
|
|
65
|
+
className={classes}
|
|
66
|
+
render={Children.only(children)}
|
|
67
|
+
{...props} />
|
|
68
|
+
);
|
|
69
|
+
}
|
|
53
70
|
return (
|
|
54
71
|
<ButtonPrimitive
|
|
55
72
|
data-slot="button"
|
|
56
|
-
className={
|
|
57
|
-
{...props}
|
|
73
|
+
className={classes}
|
|
74
|
+
{...props}>
|
|
75
|
+
{children}
|
|
76
|
+
</ButtonPrimitive>
|
|
58
77
|
);
|
|
59
78
|
}
|
|
60
79
|
|