Skip to content

Commit ade45f7

Browse files
committed
feat: create link component
1 parent 8fd3ef3 commit ade45f7

File tree

4 files changed

+76
-15
lines changed

4 files changed

+76
-15
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import type { Meta, StoryObj } from "@storybook/react";
2+
// import { userEvent, within } from "@storybook/test";
3+
import { Link } from "./Link";
4+
5+
const meta: Meta<typeof Link> = {
6+
title: "components/Link",
7+
component: Link,
8+
args: {
9+
text: "Learn more",
10+
},
11+
};
12+
13+
export default meta;
14+
type Story = StoryObj<typeof Link>;
15+
16+
export const Default: Story = {};
17+
18+
export const Small: Story = {
19+
args: {
20+
size: "sm",
21+
},
22+
};
23+
24+
// export const Hover: Story = {
25+
// play: async ({ canvasElement, step }) => {
26+
// const screen = within(canvasElement);
27+
28+
// await step("activate hover trigger", async () => {
29+
// await userEvent.hover(screen.getByRole("link", { name: /Learn more/i }));
30+
// });
31+
// },
32+
// };
33+

site/src/components/Link/Link.tsx

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { type VariantProps, cva } from "class-variance-authority";
2+
import { SquareArrowOutUpRight } from "lucide-react";
3+
import { forwardRef } from "react";
4+
import { cn } from "utils/cn";
5+
6+
export const linkVariants = cva(
7+
`relative inline-flex items-center no-underline font-medium text-content-link
8+
after:hover:content-[''] after:hover:absolute after:hover:w-full after:hover:h-[1px] after:hover:bg-current after:hover:bottom-px
9+
focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-content-link
10+
focus-visible:ring-offset-2 focus-visible:ring-offset-surface-primary focus-visible:rounded-sm
11+
visited:text-content-link`,
12+
{
13+
variants: {
14+
size: {
15+
lg: "text-sm mb-px",
16+
sm: "text-xs [&_svg]:size-icon-xs [&_svg]:p-px",
17+
},
18+
},
19+
defaultVariants: {
20+
size: "lg",
21+
},
22+
},
23+
);
24+
25+
export interface LinkProps
26+
extends React.AnchorHTMLAttributes<HTMLAnchorElement>,
27+
VariantProps<typeof linkVariants> {
28+
text: string;
29+
}
30+
31+
export const Link = forwardRef<HTMLAnchorElement, LinkProps>(
32+
({ className, text, size, ...props }, ref) => {
33+
return (
34+
<a className={cn(linkVariants({ size }), className)} ref={ref} {...props}>
35+
{text}&nbsp;
36+
<SquareArrowOutUpRight size={14} aria-hidden="true" />
37+
</a>
38+
);
39+
},
40+
);

site/src/pages/ManagementSettingsPage/IdpSyncPage/IdpSyncPage.tsx

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import { ChooseOne, Cond } from "components/Conditionals/ChooseOne";
1111
import { EmptyState } from "components/EmptyState/EmptyState";
1212
import { displayError } from "components/GlobalSnackbar/utils";
1313
import { displaySuccess } from "components/GlobalSnackbar/utils";
14+
import { Link } from "components/Link/Link";
1415
import { Paywall } from "components/Paywall/Paywall";
15-
import { SquareArrowOutUpRight } from "lucide-react";
1616
import { useFeatureVisibility } from "modules/dashboard/useFeatureVisibility";
1717
import { useOrganizationSettings } from "modules/management/OrganizationSettingsLayout";
1818
import { type FC, useEffect } from "react";
@@ -107,16 +107,9 @@ export const IdpSyncPage: FC = () => {
107107
<p className="flex flex-row gap-1 text-sm text-content-secondary font-medium m-0">
108108
Automatically assign groups or roles to a user based on their IdP
109109
claims.
110-
<a
111-
href={docs("/admin/users/idp-sync")}
112-
className="flex flex-row text-content-link items-center gap-1 no-underline hover:underline visited:text-content-link"
113-
>
114-
View docs
115-
<SquareArrowOutUpRight size={14} />
116-
</a>
110+
<Link text="View docs" href={docs("/admin/users/idp-sync")} />
117111
</p>
118112
</div>
119-
{/* <ExportPolicyButton syncSettings={orgSyncSettingsData} /> */}
120113
</header>
121114
<ChooseOne>
122115
<Cond condition={!isIdpSyncEnabled}>

site/src/pages/ManagementSettingsPage/IdpSyncPage/IdpSyncPageView.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -697,12 +697,7 @@ const TableLoader = () => {
697697

698698
const LegacyGroupSyncHeader: FC = () => {
699699
return (
700-
<h4
701-
css={{
702-
fontSize: 20,
703-
fontWeight: 500,
704-
}}
705-
>
700+
<h4 className="text-xl font-medium">
706701
<div className="flex items-end gap-2">
707702
<span>Legacy group sync settings</span>
708703
<HelpTooltip>

0 commit comments

Comments
 (0)