-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' of https://github.com/realworldreact/realworld…
…react into develop
- Loading branch information
Showing
24 changed files
with
367 additions
and
138 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,7 @@ | ||
module.exports = { | ||
parser: 'babylon', | ||
printWidth: 80, | ||
semi: true, | ||
singleQuote: true, | ||
bracketSpacing: true | ||
}; |
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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
export default () => ({ | ||
root: { | ||
padding: 20, | ||
padding: 20 | ||
}, | ||
logo: { | ||
width: 100, | ||
height: 100, | ||
}, | ||
height: 100 | ||
} | ||
}); |
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 |
---|---|---|
@@ -1,26 +1,26 @@ | ||
export default () => ({ | ||
root: { | ||
padding: 20, | ||
padding: 20 | ||
}, | ||
logo: { | ||
display: 'inline-block', | ||
height: 60, | ||
height: 60 | ||
}, | ||
menu: { | ||
display: 'flex', | ||
textAlign: 'right', | ||
textAlign: 'right' | ||
}, | ||
desktop: { | ||
display: 'none', | ||
display: 'none' | ||
}, | ||
|
||
// small + | ||
'@media screen and (min-width: 48em)': { | ||
mobile: { | ||
display: 'none', | ||
display: 'none' | ||
}, | ||
desktop: { | ||
display: 'flex', | ||
}, | ||
}, | ||
display: 'flex' | ||
} | ||
} | ||
}); |
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,96 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import withStyles from 'react-jss'; | ||
import TextareaAutoize from 'react-textarea-autosize'; | ||
import cx from 'classnames'; | ||
|
||
import styles from './styles'; | ||
|
||
const TextField = props => { | ||
const { | ||
theme, | ||
sheet, | ||
classes, | ||
className, | ||
palette, | ||
reversed, | ||
isTextarea, | ||
type, | ||
value, | ||
onChange, | ||
placeholder, | ||
errorText, | ||
fieldProps, | ||
...etc | ||
} = props; | ||
const cls = cx(classes.root, className); | ||
const node = isTextarea ? TextareaAutoize : 'input'; | ||
return ( | ||
<div className={cls} {...etc}> | ||
{React.createElement(node, { | ||
type: node === 'input' ? type : null, | ||
value, | ||
onChange, | ||
placeholder, | ||
...fieldProps, | ||
className: cx(classes.field, fieldProps.className), | ||
})} | ||
{!!errorText && <div className={classes.errorText}>{errorText}</div>} | ||
</div> | ||
); | ||
}; | ||
|
||
TextField.propTypes = { | ||
/** | ||
* Color palette. | ||
*/ | ||
palette: PropTypes.oneOf(['primary', 'secondary']), | ||
|
||
/** | ||
* If colors should be reversed. | ||
*/ | ||
reversed: PropTypes.bool, | ||
|
||
/** | ||
* If the field is a textarea. | ||
*/ | ||
isTextarea: PropTypes.bool, | ||
|
||
/** | ||
* If node 'input', its type. | ||
*/ | ||
type: PropTypes.oneOf(['text', 'number', 'email']), | ||
|
||
/** | ||
* Field value when controlled. | ||
*/ | ||
value: PropTypes.string, | ||
|
||
/** | ||
* Field onchange event handler. | ||
*/ | ||
onChange: PropTypes.func, | ||
|
||
/** | ||
* Field placeholder text. | ||
*/ | ||
placeholder: PropTypes.string, | ||
|
||
/** | ||
* When the field has an error, show this text below it. | ||
*/ | ||
errorText: PropTypes.string, | ||
|
||
/** | ||
* Extra fields to pass to the encapsulated field element. | ||
*/ | ||
fieldProps: PropTypes.object, | ||
}; | ||
|
||
TextField.defaultProps = { | ||
type: 'text', | ||
palette: 'primary', | ||
fieldProps: {}, | ||
}; | ||
|
||
export default withStyles(styles)(TextField); |
Oops, something went wrong.