Skip to content

Commit f6bcb3b

Browse files
committed
[optimize] update Data & UI of Case page
1 parent e6e51ce commit f6bcb3b

File tree

6 files changed

+56
-53
lines changed

6 files changed

+56
-53
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"web-utility": "^1.9.0"
3333
},
3434
"devDependencies": {
35-
"@babel/core": "^7.12.3",
35+
"@babel/core": "^7.12.7",
3636
"@types/classnames": "^2.2.11",
3737
"autoprefixer": "^9.8.6",
3838
"husky": "^4.3.0",

source/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { serviceWorkerUpdate } from 'web-utility';
22
import { documentReady, render, createCell } from 'web-cell';
33

4-
import { PageFrame } from './page/Router';
4+
import { PageFrame } from './page';
55

66
const { serviceWorker } = window.navigator;
77

source/page/Case.tsx

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,6 @@ import { Embed } from 'boot-cell/source/Media/Embed';
55
import style from './Case.module.less';
66
import { cases } from './data';
77

8-
const list = cases.reduce((list, item, index) => {
9-
if (index % 2 === 0) list.push([item]);
10-
else list.slice(-1)[0].push(item);
11-
12-
return list;
13-
}, [] as typeof cases[]);
14-
158
function Case({
169
name,
1710
description,
@@ -21,7 +14,7 @@ function Case({
2114
return (
2215
<section
2316
className={
24-
'flex-md-grow-1 mr-md-3 pt-3 px-3 pt-md-5 px-md-5 text-center position-relative ' +
17+
'col-12 col-md-6 my-3 my-md-0 pt-3 px-3 pt-md-5 px-md-5 text-center position-relative ' +
2518
(reverse ? 'bg-light' : 'bg-dark text-white')
2619
}
2720
>
@@ -51,20 +44,14 @@ export function CasePage() {
5144
<h2 className="display-4 text-center pt-5">用户案例</h2>
5245
<p className="lead text-center">User cases</p>
5346

54-
{list.map((row, index) => {
55-
const odd = index % 2;
47+
<div className="row w-100 m-0">
48+
{cases.map((item, index) => {
49+
const odd = index % 2;
50+
const order = Math.ceil((index + 1) / 2) % 2 ? !!odd : !odd;
5651

57-
return (
58-
<div className="d-md-flex w-100 my-md-3 pl-md-3">
59-
{row.map((item, index) => {
60-
const right = index % 2;
61-
const order = odd ? !!right : !right;
62-
63-
return <Case {...item} reverse={order} />;
64-
})}
65-
</div>
66-
);
67-
})}
52+
return <Case {...item} reverse={order} />;
53+
})}
54+
</div>
6855
</>
6956
);
7057
}

source/page/Main.tsx

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,32 @@ import { scaffold, feature } from './data';
1010
import style from './Main.module.less';
1111
import { WebCell_1 } from '../image';
1212

13+
function Feature({
14+
reverse,
15+
title,
16+
summary,
17+
link,
18+
logo
19+
}: typeof feature[0] & { reverse: boolean }) {
20+
return (
21+
<section
22+
className={classNames(
23+
'row',
24+
'align-items-end',
25+
reverse && 'flex-row-reverse'
26+
)}
27+
>
28+
<div className="col-md-10">
29+
<h2 className={style['featurette-heading']}>{title}</h2>
30+
<p className="lead">{summary}</p>
31+
</div>
32+
<a className="col-md-2" target="_blank" href={link}>
33+
<Image fluid className={style['featurette-logo']} src={logo} />
34+
</a>
35+
</section>
36+
);
37+
}
38+
1339
export function MainPage() {
1440
return (
1541
<>
@@ -59,29 +85,9 @@ export function MainPage() {
5985
<div className="container">
6086
<h2 className="text-center display-4 mb-5">核心特性</h2>
6187

62-
{feature.map(({ title, summary, link, logo }, index) => (
88+
{feature.map((item, index) => (
6389
<>
64-
<section
65-
className={classNames(
66-
'row',
67-
'align-items-end',
68-
index % 2 && 'flex-row-reverse'
69-
)}
70-
>
71-
<div className="col-md-10">
72-
<h2 className={style['featurette-heading']}>
73-
{title}
74-
</h2>
75-
<p className="lead">{summary}</p>
76-
</div>
77-
<a className="col-md-2" target="_blank" href={link}>
78-
<Image
79-
fluid
80-
className={style['featurette-logo']}
81-
src={logo}
82-
/>
83-
</a>
84-
</section>
90+
<Feature {...item} reverse={!(index % 2)} />
8591

8692
{index + 1 < feature.length ? (
8793
<hr

source/page/data.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { DropMenuItemProps } from 'boot-cell/source/Navigator/DropMenu';
2+
23
import { WebCell_0 } from '../image';
34

45
export const footer = [
@@ -278,6 +279,16 @@ export const cases = [
278279
description: 'JavaScript Chinese Interest Group',
279280
url: 'https://jscig.github.io/'
280281
},
282+
{
283+
name: '中国 Python 开发者大会',
284+
description: 'PyCon China',
285+
url: 'https://cn.pycon.org/'
286+
},
287+
{
288+
name: '中国开源年会',
289+
description: 'China Open Source Conference',
290+
url: 'http://coscon.kaiyuanshe.cn/'
291+
},
281292
{
282293
name: '成都 Web 开发者大会',
283294
description: 'Web developer conference of ChengDu',
@@ -288,11 +299,6 @@ export const cases = [
288299
description: 'COVID-19 Epidemic information platform',
289300
url: 'https://wuhan2020.kaiyuanshe.cn/'
290301
},
291-
{
292-
name: '中国开源年会',
293-
description: 'China Open Source Conference',
294-
url: 'http://coscon.kaiyuanshe.cn/'
295-
},
296302
{
297303
name: '开放黑客松平台',
298304
description: 'Open Hackathon platform',
@@ -301,11 +307,11 @@ export const cases = [
301307
{
302308
name: '23.5° 文化传播',
303309
description: '23.5° Culture Co., Ltd',
304-
url: 'https://in235.com/'
310+
url: 'https://www.in235.com/'
305311
},
306312
{
307313
name: 'Shopify 采集平台',
308314
description: 'Shopify Crawler platform',
309-
url: 'https://shopifycopy.com/'
315+
url: 'http://shopifycopy.com/'
310316
}
311317
];

source/page/Router.tsx renamed to source/page/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ function Copyright() {
2424
/>
2525
<small className="d-block mb-3 text-muted">
2626
&copy; 2018 - {new Date().getFullYear()}
27-
<a target="_blank" href="https://github.com/EasyWebApp">
27+
<a
28+
className="d-block"
29+
target="_blank"
30+
href="https://github.com/EasyWebApp"
31+
>
2832
EasyWebApp team
2933
</a>
3034
</small>

0 commit comments

Comments
 (0)