这是indexloc提供的服务,不要输入任何密码
Skip to content

[refactor] - made Features components more reusable #1782

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

Merged
merged 5 commits into from
Aug 31, 2022
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
70 changes: 38 additions & 32 deletions docs/components/Features.tsx
Original file line number Diff line number Diff line change
@@ -1,37 +1,43 @@
import Feature from "./Feature";
import React from "react";
import { DOCS_FEATURES, HOME_FEATURES } from "../content/features";
import type { Feature as FeatureType } from "../content/features";
import Feature from "./Feature";

export function HomeFeatures() {
return (
<DetailedFeaturesGrid>
{HOME_FEATURES.map((feature) => (
<Feature
key={feature.name.split(" ").join("-")}
feature={feature}
detailed
/>
))}
</DetailedFeaturesGrid>
);
}

export function DocsFeatures({ detailed = true }: { detailed?: boolean }) {
return (
<div className="grid grid-cols-2 gap-6 my-12 sm:grid-cols-3 ">
{DOCS_FEATURES.map((feature) => (
<Feature
key={feature.name.split(" ").join("-")}
feature={feature}
detailed={detailed}
/>
))}
</div>
);
}

export default function Features({
page = "home",
detailed = true,
export function DetailedFeaturesGrid({
children,
}: {
page?: FeatureType["page"];
detailed?: boolean;
children?: React.ReactNode;
}) {
if (page === "docs") {
return (
<div className="grid grid-cols-2 gap-6 my-12 sm:grid-cols-3 ">
{DOCS_FEATURES.map((feature) => (
<Feature
key={feature.name.split(" ").join("-")}
feature={feature}
detailed={detailed}
/>
))}
</div>
);
} else {
return (
<div className="grid grid-cols-1 mt-12 gap-x-6 gap-y-12 sm:grid-cols-2 lg:mt-16 lg:grid-cols-3 lg:gap-x-8 lg:gap-y-12">
{HOME_FEATURES.map((feature) => (
<Feature
key={feature.name.split(" ").join("-")}
feature={feature}
detailed
/>
))}
</div>
);
}
return (
<div className="grid grid-cols-1 mt-12 gap-x-6 gap-y-12 sm:grid-cols-2 lg:mt-16 lg:grid-cols-3 lg:gap-x-8 lg:gap-y-12">
{children}
</div>
);
}
4 changes: 2 additions & 2 deletions docs/components/pages/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import paularmstrong from "../../images/paularmstrong.jpeg";

import { Container } from "../Container";
import Tweet, { Mention } from "../Tweet";
import Features from "../Features";
import { HomeFeatures } from "../Features";
import { Marquee } from "../clients/Marquee";
import { Clients } from "../clients/Clients";

Expand Down Expand Up @@ -90,7 +90,7 @@ export default function Home() {
Turborepo reimagines build system techniques used by Facebook and
Google to remove maintenance burden and overhead.
</p>
<Features />
<HomeFeatures />
</div>
</div>
<div className="">
Expand Down
4 changes: 2 additions & 2 deletions docs/pages/docs/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ title: Documentation
description: Turborepo is a high-performance build system for JavaScript and TypeScript codebases.
---

import Features from "../../components/Features";
import { DocsFeatures } from "../../components/Features";

# Turborepo Documentation

<Features page="docs" detailed={false} />
<DocsFeatures detailed={false} />

Turborepo is a blazing fast build system for JavaScript/TypeScript _monorepos_: codebases containing multiple
projects, often using multiple frameworks, in a single, unified
Expand Down