Skip to content

Commit e2e9dd1

Browse files
committed
refactor(templates): split resources detail parts
Extract canonical link and related list components, and let blog post template wrap content while updating stories and usage.
1 parent 6520e6f commit e2e9dd1

16 files changed

Lines changed: 168 additions & 41 deletions
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import type { Meta, StoryObj } from "@storybook/react";
2+
3+
import { ResourceCanonicalLink } from "./ResourceCanonicalLink";
4+
5+
const meta = {
6+
title: "Molecules/ResourceCanonicalLink",
7+
component: ResourceCanonicalLink,
8+
args: {
9+
canonicalLabel: "Canonical source:",
10+
canonicalUrl: "https://example.com/resources/interview-guide",
11+
},
12+
parameters: {
13+
docs: {
14+
description: {
15+
component:
16+
"Small link block that points to the canonical source for a resource.",
17+
},
18+
},
19+
},
20+
} satisfies Meta<typeof ResourceCanonicalLink>;
21+
22+
export default meta;
23+
24+
type Story = StoryObj<typeof meta>;
25+
26+
export const Default: Story = {};
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import type { ResourceCanonicalLinkProps } from "./ResourceCanonicalLink.types";
2+
3+
export const ResourceCanonicalLink = ({
4+
canonicalUrl,
5+
canonicalLabel,
6+
}: ResourceCanonicalLinkProps) => (
7+
<p className="text-sm text-secondary-600">
8+
{canonicalLabel}{" "}
9+
<a
10+
className="text-primary-700 hover:text-primary-800"
11+
href={canonicalUrl}
12+
rel="noopener noreferrer"
13+
>
14+
{canonicalUrl}
15+
</a>
16+
</p>
17+
);
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export interface ResourceCanonicalLinkProps {
2+
canonicalUrl: string;
3+
canonicalLabel: string;
4+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { ResourceCanonicalLink } from "./ResourceCanonicalLink";
2+
export type { ResourceCanonicalLinkProps } from "./ResourceCanonicalLink.types";

src/components/molecules/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ export { Card } from "./Card";
22
export { FeatureGrid } from "./FeatureGrid";
33
export { HeroActions } from "./HeroActions";
44
export { MetaGroup } from "./MetaGroup";
5+
export { ResourceCanonicalLink } from "./ResourceCanonicalLink";
56
export { TagList } from "./TagList";
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import type { Meta, StoryObj } from "@storybook/react";
2+
3+
import { ResourcesRelatedList } from "./ResourcesRelatedList";
4+
5+
const meta = {
6+
title: "Organisms/ResourcesRelatedList",
7+
component: ResourcesRelatedList,
8+
args: {
9+
title: "Related resources",
10+
resources: [
11+
{ title: "Synthesis workshop checklist", href: "/resources/synthesis/" },
12+
{
13+
title: "Participant recruitment guide",
14+
href: "/resources/recruitment/",
15+
},
16+
],
17+
},
18+
parameters: {
19+
docs: {
20+
description: {
21+
component:
22+
"Related resources list with heading and linked items for resource detail pages.",
23+
},
24+
},
25+
},
26+
} satisfies Meta<typeof ResourcesRelatedList>;
27+
28+
export default meta;
29+
30+
type Story = StoryObj<typeof meta>;
31+
32+
export const Default: Story = {};
33+
34+
export const SingleItem: Story = {
35+
args: {
36+
resources: [
37+
{ title: "Remote research facilitation", href: "/resources/remote/" },
38+
],
39+
},
40+
};
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import type { ResourcesRelatedListProps } from "./ResourcesRelatedList.types";
2+
3+
export const ResourcesRelatedList = ({
4+
title,
5+
resources,
6+
}: ResourcesRelatedListProps) => (
7+
<section>
8+
<h2 className="text-xl font-semibold text-secondary-900">{title}</h2>
9+
<ul className="mt-3 space-y-2 text-secondary-700">
10+
{resources.map((resource) => (
11+
<li key={resource.href}>
12+
<a className="hover:text-primary-700" href={resource.href}>
13+
{resource.title}
14+
</a>
15+
</li>
16+
))}
17+
</ul>
18+
</section>
19+
);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export interface ResourcesRelatedListItem {
2+
title: string;
3+
href: string;
4+
}
5+
6+
export interface ResourcesRelatedListProps {
7+
title: string;
8+
resources: readonly ResourcesRelatedListItem[];
9+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export { ResourcesRelatedList } from "./ResourcesRelatedList";
2+
export type {
3+
ResourcesRelatedListItem,
4+
ResourcesRelatedListProps,
5+
} from "./ResourcesRelatedList.types";

src/components/organisms/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ export { HomeHero } from "./HomeHero";
77
export { Navbar } from "./Navbar";
88
export { Footer } from "./Footer";
99
export { PageIntro } from "./PageIntro";
10+
export { ResourcesRelatedList } from "./ResourcesRelatedList";

0 commit comments

Comments
 (0)