Skip to content

Commit d0323e7

Browse files
committed
重构:将Installation组件模块化,拆分样式和功能代码
1 parent 35d31d8 commit d0323e7

File tree

5 files changed

+261
-224
lines changed

5 files changed

+261
-224
lines changed

office-website/src/components/Installation.tsx

Lines changed: 0 additions & 224 deletions
This file was deleted.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import React from 'react';
2+
import {
3+
StepItem,
4+
StepNumber,
5+
StepTitle,
6+
StepDescription,
7+
CodeBlock
8+
} from '../../styles/components/Installation.styles';
9+
import CustomCodeBlock from '../CustomCodeBlock';
10+
11+
interface InstallationStepProps {
12+
number: number;
13+
title: string;
14+
description: string;
15+
code: string;
16+
language: string;
17+
}
18+
19+
const InstallationStep: React.FC<InstallationStepProps> = ({
20+
number,
21+
title,
22+
description,
23+
code,
24+
language
25+
}) => {
26+
return (
27+
<StepItem>
28+
<StepNumber>{number}</StepNumber>
29+
<StepTitle>{title}</StepTitle>
30+
<StepDescription>{description}</StepDescription>
31+
<CodeBlock>
32+
<CustomCodeBlock
33+
code={code}
34+
language={language}
35+
/>
36+
</CodeBlock>
37+
</StepItem>
38+
);
39+
};
40+
41+
export default InstallationStep;
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import React from 'react';
2+
import {
3+
SectionContainer,
4+
SectionInner,
5+
SectionHeading,
6+
Title,
7+
Subtitle,
8+
InstallationContent,
9+
StepsList
10+
} from '../../styles/components/Installation.styles';
11+
import InstallationStep from './InstallationStep';
12+
import { leftColumnSteps, rightColumnSteps } from './stepsData';
13+
14+
const Installation: React.FC = () => {
15+
return (
16+
<SectionContainer id="installation">
17+
<SectionInner>
18+
<SectionHeading>
19+
<Title>安装指南</Title>
20+
<Subtitle>
21+
通过几个简单的步骤,开始使用Typescript Userscript Template开发你的用户脚本
22+
</Subtitle>
23+
</SectionHeading>
24+
25+
<InstallationContent>
26+
<StepsList>
27+
{leftColumnSteps.map((step, index) => (
28+
<InstallationStep
29+
key={`left-step-${index + 1}`}
30+
number={index + 1}
31+
title={step.title}
32+
description={step.description}
33+
code={step.code}
34+
language={step.language}
35+
/>
36+
))}
37+
</StepsList>
38+
39+
<StepsList>
40+
{rightColumnSteps.map((step, index) => (
41+
<InstallationStep
42+
key={`right-step-${index + 4}`}
43+
number={index + 4}
44+
title={step.title}
45+
description={step.description}
46+
code={step.code}
47+
language={step.language}
48+
/>
49+
))}
50+
</StepsList>
51+
</InstallationContent>
52+
</SectionInner>
53+
</SectionContainer>
54+
);
55+
};
56+
57+
export default Installation;

0 commit comments

Comments
 (0)