Skip to content

Commit 762fdf4

Browse files
dongruisunnywx
authored andcommitted
feat: Add new app detail page (#655)
* refactor: Modify Header and TitleBanner by design
1 parent 6621cb3 commit 762fdf4

File tree

38 files changed

+653
-1417
lines changed

38 files changed

+653
-1417
lines changed

src/App.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class App extends React.Component {
5656

5757
return (
5858
<LazyLoad>
59-
{(hasHeader || isHome) && <Header isHome={isHome} />}
59+
{(hasHeader || isHome) && <Header />}
6060
<WrapComp {...props} />
6161
{(hasHeader || isHome) && <Footer />}
6262
</LazyLoad>

src/components/AppImages/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export default class AppImages extends Component {
3636
<Link
3737
className={styles.image}
3838
key={app_id}
39-
to={user.isDev ? `/dashboard/app/${app_id}` : `/store/${app_id}`}
39+
to={`/apps/${app_id}`}
4040
title={name}
4141
>
4242
<Image src={icon} iconLetter={name} className={styles.img} />

src/components/AppList/index.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export default class AppList extends PureComponent {
6363
icon={app.icon}
6464
name={app.name}
6565
desc={app.description}
66-
link={`/${skipLink}/${app.app_id}`}
66+
link={`/apps/${app.app_id}`}
6767
fold
6868
/>
6969
))}
@@ -94,7 +94,7 @@ export default class AppList extends PureComponent {
9494
name={app.name}
9595
desc={app.description}
9696
key={idx}
97-
link={`/${skipLink}/${app.app_id}`}
97+
link={`/apps/${app.app_id}`}
9898
/>
9999
))}
100100

src/components/Header/index.jsx

Lines changed: 13 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { observer, inject } from 'mobx-react';
66
import { translate } from 'react-i18next';
77
import { toUrl } from 'utils/url';
88

9-
import { Popover, Icon, Input } from 'components/Base';
9+
import { Popover, Icon } from 'components/Base';
1010
import MenuLayer from 'components/MenuLayer';
1111
import Logo from '../Logo';
1212

