Skip to content

Commit

Permalink
feat: Add new app detail page (#655)
Browse files Browse the repository at this point in the history
* refactor: Modify Header and TitleBanner by design
  • Loading branch information
dongrui authored and sunnywx committed Jan 10, 2019
1 parent 6621cb3 commit 762fdf4
Show file tree
Hide file tree
Showing 38 changed files with 653 additions and 1,417 deletions.
2 changes: 1 addition & 1 deletion src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class App extends React.Component {

return (
<LazyLoad>
{(hasHeader || isHome) && <Header isHome={isHome} />}
{(hasHeader || isHome) && <Header />}
<WrapComp {...props} />
{(hasHeader || isHome) && <Footer />}
</LazyLoad>
Expand Down
2 changes: 1 addition & 1 deletion src/components/AppImages/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default class AppImages extends Component {
<Link
className={styles.image}
key={app_id}
to={user.isDev ? `/dashboard/app/${app_id}` : `/store/${app_id}`}
to={`/apps/${app_id}`}
title={name}
>
<Image src={icon} iconLetter={name} className={styles.img} />
Expand Down
4 changes: 2 additions & 2 deletions src/components/AppList/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default class AppList extends PureComponent {
icon={app.icon}
name={app.name}
desc={app.description}
link={`/${skipLink}/${app.app_id}`}
link={`/apps/${app.app_id}`}
fold
/>
))}
Expand Down Expand Up @@ -94,7 +94,7 @@ export default class AppList extends PureComponent {
name={app.name}
desc={app.description}
key={idx}
link={`/${skipLink}/${app.app_id}`}
link={`/apps/${app.app_id}`}
/>
))}

Expand Down
57 changes: 13 additions & 44 deletions src/components/Header/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { observer, inject } from 'mobx-react';
import { translate } from 'react-i18next';
import { toUrl } from 'utils/url';

import { Popover, Icon, Input } from 'components/Base';
import { Popover, Icon } from 'components/Base';
import MenuLayer from 'components/MenuLayer';
import Logo from '../Logo';

