UpdaUpdate changes
This commit is contained in:
parent
cf77606157
commit
d886b5bc39
|
@ -26,19 +26,7 @@ const DappListItem = props => {
|
|||
return (
|
||||
<div className={isRanked ? styles.rankedListItem : styles.listItem}>
|
||||
{isRanked && <div className={styles.position}>{position}</div>}
|
||||
<div
|
||||
onClick={() =>
|
||||
onToggleProfileModal({
|
||||
name,
|
||||
url,
|
||||
description,
|
||||
image,
|
||||
isRanked,
|
||||
position,
|
||||
category,
|
||||
})
|
||||
}
|
||||
>
|
||||
<div onClick={() => onToggleProfileModal(name)}>
|
||||
<ReactImageFallback
|
||||
className={styles.image}
|
||||
src={image}
|
||||
|
@ -47,19 +35,7 @@ const DappListItem = props => {
|
|||
/>
|
||||
</div>
|
||||
<div>
|
||||
<div
|
||||
onClick={() =>
|
||||
onToggleProfileModal({
|
||||
name,
|
||||
url,
|
||||
description,
|
||||
image,
|
||||
isRanked,
|
||||
position,
|
||||
category,
|
||||
})
|
||||
}
|
||||
>
|
||||
<div onClick={() => onToggleProfileModal(name)}>
|
||||
<h2 className={styles.header}>{name}</h2>
|
||||
<p className={styles.description}>{description}</p>
|
||||
</div>
|
||||
|
|
|
@ -13,8 +13,7 @@ export default () => [
|
|||
<Route path="/categories" component={Filtered} />
|
||||
<Route path="/all" component={Dapps} />
|
||||
<Route path="/recently-added" component={RecentlyAdded} />
|
||||
<Route path="/:dapp-name" component={Profile} />
|
||||
<Route path="/:dapp_name" component={Profile} />
|
||||
</Switch>,
|
||||
<Vote key={2} />,
|
||||
<Profile key={3} />,
|
||||
]
|
||||
|
|
|
@ -1,7 +1,15 @@
|
|||
import { connect } from 'react-redux'
|
||||
|
||||
import Profile from './Profile'
|
||||
import { toggleProfileModalAction } from './Profile.reducer'
|
||||
|
||||
const mapStateToProps = state => state
|
||||
|
||||
export default connect(mapStateToProps)(Profile)
|
||||
const mapDispatchToProps = dispatch => ({
|
||||
openModal: dapp => dispatch(toggleProfileModalAction(dapp)),
|
||||
})
|
||||
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps,
|
||||
)(Profile)
|
||||
|
|
|
@ -5,23 +5,14 @@ import Modal from '../../common/components/Modal'
|
|||
import styles from './Profile.module.scss'
|
||||
import icon from '../../common/assets/images/icon.svg'
|
||||
import chat from '../../common/assets/images/chat.svg'
|
||||
import { Redirect } from 'react-router-dom'
|
||||
import { push } from 'connected-react-router'
|
||||
|
||||
const DesktopScreen = props => {
|
||||
return <Modal visible={props.visible}>{props.children}</Modal>
|
||||
}
|
||||
|
||||
const MobileScreen = props => {
|
||||
return (
|
||||
<>
|
||||
{props.router.location.state &&
|
||||
props.router.location.state.name === props.profile.dapp.name ? (
|
||||
props.children
|
||||
) : (
|
||||
<Redirect to={'/'} />
|
||||
)}
|
||||
</>
|
||||
)
|
||||
return <>{props.children}</>
|
||||
}
|
||||
|
||||
const ProfileContent = ({
|
||||
|
@ -29,7 +20,6 @@ const ProfileContent = ({
|
|||
url,
|
||||
description,
|
||||
image,
|
||||
isRanked,
|
||||
position,
|
||||
category,
|
||||
}) => {
|
||||
|
@ -104,26 +94,53 @@ const ProfileContent = ({
|
|||
)
|
||||
}
|
||||
|
||||
const Profile = props => {
|
||||
class Profile extends Component {
|
||||
constructor(props) {
|
||||
super(props)
|
||||
this.state = {
|
||||
screenSize: 0,
|
||||
visible: true,
|
||||
dapp: {},
|
||||
}
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
const { innerWidth } = window
|
||||
return innerWidth >= 1024 ? (
|
||||
<DesktopScreen {...props.profile}>
|
||||
<ProfileContent {...props.profile.dapp} />
|
||||
const { dapp_name } = this.props.match.params
|
||||
|
||||
this.props.dapps.find(dapp => {
|
||||
if (dapp.name.toLowerCase() === dapp_name.toLowerCase()) {
|
||||
if (innerWidth >= 1024) {
|
||||
this.props.openModal(dapp.name)
|
||||
}
|
||||
this.setState({
|
||||
screenSize: innerWidth,
|
||||
visible: true,
|
||||
dapp,
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
render() {
|
||||
return this.state.screenSize >= 1024 ? (
|
||||
<DesktopScreen visible={this.state.visible}>
|
||||
<ProfileContent {...this.state.dapp} />
|
||||
</DesktopScreen>
|
||||
) : (
|
||||
<MobileScreen {...props}>
|
||||
<ProfileContent {...props.profile.dapp} />
|
||||
<MobileScreen {...this.props}>
|
||||
<ProfileContent {...this.state.dapp} />
|
||||
</MobileScreen>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Profile.propTypes = {
|
||||
visible: PropTypes.bool.isRequired,
|
||||
visible: PropTypes.bool,
|
||||
dapp: PropTypes.object,
|
||||
}
|
||||
|
||||
Profile.defaultProps = {
|
||||
visible: false,
|
||||
// visible: false,
|
||||
}
|
||||
|
||||
export default Profile
|
||||
|
|
|
@ -7,14 +7,8 @@ const MOBILE_NAVIGATE = 'MOBILE_NAVIGATE'
|
|||
|
||||
export const toggleProfileModalAction = dapp => {
|
||||
const { innerWidth } = window
|
||||
history.push(`/${dapp.trim()}`, dapp)
|
||||
if (innerWidth <= 1024) {
|
||||
history.push(
|
||||
`/${dapp.name
|
||||
.toLowerCase()
|
||||
.trim()
|
||||
.replace(' ', '-')}`,
|
||||
dapp,
|
||||
)
|
||||
return {
|
||||
type: MOBILE_NAVIGATE,
|
||||
payload: dapp,
|
||||
|
|
Loading…
Reference in New Issue