@@ -21,24 +21,13 @@ import styles from './index.scss';
2121
}))
2222
@observer
2323
class Header extends Component {
24-
static propTypes = {
25-
isHome: PropTypes.bool
26-
};
27-
28-
onSearch = async value => {
29-
const { appStore, history, isHome } = this.props;
30-
const pushUrl = isHome ? `/apps/search/${value}` : `/store/search/${value}`;
31-
history.push(pushUrl);
32-
await appStore.fetchAll({ search_word: value });
33-
appStore.homeApps = appStore.apps;
34-
};
35-
36-
onClearSearch = async () => {
37-
this.props.history.push('/');
38-
};
39-
4024
isLinkActive = curLink => {
4125
const { pathname } = location;
26+
27+
if (curLink === 'apps') {
28+
return pathname === '/' || pathname.indexOf(curLink) > -1;
29+
}
30+
4231
return pathname.indexOf(curLink) > -1;
4332
};
4433

@@ -48,10 +37,10 @@ class Header extends Component {
4837
return (
4938
<div className={styles.menus}>
5039
<NavLink
51-
to="/store"
40+
to="/apps"
5241
exact
5342
activeClassName={styles.active}
54-
isActive={() => this.isLinkActive('store')}
43+
isActive={() => this.isLinkActive('apps')}
5544
>
5645
{t('App Store')}
5746
</NavLink>
@@ -106,41 +95,21 @@ class Header extends Component {
10695
}
10796

10897
render() {
109-
const {
110-
t,
111-
isHome,
112-
match,
113-
rootStore: { fixNav }
114-
} = this.props;
115-
const logoUrl = fixNav ? '/logo_light.svg' : '/logo_dark.svg';
116-
const appSearch = match.params.search;
98+
const { user, t } = this.props;
11799

118-
if (isHome) {
100+
if (!user.isNormal) {
119101
return (
120-
<div
121-
className={classnames('header', styles.header, {
122-
[styles.deepHome]: fixNav
123-
})}
124-
>
102+
<div className={styles.header}>
125103
<div className={styles.wrapper}>
126-
<Logo className={styles.logo} url={logoUrl} />
104+
<Logo className={styles.logo} url="/logo_light.svg" />
127105
{this.renderMenuBtns()}
128-
{fixNav && (
129-
<Input.Search
130-
className={styles.search}
131-
placeholder={t('search.placeholder')}
132-
value={appSearch}
133-
onSearch={this.onSearch}
134-
onClear={this.onClearSearch}
135-
/>
136-
)}
137106
</div>
138107
</div>
139108
);
140109
}
141110

142111
return (
143-
<div className={classnames(styles.header, styles.deepInner)}>
112+
<div className={classnames(styles.header, styles.menusHeader)}>
144113
<div className={styles.wrapper}>
145114
<Link className={styles.logoIcon} to="/">
146115
<Icon

src/components/Header/index.scss

Lines changed: 20 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ $profile-hover-color: #efe6f8;
1414
}
1515

1616
.header {
17-
position: absolute;
17+
position: fixed;
1818
top: 0;
19+
z-index: 99;
1920
width: 100%;
2021
height: $header-height;
21-
z-index: 99;
22-
background: none;
22+
background-color: $N400;
2323

2424
.wrapper {
2525
width: $content-width;
@@ -99,9 +99,10 @@ $profile-hover-color: #efe6f8;
9999
.login{
100100
float: right;
101101
display: inline-block;
102-
margin: 14px 0;
103-
line-height: 20px;
104-
color: $N500;
102+
margin: 16px 0;
103+
line-height: 16px;
104+
font-size: 12px;
105+
color: $N0;
105106
font-weight: 500;
106107
opacity: 0.9;
107108

@@ -118,25 +119,28 @@ $profile-hover-color: #efe6f8;
118119
height: 16px;
119120
width: auto;
120121
line-height: 16px;
121-
font-size: 14px;
122-
opacity: 0.9;
123-
color: $N500;
122+
font-size: 12px;
123+
color: $N65;
124+
opacity: 1;
124125
font-weight: 500;
125126
border: 0 none;
126127

127128
.icon {
128129
float: right;
129130
margin-left: 2px;
130131
svg {
131-
--primary-color: #{$N500};
132-
--secondary-color: #{$N500};
132+
--primary-color: #{$N65};
133+
--secondary-color: #{$N65};
133134
}
134135
}
135136

136-
&:hover{
137-
border: 0 none;
138-
box-shadow: none;
139-
opacity: 1;
137+
&:hover {
138+
color: $N30;
139+
140+
.icon svg {
141+
--primary-color: #{$N30};
142+
--secondary-color: #{$N30};
143+
}
140144
}
141145
}
142146
}
@@ -149,36 +153,7 @@ $profile-hover-color: #efe6f8;
149153
}
150154
}
151155

152-
.deepInner,
153-
.deepHome {
154-
position: fixed;
155-
}
156-
157-
.deepHome {
158-
background: linear-gradient(to left, $P75, #854fb9 32%, #484999);
159-
animation-duration: 0.5s;
160-
animation-name: deepHeader;
161-
animation-iteration-count: 1;
162-
animation-timing-function: ease-in-out;
163-
animation-fill-mode: forwards;
164-
165-
.login {
166-
color: $N0;
167-
}
168-
169-
.user [class*='target']{
170-
color: $N0;
171-
172-
.icon svg{
173-
--primary-color: #{$N0};
174-
--secondary-color: #{$N0};
175-
}
176-
}
177-
}
178-
179-
.deepInner {
180-
background-color: $N400;
181-
156+
.menusHeader {
182157
.logoIcon {
183158
float: left;
184159
display: inline-block;
@@ -220,26 +195,6 @@ $profile-hover-color: #efe6f8;
220195
}
221196
}
222197

223-
.user [class*='target'] {
224-
font-size: 12px;
225-
color: $N65;
226-
opacity: 1;
227-
228-
.icon svg{
229-
--primary-color: #{$N65};
230-
--secondary-color: #{$N65};
231-
}
232-
233-
&:hover {
234-
color: $N30;
235-
236-
.icon svg {
237-
--primary-color: #{$N30};
238-
--secondary-color: #{$N30};
239-
}
240-
}
241-
}
242-
243198
.mail {
244199
float: right;
245200
margin: 14px 8px;

src/components/Layout/TitleBanner.jsx

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ import PropTypes from 'prop-types';
33
import { withRouter } from 'react-router-dom';
44
import { translate } from 'react-i18next';
55

6-
import { Image } from 'components/Base';
6+
import { Image, Input } from 'components/Base';
77
import styles from './index.scss';
88

99
@translate()
1010
class TitleBanner extends Component {
1111
static propTypes = {
12+
appSearch: PropTypes.string,
1213
className: PropTypes.string,
1314
description: PropTypes.string,
1415
hasSearch: PropTypes.bool,
@@ -20,11 +21,12 @@ class TitleBanner extends Component {
2021
icon: '',
2122
title: '',
2223
description: '',
23-
hasSearch: false
24+
hasSearch: false,
25+
appSearch: ''
2426
};
2527

2628
onSearch = async value => {
27-
this.props.history.push(`/store/search/${value}`);
29+
this.props.history.push(`/apps/search/${value}`);
2830
};
2931

3032
onClearSearch = async () => {
@@ -33,19 +35,31 @@ class TitleBanner extends Component {
3335

3436
render() {
3537
const {
36-
icon, title, description, t
38+
icon, title, description, hasSearch, appSearch, t
3739
} = this.props;
3840

3941
return (
4042
<div className={styles.titleBanner}>
4143
<div className={styles.wrapper}>
42-
{Boolean(icon) && (
43-
<span className={styles.image}>
44-
<Image src={icon} iconSize={48} iconLetter={title} />
45-
</span>
44+
<div className={styles.words}>
45+
{Boolean(icon) && (
46+
<span className={styles.image}>
47+
<Image src={icon} iconSize={48} iconLetter={title} />
48+
</span>
49+
)}
50+
<div className={styles.name}>{t(title)}</div>
51+
<div className={styles.description}>{t(description)}</div>
52+
</div>
53+
54+
{hasSearch && (
55+
<Input.Search
56+
className={styles.search}
57+
placeholder={t('search.placeholder')}
58+
value={appSearch}
59+
onSearch={this.onSearch}
60+
onClear={this.onClearSearch}
61+
/>
4662
)}
47-
<div className={styles.name}>{t(title)}</div>
48-
<div className={styles.description}>{t(description)}</div>
4963
</div>
5064
</div>
5165
);

src/components/Layout/index.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ class Layout extends Component {
113113
isCenterPage,
114114
centerWidth,
115115
hasBack,
116-
user
116+
user,
117+
match
117118
} = this.props;
118119

119120
const hasMenu = !user.isNormal && !isHome;

0 commit comments

Comments
 (0)