Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nojira | @rebeccahongsf | fixup action-link className #6

Merged
merged 2 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/components/elements/action-link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ type Props = HtmlHTMLAttributes<HTMLAnchorElement> & {
href: string
};

const ActionLink = ({ children, ...props }: Props) => {
const ActionLink = ({ children, className, ...props }: Props) => {
return (
<Link {...props} className={twMerge("relative", props.className)}>
<Link {...props} className={twMerge("relative", className?.replace("link--action", ""))}>
{children}
<ArrowRightIcon width={20} className="ml-2 inline-block" />
</Link>
Expand Down
2 changes: 1 addition & 1 deletion src/components/elements/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export const Button = ({
return (
<Link
href={href}
className={twMerge(standardClasses, className)}
className={twMerge(standardClasses, className?.replace("button", ""))}
{...props}
>
{children}
Expand Down
12 changes: 6 additions & 6 deletions src/components/elements/link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type Props = HtmlHTMLAttributes<HTMLAnchorElement | HTMLButtonElement> & LinkPro
href: string
}

const DrupalLink = ({href, className, children, ...props}: Props) => {
const DrupalLink = ({href, children, ...props}: Props) => {
// Make sure all links have a href.
href = href || "#"
const drupalBase: string = (process.env.NEXT_PUBLIC_DRUPAL_BASE_URL || "").replace(/\/$/, "");
Expand All @@ -21,20 +21,20 @@ const DrupalLink = ({href, className, children, ...props}: Props) => {
href = href.replace(drupalBase, "").replace("<front>", "/");
}

if (className?.includes("link--action")) {
if (props.className?.includes("link--action")) {
return (
<ActionLink href={href} {...props}>
{children}
</ActionLink>
)
}

if (className?.includes("button")) {
if (props.className?.includes("button")) {
return (
<Button
href={href}
big={className.includes("--big")}
secondary={className.includes("--secondary")}
big={props.className.includes("--big")}
secondary={props.className.includes("--secondary")}
{...props}
>
{children}
Expand All @@ -43,7 +43,7 @@ const DrupalLink = ({href, className, children, ...props}: Props) => {
}

return (
<Link href={href} className={className} {...props}>
<Link href={href} className={props.className} {...props}>
{children}
{href.startsWith("mailto") &&
<EnvelopeIcon width={20} className="ml-4 inline-block"/>
Expand Down