From 7b2f8c9ec9c0b5202787ac94035a1bc91da5e7f4 Mon Sep 17 00:00:00 2001 From: mortuie Date: Thu, 20 Dec 2018 17:38:03 +0100 Subject: [PATCH 01/11] Intial commit of removing all the aphrodite --- frontend/src/Common/Buttons/CrossButton.js | 23 ++---- frontend/src/Dashboard/Dashboard.Loader.js | 22 +++--- frontend/src/Dummy/Dummy.js | 88 ++++++++++++---------- frontend/src/House/Card.Loader.js | 71 ++++++++--------- frontend/src/House/Card.js | 71 ++++++++--------- 5 files changed, 135 insertions(+), 140 deletions(-) diff --git a/frontend/src/Common/Buttons/CrossButton.js b/frontend/src/Common/Buttons/CrossButton.js index 8b18ff7..4c37549 100644 --- a/frontend/src/Common/Buttons/CrossButton.js +++ b/frontend/src/Common/Buttons/CrossButton.js @@ -1,18 +1,13 @@ import React from 'react'; import PropTypes from 'prop-types'; -import { StyleSheet, css } from 'aphrodite'; +import styled from 'styled-components'; -const cross_symbol = String.fromCharCode(10799); +const SYMBOL = String.fromCharCode(10799); const CrossButton = props => ( - + + {SYMBOL} + ); CrossButton.propTypes = { @@ -20,10 +15,8 @@ CrossButton.propTypes = { onClick: PropTypes.func.isRequired }; -const styles = StyleSheet.create({ - cross_box_colour: { - background: 'tomato' // "linear-gradient( to top, #49CF87, #40C080)" - } -}); +const ButtonStyle = styled.button` + background: tomato; +`; export default CrossButton; diff --git a/frontend/src/Dashboard/Dashboard.Loader.js b/frontend/src/Dashboard/Dashboard.Loader.js index a6c377c..f62b926 100644 --- a/frontend/src/Dashboard/Dashboard.Loader.js +++ b/frontend/src/Dashboard/Dashboard.Loader.js @@ -1,25 +1,23 @@ import React from 'react'; import HouseListLoader from '../House/HouseList.Loader'; -import { StyleSheet, css } from 'aphrodite'; +import styled from 'styled-components'; const DashboardLoader = () => (

Dashboard

-
); -const styles = StyleSheet.create({ - button: { - width: '80px', - height: '1.5rem', - background: 'lightgrey', - borderRadius: '10px', - ':hover': { - boxShadow: 'none' - } +const StyledButton = styled.button` + width: 80px; + height: 1.5rem; + background: lightgrey; + border-radius: 10px; + &:hover { + box-shadow: none; } -}); +`; export default DashboardLoader; diff --git a/frontend/src/Dummy/Dummy.js b/frontend/src/Dummy/Dummy.js index 9f65db9..8addb75 100644 --- a/frontend/src/Dummy/Dummy.js +++ b/frontend/src/Dummy/Dummy.js @@ -1,45 +1,53 @@ import React from 'react'; -import { StyleSheet, css } from 'aphrodite'; +import styled from 'styled-components'; -const styles = StyleSheet.create({ - container: { - height: '80vh', - width: '100%', - display: 'flex', - justifyContent: 'center', - alignItems: 'center' - }, - form: { - display: 'flex', - border: '20px solid rgba(0,0,0,0.3)', - borderRadius: '5px' - }, - formInput: { - border: '0', - padding: '10px', - background: 'white', - lineHeight: '50px', - fontSize: '20px', - borderRadius: '0', - outline: '0', - borderRight: '1px solid rgba(0,0,0,0.2)' - }, - formSubmit: { - border: '0', - padding: '10px', - lineHeight: '50px', - fontSize: '20px', - borderRadius: '0', - outline: '0', - borderRight: '1px solid rgba(0,0,0,0.2)', - background: '#FF5A5F', - borderTop: '1px solid #FF5A5F', - borderBottom: '1px solid #FF5A5F', - color: 'white', - flexBasis: '500px' - } -}); +const Container = styled.div` + height: 80vh; + width: 100%; + display: flex; + justify-content: center; + align-items: center; +`; -const Dummy = () =>
; +// const styles = StyleSheet.create({ +// container: { +// height: '80vh', +// width: '100%', +// display: 'flex', +// justifyContent: 'center', +// alignItems: 'center' +// } +// form: { +// display: 'flex', +// border: '20px solid rgba(0,0,0,0.3)', +// borderRadius: '5px' +// }, +// formInput: { +// border: '0', +// padding: '10px', +// background: 'white', +// lineHeight: '50px', +// fontSize: '20px', +// borderRadius: '0', +// outline: '0', +// borderRight: '1px solid rgba(0,0,0,0.2)' +// } +// formSubmit: { +// border: '0', +// padding: '10px', +// lineHeight: '50px', +// fontSize: '20px', +// borderRadius: '0', +// outline: '0', +// borderRight: '1px solid rgba(0,0,0,0.2)', +// background: '#FF5A5F', +// borderTop: '1px solid #FF5A5F', +// borderBottom: '1px solid #FF5A5F', +// color: 'white', +// flexBasis: '500px' +// } +// }); + +const Dummy = () => ; export default Dummy; diff --git a/frontend/src/House/Card.Loader.js b/frontend/src/House/Card.Loader.js index 75ee66a..401f249 100644 --- a/frontend/src/House/Card.Loader.js +++ b/frontend/src/House/Card.Loader.js @@ -1,42 +1,43 @@ import React from 'react'; -import { StyleSheet, css } from 'aphrodite'; +import styled from 'styled-components'; const CardLoader = () => ( -
-
-
-
-
+ + + + + ); -const styles = StyleSheet.create({ - imageGreyed: { - width: '100%', - height: '200px', - background: 'lightgrey' - }, - titleGreyed: { - width: '100%', - height: '3rem', - background: 'lightgrey', - marginTop: '10px' - }, - descriptionGreyed: { - width: '100%', - height: '4rem', - background: 'lightgrey', - marginTop: '10px' - }, - container: { - background: 'snow', - boxShadow: '0px 0px 5px 2px rgba(0, 0, 0, 0.19)', - borderRadius: '10px', - display: 'flex', - flexDirection: 'column', - alignItems: 'center', - margin: '10px', - width: '320px' - } -}); +const GreyedImage = styled.div` + width: 100%; + height: 200px; + background: lightgrey; +`; + +const Container = styled.div` + background: snow; + box-shadow: 0 0 5px 2px rgba(0, 0, 0, 0.19); + border-radius: 10px; + display: flex; + flex-direction: column; + align-items: center; + margin: 10px; + width: 320px; +`; + +const GreyedTitle = styled.div` + width: 100%; + height: 3rem; + background: lightgrey; + margin-top: 10px; +`; + +const GreyedDescription = styled.div` + width: 100%; + height: 4rem; + background: lightgrey; + margin-top: 10px; +`; export default CardLoader; diff --git a/frontend/src/House/Card.js b/frontend/src/House/Card.js index 6fcd37e..0b7c482 100644 --- a/frontend/src/House/Card.js +++ b/frontend/src/House/Card.js @@ -2,61 +2,56 @@ import React from 'react'; import PropTypes from 'prop-types'; import { ImageDefault } from '../Image'; import Rating from '../Rating'; -import { StyleSheet, css } from 'aphrodite'; +import styled from 'styled-components'; const Card = props => ( -
+ -
+ {props.house.title} <Rating currentRating={props.house.rating} type="house" parent_id={props.house._id} /> - </div> - <p className={css(styles.content)}>{props.house.description}</p> - </div> + + {props.house.description} + ); Card.propTypes = { house: PropTypes.object.isRequired }; -const styles = StyleSheet.create({ - container: { - background: '#fefff9', - boxShadow: 'rgba(0, 0, 0, 0.19) 0 0 8px 0', - borderRadius: '4px', - color: '#363636', - display: 'flex', - flexDirection: 'column', - margin: '10px', - width: '320px' - }, - title: { - display: 'flex', - alignItems: 'center', - fontWeight: 'bold', - margin: '0', - padding: '1% 2.5%', - lineHeight: '1.2', - background: 'rgba(157, 187, 63, .85)', - color: 'white', - bottom: '0', - width: '100%' - }, - title_heading: { - margin: '0', - padding: '0 3.5%', - lineHeight: '1.2' - }, - content: { - padding: '5% 5% 3% 5%' - } -}); +const Container = styled.div` + background: #fefff9; + box-shadow: rgba(0, 0, 0, 0.19) 0 0 8px 0; + border-radius: 4px; + color: #363636; + display: flex; + flex-direction: column; + margin: 10px; + width: 320px; +`; + +const Title = styled.div` + display: flex; + align-items: center; + font-weight: bold; + margin: 0; + padding: 1% 2.5%; + line-height: 1.2; + background: rgba(157, 187, 63, 0.85); + color: white; + bottom: 0; + width: 100%; +`; + +const Content = styled.p` + padding: 5% 5% 3% 5%; +`; export default Card; From ff317f214480dea0b3a4f8edb31dd222d05b5843 Mon Sep 17 00:00:00 2001 From: mortuie Date: Thu, 20 Dec 2018 17:54:54 +0100 Subject: [PATCH 02/11] Working on removing aphrodite --- frontend/src/Uploader/UrlInput.js | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/frontend/src/Uploader/UrlInput.js b/frontend/src/Uploader/UrlInput.js index 994553f..914af9f 100644 --- a/frontend/src/Uploader/UrlInput.js +++ b/frontend/src/Uploader/UrlInput.js @@ -1,9 +1,9 @@ import React from 'react'; import PropTypes from 'prop-types'; -import { StyleSheet, css } from 'aphrodite'; +import styled from 'styled-components'; const UrlInput = props => ( -
+ Url ( onChange={props.onUrlChange} onKeyUp={props.handleUrlKeyUp} /> -
+ ); UrlInput.propTypes = { url_text: PropTypes.string, onUrlChange: PropTypes.func.isRequired, handleUrlKeyUp: PropTypes.func.isRequired }; -export default UrlInput; -const styles = StyleSheet.create({ - wrapper: { - display: 'flex', - justifyContent: 'space-around', - alignItems: 'center' - } -}); +const Container = styled.div` + display: flex; + justify-content: space-around; + align-items: center; +`; + +export default UrlInput; From 5a4c4bc320e22d4c89746f7733434912cd702c30 Mon Sep 17 00:00:00 2001 From: mortuie Date: Thu, 20 Dec 2018 18:00:38 +0100 Subject: [PATCH 03/11] Working on removing aphrodite --- frontend/src/Profile/Avatar.js | 20 +++++++++----------- frontend/src/Search/Form.js | 19 ++++++++----------- 2 files changed, 17 insertions(+), 22 deletions(-) diff --git a/frontend/src/Profile/Avatar.js b/frontend/src/Profile/Avatar.js index 1b1539b..25ba179 100644 --- a/frontend/src/Profile/Avatar.js +++ b/frontend/src/Profile/Avatar.js @@ -2,10 +2,10 @@ import React from 'react'; import PropTypes from 'prop-types'; import { ImageDefault } from '../Image'; import { Uploader } from '../Uploader'; -import { StyleSheet, css } from 'aphrodite'; +import styled from 'styled-components'; const Avatar = ({ name, localUser, image, changeImage }) => ( -
+ {localUser ? ( ) : ( @@ -15,9 +15,15 @@ const Avatar = ({ name, localUser, image, changeImage }) => ( /> )}

{name}

-
+ ); +const Wrapper = styled.div` + display: flex; + flex-direction: column; + flex: 0 1 200px; +`; + Avatar.propTypes = { localUser: PropTypes.bool.isRequired, name: PropTypes.string.isRequired, @@ -25,12 +31,4 @@ Avatar.propTypes = { changeImage: PropTypes.func.isRequired }; -const styles = StyleSheet.create({ - wrapper: { - display: 'flex', - flexDirection: 'column', - flex: '0 1 200px' - } -}); - export default Avatar; diff --git a/frontend/src/Search/Form.js b/frontend/src/Search/Form.js index 7b9f2bd..b71b08d 100644 --- a/frontend/src/Search/Form.js +++ b/frontend/src/Search/Form.js @@ -1,14 +1,11 @@ import React from 'react'; -import { css, StyleSheet } from 'aphrodite'; +import styled from 'styled-components'; -const Form = props =>
; -export default Form; +export default props => ; -const styles = StyleSheet.create({ - form: { - display: 'flex', - border: '10px solid rgba(0,0,0,0.3)', - borderRadius: '5px', - zIndex: '10' - } -}); +const StyledForm = styled.form` + display: flex; + border: 10px solid rgbd(0, 0, 0, 0.3); + border-radius: 5px; + z-index: 10; +`; From 2fb26448694c967d372fcd0ef2b66704de3e33ad Mon Sep 17 00:00:00 2001 From: mortuie Date: Thu, 20 Dec 2018 20:33:57 +0100 Subject: [PATCH 04/11] Continuing with the refactor --- frontend/src/House/HouseDetail.js | 39 ++++++++------- frontend/src/House/HouseDetailEdit.js | 39 ++++++++------- frontend/src/House/HouseForm.js | 70 ++++++++++++++------------- 3 files changed, 81 insertions(+), 67 deletions(-) diff --git a/frontend/src/House/HouseDetail.js b/frontend/src/House/HouseDetail.js index dd2d0ae..a547b14 100644 --- a/frontend/src/House/HouseDetail.js +++ b/frontend/src/House/HouseDetail.js @@ -1,10 +1,10 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { connect } from 'react-redux'; -import { css, StyleSheet } from 'aphrodite'; import { ImageList } from '../Image'; import HouseForm from './HouseForm'; import { houseFetchData, houseSaveData, houseReset } from './actions'; +import styled, { css } from 'styled-components'; class House extends Component { static propTypes = { @@ -90,30 +90,35 @@ class House extends Component { if (isWorking) { return

Please wait ...

; } - const show_error = { - color: 'tomato', - display: hasErrored ? 'block' : 'none' - }; return ( -
+

House (View)

-
{errorMessage}
+ {errorMessage} -
+ ); }; } -const styles = StyleSheet.create({ - centered: { - display: 'flex', - flex: 1, - flexDirection: 'column', - alignItems: 'center', - justifyContent: 'center' - } -}); +const Centered = styled.div` + display: flex; + flex: 1; + flex-direction: column; + align-items: center; + justify-content: center; +`; + +const ErrorMessage = styled.div` + color: tomato; + display: none; + + ${props => + props.hasErrored && + css` + display: block; + `}; +`; const mapStateToProps = state => { return { diff --git a/frontend/src/House/HouseDetailEdit.js b/frontend/src/House/HouseDetailEdit.js index 0b0f398..32fc79e 100644 --- a/frontend/src/House/HouseDetailEdit.js +++ b/frontend/src/House/HouseDetailEdit.js @@ -1,10 +1,10 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { connect } from 'react-redux'; -import { css, StyleSheet } from 'aphrodite'; import { ImageBlock, ImageListRemovable } from '../Image'; import HouseFormEdit from './HouseFormEdit'; import { houseFetchData, houseSaveData, houseReset } from './actions'; +import styled, { css } from 'styled-components'; class House extends Component { static propTypes = { @@ -91,14 +91,10 @@ class House extends Component { return

Please wait ...

; } const op_type = typeof house._id === 'undefined' ? 'New' : 'Edit'; - const show_error = { - color: 'tomato', - display: hasErrored ? 'block' : 'none' - }; return ( -
+

House ({op_type})

-
{errorMessage}
+ {errorMessage} -
+ ); }; } -const styles = StyleSheet.create({ - centered: { - display: 'flex', - flex: 1, - flexDirection: 'column', - alignItems: 'center', - justifyContent: 'center' - } -}); +const Centered = styled.div` + display: flex; + flex: 1; + flex-direction: column; + align-items: center; + justify-content: center; +`; + +const ErrorMessage = styled.div` + color: tomato; + display: none; + + ${props => + props.hasErrored && + css` + display: block; + `}; +`; const mapStateToProps = state => { return { diff --git a/frontend/src/House/HouseForm.js b/frontend/src/House/HouseForm.js index 99d0503..1983881 100644 --- a/frontend/src/House/HouseForm.js +++ b/frontend/src/House/HouseForm.js @@ -1,6 +1,6 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; -import { StyleSheet, css } from 'aphrodite'; +import styled, { css } from 'styled-components'; export default class HouseForm extends Component { static propTypes = { @@ -10,67 +10,71 @@ export default class HouseForm extends Component { render = () => { const { house } = this.props; return ( - - - + Title + - - Street + - - Post Code + - -