-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #626 from ResearchHub/AsOne/hubs_redesign
AsOne work trial - Hubs Page Redesign (Frontend)
- Loading branch information
Showing
17 changed files
with
1,334 additions
and
220 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
import React, { Fragment } from "react"; | ||
import { StyleSheet, css } from "aphrodite"; | ||
import Link from "next/link"; | ||
import { connect } from "react-redux"; | ||
import Ripples from "react-ripples"; | ||
import ReactPlaceholder from "react-placeholder/lib"; | ||
import "react-placeholder/lib/reactPlaceholder.css"; | ||
|
||
// Component | ||
import HubEntryPlaceholder from "../Placeholders/HubEntryPlaceholder"; | ||
|
||
// Config | ||
import colors from "../../config/themes/colors"; | ||
|
||
class CategoryList extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
categories: | ||
this.props.categories && this.props.categories.results | ||
? this.props.categories.results | ||
: [], | ||
}; | ||
} | ||
|
||
renderCategoryEntry = () => { | ||
let categories = this.props.categories; | ||
return categories.map((category, i) => { | ||
let { category_name } = category; | ||
let slug = category_name.toLowerCase().replace(/\s/g, "-"); | ||
return ( | ||
<Ripples | ||
className={css(styles.categoryEntry)} | ||
key={`${category_name}-${i}`} | ||
> | ||
<Link | ||
href={{ | ||
pathname: "/hubs#${slug}", | ||
}} | ||
as={`/hubs#${slug}`} | ||
> | ||
<a className={css(styles.categoryLink)}>{category_name}</a> | ||
</Link> | ||
</Ripples> | ||
); | ||
}); | ||
}; | ||
|
||
render() { | ||
let { overrideStyle } = this.props; | ||
return ( | ||
<div className={css(styles.container, overrideStyle && overrideStyle)}> | ||
<div className={css(styles.categoryListContainer)}> | ||
<div className={css(styles.listLabel)} id={"categoryListTitle"}> | ||
Categories | ||
</div> | ||
<div className={css(styles.categoryList)}> | ||
{this.props.categories.length > 0 ? ( | ||
this.renderCategoryEntry() | ||
) : ( | ||
<Fragment> | ||
<ReactPlaceholder | ||
showLoadingAnimation | ||
ready={false} | ||
customPlaceholder={ | ||
<HubEntryPlaceholder color="#efefef" rows={9} /> | ||
} | ||
/> | ||
</Fragment> | ||
)} | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
position: "fixed", | ||
display: "flex", | ||
flexDirection: "column", | ||
justifyContent: "center", | ||
alignItems: "center", | ||
paddingTop: 50, | ||
"@media only screen and (max-height: 800px)": { | ||
display: "none", | ||
}, | ||
}, | ||
categoryListContainer: { | ||
height: "100%", | ||
width: "100%", | ||
display: "flex", | ||
flexDirection: "column", | ||
justifyContent: "flex-start", | ||
alignItems: "center", | ||
textAlign: "left", | ||
cursor: "default", | ||
}, | ||
listLabel: { | ||
textTransform: "uppercase", | ||
fontWeight: 500, | ||
fontSize: 13, | ||
letterSpacing: 1.2, | ||
marginBottom: 15, | ||
textAlign: "left", | ||
color: "#a7a6b0", | ||
transition: "all ease-out 0.1s", | ||
width: "90%", | ||
paddingLeft: 25, | ||
boxSizing: "border-box", | ||
}, | ||
categoryEntry: { | ||
width: "100%", | ||
maxWidth: 175, | ||
fontSize: 16, | ||
fontWeight: 300, | ||
cursor: "pointer", | ||
transition: "all ease-out 0.1s", | ||
borderRadius: 3, | ||
border: "1px solid #fff", | ||
marginBottom: 8, | ||
":hover": { | ||
borderColor: "rgb(237, 237, 237)", | ||
backgroundColor: "#FAFAFA", | ||
}, | ||
}, | ||
categoryLink: { | ||
width: "100%", | ||
textDecoration: "none", | ||
color: "#111", | ||
display: "flex", | ||
alignItems: "center", | ||
padding: "8px", | ||
}, | ||
categoryList: { | ||
boxSizing: "border-box", | ||
display: "flex", | ||
flexDirection: "column", | ||
justifyContent: "flex-start", | ||
alignItems: "flex-start", | ||
padding: "0px 30px", | ||
}, | ||
}); | ||
|
||
const mapStateToProps = (state) => ({ | ||
auth: state.auth, | ||
categories: state.hubs.categories, | ||
}); | ||
|
||
export default connect(mapStateToProps)(CategoryList); |
Oops, something went wrong.