@theguild/components 9.5.0 → 9.6.0-alpha-20250401154052-c98b68bae167b2530013b0a1e4b07f08ad386efd
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,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { HTMLAttributes } from 'react';
|
|
2
3
|
import { Anchor } from './anchor.mjs';
|
|
3
|
-
import 'react';
|
|
4
4
|
import 'url';
|
|
5
5
|
import '../types/components.mjs';
|
|
6
6
|
import 'next/image';
|
|
@@ -21,16 +21,27 @@ declare namespace CallToActionProps {
|
|
|
21
21
|
}
|
|
22
22
|
interface AnchorProps extends BaseProps, React.ComponentPropsWithoutRef<typeof Anchor> {
|
|
23
23
|
href: string;
|
|
24
|
+
as?: never;
|
|
24
25
|
}
|
|
25
26
|
interface ButtonProps extends BaseProps, React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement> {
|
|
26
27
|
href?: never;
|
|
27
|
-
|
|
28
|
+
as?: never;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Use inside `<summary>` or as visual part of bigger interactive element.
|
|
32
|
+
* Prefer using `href` prop using CallToAction as `<button>` in other cases.
|
|
33
|
+
*/
|
|
34
|
+
interface NonInteractiveProps extends BaseProps, React.DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement> {
|
|
35
|
+
href?: never;
|
|
36
|
+
as: 'span' | 'div';
|
|
28
37
|
}
|
|
29
38
|
}
|
|
30
|
-
type CallToActionProps = CallToActionProps.AnchorProps | CallToActionProps.ButtonProps;
|
|
39
|
+
type CallToActionProps = CallToActionProps.AnchorProps | CallToActionProps.ButtonProps | CallToActionProps.NonInteractiveProps;
|
|
31
40
|
/**
|
|
32
41
|
* This is called `Button` in Figma in the new Hive brand design system.
|
|
33
|
-
* It's a styled variant of {@link Anchor}.
|
|
42
|
+
* It's a styled variant of {@link Anchor}. Based on the presence of the
|
|
43
|
+
* `href` prop or `as` prop, it renders a `button`, `a` or `props.as`
|
|
44
|
+
* (for non-interactive elements) element.
|
|
34
45
|
*
|
|
35
46
|
* // TODO: Consider renaming it to `Button`.
|
|
36
47
|
*/
|
|
@@ -24,16 +24,25 @@ function CallToAction(props) {
|
|
|
24
24
|
variantStyles[props.variant],
|
|
25
25
|
props.className
|
|
26
26
|
);
|
|
27
|
+
const growingBorderBox = /* @__PURE__ */ jsx("span", { className: "absolute inset-0 rounded-lg border border-green-800 dark:border-neutral-200" });
|
|
27
28
|
if ("href" in props && typeof props.href === "string") {
|
|
28
29
|
const { className: _12, variant: _22, children: children2, ...rest2 } = props;
|
|
29
30
|
return /* @__PURE__ */ jsxs(Anchor, { className, ...rest2, children: [
|
|
30
|
-
|
|
31
|
+
growingBorderBox,
|
|
32
|
+
children2
|
|
33
|
+
] });
|
|
34
|
+
}
|
|
35
|
+
if (props.as) {
|
|
36
|
+
const { className: _12, variant: _22, children: children2, as, ...rest2 } = props;
|
|
37
|
+
const Root = as;
|
|
38
|
+
return /* @__PURE__ */ jsxs(Root, { className, ...rest2, children: [
|
|
39
|
+
growingBorderBox,
|
|
31
40
|
children2
|
|
32
41
|
] });
|
|
33
42
|
}
|
|
34
43
|
const { className: _1, variant: _2, children, ...rest } = props;
|
|
35
44
|
return /* @__PURE__ */ jsxs("button", { className, ...rest, children: [
|
|
36
|
-
|
|
45
|
+
growingBorderBox,
|
|
37
46
|
children
|
|
38
47
|
] });
|
|
39
48
|
}
|
package/package.json
CHANGED