Skip to content

Commit

Permalink
Merge pull request #1 from justinsilvestre/curator
Browse files Browse the repository at this point in the history
Curator
  • Loading branch information
justinsilvestre authored Mar 7, 2024
2 parents 7330c6b + 2853966 commit f35810f
Show file tree
Hide file tree
Showing 31 changed files with 3,220 additions and 191 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ node_modules
/postgres-data

*.log
*.log.json

.DS_Store
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll": true
"source.fixAll": "explicit"
},
"eslint.validate": ["javascript"]
}
18 changes: 16 additions & 2 deletions app/components/AppLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,26 @@ import { useEffect, type ReactNode, useRef } from "react";
type LinkProps<T = object> = T & {
children: ReactNode;
className?: string;
newWindow?: boolean;
};

function AppLink({
to,
children,
className = "underline hover:text-orange-600",
linkRef,
newWindow,
}: LinkProps<{
to: string;
linkRef?: React.Ref<HTMLAnchorElement>;
}>) {
return (
<Link to={to} className={className} ref={linkRef}>
<Link
to={to}
className={className}
ref={linkRef}
{...(newWindow ? { target: "_blank", rel: "noopener noreferrer" } : {})}
>
{children}
</Link>
);
Expand All @@ -27,11 +34,13 @@ export function DictLink({
figureId,
focusOnLoad,
className,
newWindow,
}: {
children?: ReactNode;
className?: string;
} & Omit<
LinkProps<{
newWindow?: boolean;
figureId: string;
focusOnLoad?: boolean;
}>,
Expand All @@ -44,7 +53,12 @@ export function DictLink({
}
}, [figureId, focusOnLoad]);
return (
<AppLink to={`/dict/${figureId}`} linkRef={linkRef} className={className}>
<AppLink
to={`/dict/${figureId}`}
linkRef={linkRef}
className={className}
newWindow={newWindow}
>
{children || figureId}
</AppLink>
);
Expand Down
21 changes: 21 additions & 0 deletions app/components/FigureBadgeLink.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { DictLink } from "~/components/AppLink";
import { FigureBadge } from "~/components/FigureBadge";
import { BadgeProps } from "~/features/dictionary/badgeFigure";

export function FigureBadgeLink({
id: figureId,
badgeProps,
width,
newWindow,
}: {
id: string;
badgeProps: BadgeProps;
width?: number;
newWindow?: boolean;
}) {
return (
<DictLink figureId={figureId} newWindow={newWindow}>
<FigureBadge badgeProps={badgeProps} width={width} />
</DictLink>
);
}
Loading

0 comments on commit f35810f

Please sign in to comment.