Skip to content

Commit b586abf

Browse files
whDongRuisunnywx
authored andcommitted
fix: Home app list card style (#504)
1 parent 3baebec commit b586abf

File tree

4 files changed

+46
-30
lines changed

4 files changed

+46
-30
lines changed

src/components/AppList/index.jsx

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,18 @@ export default class AppList extends PureComponent {
4646
<CardTitle skipLink={skipLink} categoryId={category_id} title={name} more />
4747
)}
4848

49-
{apps.slice(0, 6).map(app => (
50-
<Link key={app.app_id} to={`/${skipLink}/${app.app_id}`}>
51-
<Card icon={app.icon} name={app.name} desc={app.description} fold />
52-
</Link>
53-
))}
49+
{apps
50+
.slice(0, 6)
51+
.map(app => (
52+
<Card
53+
key={app.app_id}
54+
icon={app.icon}
55+
name={app.name}
56+
desc={app.description}
57+
link={`/${skipLink}/${app.app_id}`}
58+
fold
59+
/>
60+
))}
5461
</div>
5562
);
5663
});
@@ -66,10 +73,10 @@ export default class AppList extends PureComponent {
6673
const { apps, className, skipLink, isLoading, t } = this.props;
6774

6875
return (
69-
<div className={classnames(styles.appList, className)}>
70-
{<CardTitle title={this.getSearchTitle()} more={false} />}
76+
<div className={classnames(className)}>
77+
<div className={styles.appList}>
78+
{<CardTitle title={this.getSearchTitle()} more={false} />}
7179

72-
<div className={styles.appsRow}>
7380
{apps.map((app, idx) => (
7481
<Card
7582
icon={app.icon}
@@ -79,9 +86,9 @@ export default class AppList extends PureComponent {
7986
link={`/${skipLink}/${app.app_id}`}
8087
/>
8188
))}
82-
</div>
8389

84-
{!apps.length && !isLoading && <div className={styles.noData}>{t('NO_SEARCH_DATA')}</div>}
90+
{!apps.length && !isLoading && <div className={styles.noData}>{t('NO_SEARCH_DATA')}</div>}
91+
</div>
8592

8693
{this.renderCategoryApps()}
8794
</div>

src/components/AppList/index.scss

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
@import '~scss/vars';
22

3-
.appList {
4-
a {
3+
4+
.appList, .categoryApps {
5+
overflow: hidden;
6+
_zoom: 1;
7+
8+
> div {
59
&:nth-child(3n+4) {
6-
&>div {
7-
margin-right: 0;
8-
}
10+
margin-right: 0;
911
}
1012
}
11-
.noData{
13+
}
14+
15+
.appList {
16+
.noData {
1217
padding: 20px 0;
1318
text-align: center;
1419
font-size: 12px;
1520
color: $N75;
1621
}
1722
}
18-
.categoryApps{
19-
margin-top: -16px;
20-
}
2123

22-
.appsRow {
23-
display: flex;
24-
justify-content: space-between;
24+
.categoryApps {
25+
margin-top: -16px;
2526
}

src/components/Card/index.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
@import '~scss/vars';
22

33
.card {
4+
float: left;
45
display: inline-block;
56
width: $app-card-width;
67
height: $app-card-height;
78
padding: 40px 20px 20px;
8-
//margin: 0 24px 24px 0;
9+
margin: 0 24px 24px 0;
910
border-radius: 2px;
1011
//border: 1px solid $border-light;
1112
background-color: $N0;

src/pages/Home/index.jsx

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,27 @@ import styles from './index.scss';
1919
}))
2020
@observer
2121
export default class Home extends Component {
22+
async componentWillMount() {
23+
const { rootStore, match } = this.props;
24+
const { category, search } = match.params;
25+
26+
if (category || search) {
27+
rootStore.setNavFix(true);
28+
} else {
29+
rootStore.setNavFix(false);
30+
}
31+
32+
window.scroll({ top: 0 });
33+
}
34+
2235
async componentDidMount() {
2336
const { rootStore, appStore, categoryStore, match } = this.props;
2437
const { category, search } = match.params;
2538
const filterParams = { status: 'active', noLimit: true };
2639

27-
window.scroll({ top: 0, behavior: 'smooth' });
28-
2940
await categoryStore.fetchAll();
3041

31-
if (category || search) {
32-
rootStore.setNavFix(true);
33-
} else {
34-
// home page
35-
rootStore.setNavFix(false);
42+
if (!(category || search)) {
3643
this.threshold = this.getThreshold();
3744
window.onscroll = this.handleScroll;
3845
}

0 commit comments

Comments
 (0)