@syscore/ui-library 2.0.0-beta-publish-workflow-beta.26 → 2.0.0-beta-publish-workflow-beta.27
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,75 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { cn } from "@/lib/utils";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* LinkButton — the published `Button`'s look on a real link element.
|
|
6
|
+
*
|
|
7
|
+
* `Button` has no `asChild`/Slot support in this DS, so it cannot render as an
|
|
8
|
+
* anchor or a router `Link` without losing real link semantics (right-click,
|
|
9
|
+
* ctrl/cmd-click, screen-reader "link" role). This applies the exact same
|
|
10
|
+
* `.button*` classes `Button`'s own cva map emits, so it stays pixel-identical.
|
|
11
|
+
* Renders as `<a>` by default — pass `as={Link}` (react-router) for in-app nav.
|
|
12
|
+
*
|
|
13
|
+
* Only the variants/sizes this app currently needs are mapped. Extend this
|
|
14
|
+
* alongside Button's own cva map in
|
|
15
|
+
* IWBI-DESIGN-SYSTEM/client/components/ui/button.tsx if a third is needed,
|
|
16
|
+
* so the two never drift apart.
|
|
17
|
+
*/
|
|
18
|
+
const LINK_BUTTON_VARIANT_CLASSES = {
|
|
19
|
+
"primary-gradient": "button--primary-gradient",
|
|
20
|
+
"general-secondary": "button--general-secondary",
|
|
21
|
+
} as const;
|
|
22
|
+
|
|
23
|
+
const LINK_BUTTON_SIZE_CLASSES = {
|
|
24
|
+
large: "button--large",
|
|
25
|
+
utility: "button--utility",
|
|
26
|
+
} as const;
|
|
27
|
+
|
|
28
|
+
const LINK_BUTTON_TEXT_CLASSES = {
|
|
29
|
+
large: "body-base",
|
|
30
|
+
utility: "body-small",
|
|
31
|
+
} as const;
|
|
32
|
+
|
|
33
|
+
type LinkButtonVariant = keyof typeof LINK_BUTTON_VARIANT_CLASSES;
|
|
34
|
+
type LinkButtonSize = keyof typeof LINK_BUTTON_SIZE_CLASSES;
|
|
35
|
+
|
|
36
|
+
export interface LinkButtonProps extends React.HTMLAttributes<HTMLElement> {
|
|
37
|
+
as?: React.ElementType;
|
|
38
|
+
variant?: LinkButtonVariant;
|
|
39
|
+
size?: LinkButtonSize;
|
|
40
|
+
href?: string;
|
|
41
|
+
to?: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const LinkButton = React.forwardRef<HTMLElement, LinkButtonProps>(
|
|
45
|
+
(
|
|
46
|
+
{
|
|
47
|
+
as: Component = "a",
|
|
48
|
+
variant = "primary-gradient",
|
|
49
|
+
size = "large",
|
|
50
|
+
className,
|
|
51
|
+
children,
|
|
52
|
+
...props
|
|
53
|
+
},
|
|
54
|
+
ref,
|
|
55
|
+
) => (
|
|
56
|
+
<Component
|
|
57
|
+
ref={ref}
|
|
58
|
+
className={cn(
|
|
59
|
+
"button",
|
|
60
|
+
LINK_BUTTON_VARIANT_CLASSES[variant],
|
|
61
|
+
LINK_BUTTON_SIZE_CLASSES[size],
|
|
62
|
+
className,
|
|
63
|
+
)}
|
|
64
|
+
{...props}
|
|
65
|
+
>
|
|
66
|
+
<span className="button-text">
|
|
67
|
+
<span className={LINK_BUTTON_TEXT_CLASSES[size]}>{children}</span>
|
|
68
|
+
</span>
|
|
69
|
+
</Component>
|
|
70
|
+
),
|
|
71
|
+
);
|
|
72
|
+
LinkButton.displayName = "LinkButton";
|
|
73
|
+
|
|
74
|
+
export { LinkButton };
|
|
75
|
+
export type { LinkButtonVariant, LinkButtonSize };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { cn } from "../../lib/utils.js";
|
|
4
|
+
const LINK_BUTTON_VARIANT_CLASSES = {
|
|
5
|
+
"primary-gradient": "button--primary-gradient",
|
|
6
|
+
"general-secondary": "button--general-secondary"
|
|
7
|
+
};
|
|
8
|
+
const LINK_BUTTON_SIZE_CLASSES = {
|
|
9
|
+
large: "button--large",
|
|
10
|
+
utility: "button--utility"
|
|
11
|
+
};
|
|
12
|
+
const LINK_BUTTON_TEXT_CLASSES = {
|
|
13
|
+
large: "body-base",
|
|
14
|
+
utility: "body-small"
|
|
15
|
+
};
|
|
16
|
+
const LinkButton = React.forwardRef(
|
|
17
|
+
({
|
|
18
|
+
as: Component = "a",
|
|
19
|
+
variant = "primary-gradient",
|
|
20
|
+
size = "large",
|
|
21
|
+
className,
|
|
22
|
+
children,
|
|
23
|
+
...props
|
|
24
|
+
}, ref) => /* @__PURE__ */ jsx(
|
|
25
|
+
Component,
|
|
26
|
+
{
|
|
27
|
+
ref,
|
|
28
|
+
className: cn(
|
|
29
|
+
"button",
|
|
30
|
+
LINK_BUTTON_VARIANT_CLASSES[variant],
|
|
31
|
+
LINK_BUTTON_SIZE_CLASSES[size],
|
|
32
|
+
className
|
|
33
|
+
),
|
|
34
|
+
...props,
|
|
35
|
+
children: /* @__PURE__ */ jsx("span", { className: "button-text", children: /* @__PURE__ */ jsx("span", { className: LINK_BUTTON_TEXT_CLASSES[size], children }) })
|
|
36
|
+
}
|
|
37
|
+
)
|
|
38
|
+
);
|
|
39
|
+
LinkButton.displayName = "LinkButton";
|
|
40
|
+
export {
|
|
41
|
+
LinkButton
|
|
42
|
+
};
|