Expand All @@ -21,24 +21,13 @@ import styles from './index.scss';
}))
@observer
class Header extends Component {
static propTypes = {
isHome: PropTypes.bool
};

onSearch = async value => {
const { appStore, history, isHome } = this.props;
const pushUrl = isHome ? `/apps/search/${value}` : `/store/search/${value}`;
history.push(pushUrl);
await appStore.fetchAll({ search_word: value });
appStore.homeApps = appStore.apps;
};

onClearSearch = async () => {
this.props.history.push('/');
};

isLinkActive = curLink => {
const { pathname } = location;

if (curLink === 'apps') {
return pathname === '/' || pathname.indexOf(curLink) > -1;
}

return pathname.indexOf(curLink) > -1;
};

Expand All @@ -48,10 +37,10 @@ class Header extends Component {
return (
<div className={styles.menus}>
<NavLink
to="/store"
to="/apps"
exact
activeClassName={styles.active}
isActive={() => this.isLinkActive('store')}
isActive={() => this.isLinkActive('apps')}
>
{t('App Store')}
</NavLink>
Expand Down Expand Up @@ -106,41 +95,21 @@ class Header extends Component {
}

render() {
const {
t,
isHome,
match,
rootStore: { fixNav }
} = this.props;
const logoUrl = fixNav ? '/logo_light.svg' : '/logo_dark.svg';
const appSearch = match.params.search;
const { user, t } = this.props;

if (isHome) {
if (!user.isNormal) {
return (
<div
className={classnames('header', styles.header, {
[styles.deepHome]: fixNav
})}
>
<div className={styles.header}>
<div className={styles.wrapper}>
<Logo className={styles.logo} url={logoUrl} />
<Logo className={styles.logo} url="/logo_light.svg" />
{this.renderMenuBtns()}
{fixNav && (
<Input.Search
className={styles.search}
placeholder={t('search.placeholder')}
value={appSearch}
onSearch={this.onSearch}
onClear={this.onClearSearch}
/>
)}
</div>
</div>
);
}

return (
<div className={classnames(styles.header, styles.deepInner)}>
<div className={classnames(styles.header, styles.menusHeader)}>
<div className={styles.wrapper}>
<Link className={styles.logoIcon} to="/">
<Icon
Expand Down
85 changes: 20 additions & 65 deletions src/components/Header/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ $profile-hover-color: #efe6f8;
}

.header {
position: absolute;
position: fixed;
top: 0;
z-index: 99;
width: 100%;
height: $header-height;
z-index: 99;
background: none;
background-color: $N400;

.wrapper {
width: $content-width;
Expand Down Expand Up @@ -99,9 +99,10 @@ $profile-hover-color: #efe6f8;
.login{
float: right;
display: inline-block;
margin: 14px 0;
line-height: 20px;
color: $N500;
margin: 16px 0;
line-height: 16px;
font-size: 12px;
color: $N0;
font-weight: 500;
opacity: 0.9;

Expand All @@ -118,25 +119,28 @@ $profile-hover-color: #efe6f8;
height: 16px;
width: auto;
line-height: 16px;
font-size: 14px;
opacity: 0.9;
color: $N500;
font-size: 12px;
color: $N65;
opacity: 1;
font-weight: 500;
border: 0 none;

.icon {
float: right;
margin-left: 2px;
svg {
--primary-color: #{$N500};
--secondary-color: #{$N500};
--primary-color: #{$N65};
--secondary-color: #{$N65};
}
}

&:hover{
border: 0 none;
box-shadow: none;
opacity: 1;
&:hover {
color: $N30;

.icon svg {
--primary-color: #{$N30};
--secondary-color: #{$N30};
}
}
}
}
Expand All @@ -149,36 +153,7 @@ $profile-hover-color: #efe6f8;
}
}

.deepInner,
.deepHome {
position: fixed;
}

.deepHome {
background: linear-gradient(to left, $P75, #854fb9 32%, #484999);
animation-duration: 0.5s;
animation-name: deepHeader;
animation-iteration-count: 1;
animation-timing-function: ease-in-out;
animation-fill-mode: forwards;

.login {
color: $N0;
}

.user [class*='target']{
color: $N0;

.icon svg{
--primary-color: #{$N0};
--secondary-color: #{$N0};
}
}
}

.deepInner {
background-color: $N400;

.menusHeader {
.logoIcon {
float: left;
display: inline-block;
Expand Down Expand Up @@ -220,26 +195,6 @@ $profile-hover-color: #efe6f8;
}
}

.user [class*='target'] {
font-size: 12px;
color: $N65;
opacity: 1;

.icon svg{
--primary-color: #{$N65};
--secondary-color: #{$N65};
}

&:hover {
color: $N30;

.icon svg {
--primary-color: #{$N30};
--secondary-color: #{$N30};
}
}
}

.mail {
float: right;
margin: 14px 8px;
Expand Down
34 changes: 24 additions & 10 deletions src/components/Layout/TitleBanner.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ import PropTypes from 'prop-types';
import { withRouter } from 'react-router-dom';
import { translate } from 'react-i18next';

import { Image } from 'components/Base';
import { Image, Input } from 'components/Base';
import styles from './index.scss';

@translate()
class TitleBanner extends Component {
static propTypes = {
appSearch: PropTypes.string,
className: PropTypes.string,
description: PropTypes.string,
hasSearch: PropTypes.bool,
Expand All @@ -20,11 +21,12 @@ class TitleBanner extends Component {
icon: '',
title: '',
description: '',
hasSearch: false
hasSearch: false,
appSearch: ''
};

onSearch = async value => {
this.props.history.push(`/store/search/${value}`);
this.props.history.push(`/apps/search/${value}`);
};

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

render() {
const {
icon, title, description, t
icon, title, description, hasSearch, appSearch, t
} = this.props;

return (
<div className={styles.titleBanner}>
<div className={styles.wrapper}>
{Boolean(icon) && (
<span className={styles.image}>
<Image src={icon} iconSize={48} iconLetter={title} />
</span>
<div className={styles.words}>
{Boolean(icon) && (
<span className={styles.image}>
<Image src={icon} iconSize={48} iconLetter={title} />
</span>
)}
<div className={styles.name}>{t(title)}</div>
<div className={styles.description}>{t(description)}</div>
</div>

{hasSearch && (
<Input.Search
className={styles.search}
placeholder={t('search.placeholder')}
value={appSearch}
onSearch={this.onSearch}
onClear={this.onClearSearch}
/>
)}
<div className={styles.name}>{t(title)}</div>
<div className={styles.description}>{t(description)}</div>
</div>
</div>
);
Expand Down
3 changes: 2 additions & 1 deletion src/components/Layout/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ class Layout extends Component {
isCenterPage,
centerWidth,
hasBack,
user
user,
match
} = this.props;

const hasMenu = !user.isNormal && !isHome;
Expand Down
Loading

0 comments on commit 762fdf4

Please sign in to comment.