-
Notifications
You must be signed in to change notification settings - Fork 827
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
1,529 additions
and
237 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
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,70 @@ | ||
const bindAll = require('lodash.bindall'); | ||
const React = require('react'); | ||
const PropTypes = require('prop-types'); | ||
const FRCInput = require('formsy-react-components').Input; | ||
const FRCTextarea = require('formsy-react-components').Textarea; | ||
const classNames = require('classnames'); | ||
|
||
require('./row.scss'); | ||
require('./inplace-input.scss'); | ||
|
||
class InplaceInput extends React.Component { | ||
constructor (props) { | ||
super(props); | ||
bindAll(this, [ | ||
'handleBlur', | ||
'setRef' | ||
]); | ||
} | ||
handleBlur (name, value) { | ||
if (this.inputRef.props.errorMessages.length === 0) { | ||
const jsonData = {}; | ||
jsonData[name] = value; | ||
this.props.handleUpdate(jsonData); | ||
} | ||
} | ||
setRef (input) { | ||
this.inputRef = input; | ||
} | ||
render () { | ||
const { | ||
className, | ||
type, | ||
handleUpdate, // eslint-disable-line no-unused-vars | ||
...props | ||
} = this.props; | ||
return ( | ||
(type === 'textarea') ? | ||
<FRCTextarea | ||
className="inplace-textarea" | ||
componentRef={this.setRef} | ||
rowClassName={classNames('textarea-row no-label', className)} | ||
onBlur={this.handleBlur} | ||
{...props} | ||
/> : | ||
<FRCInput | ||
className="inplace-input" | ||
componentRef={this.setRef} | ||
rowClassName={classNames( | ||
className, | ||
'no-label' | ||
)} | ||
onBlur={this.handleBlur} | ||
{...props} | ||
/> | ||
); | ||
} | ||
} | ||
|
||
InplaceInput.propTypes = { | ||
className: PropTypes.string, | ||
handleUpdate: PropTypes.func.isRequired, | ||
type: PropTypes.string | ||
}; | ||
|
||
InplaceInput.defaultProps = { | ||
type: 'text', | ||
value: '' | ||
}; | ||
|
||
module.exports = InplaceInput; |
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,57 @@ | ||
@import "../../colors"; | ||
@import "../../frameless"; | ||
|
||
.inplace-input { | ||
transition: all .5s ease; | ||
border: 2px dashed $ui-dark-gray; | ||
border-radius: 5px; | ||
background-color: transparent; | ||
padding: 0 1rem; | ||
color: $type-gray; | ||
|
||
&:focus { | ||
transition: all .5s ease; | ||
outline: none; | ||
border: 1px solid $ui-blue; | ||
} | ||
|
||
&.fail { | ||
border: 1px solid $ui-orange; | ||
} | ||
|
||
&.pass { | ||
border: 1px solid $active-dark-gray; | ||
} | ||
|
||
/* IE10/11-specific style resets */ | ||
&::-ms-reveal, &::-ms-clear { | ||
display: none; | ||
} | ||
} | ||
|
||
.inplace-textarea { | ||
transition: all 1s ease; | ||
margin-bottom: .75rem; | ||
border: 2px dashed $ui-dark-gray; | ||
border-radius: 5px; | ||
background-color: $ui-light-gray; | ||
padding: .75rem 1rem; | ||
width: calc(100% - 2.25rem); | ||
min-height: 20rem; | ||
line-height: 1.75em; | ||
color: $type-gray; | ||
font-size: .875rem; | ||
resize: none; | ||
|
||
&:focus { | ||
transition: all 1s ease; | ||
outline: none; | ||
border: 1px solid $ui-blue; | ||
} | ||
|
||
&.fail { | ||
border: 1px solid $ui-orange; | ||
} | ||
} | ||
|
||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
const React = require('react'); // eslint-disable-line | ||
const reactStringReplace = require('react-string-replace'); | ||
|
||
/** | ||
* Helper method that replaces @mentions and #hashtags in plain text | ||
* | ||
* @param {string} text string to convert | ||
* @return {string} string with links for @mentions and #hashtags | ||
*/ | ||
module.exports = text => { | ||
let replacedText; | ||
|
||
// Match @-mentions (username is alphanumeric, underscore and dash) | ||
replacedText = reactStringReplace(text, /@([\w-]+)/g, (match, i) => ( | ||
<a | ||
href={`/users/${match}`} | ||
key={match + i} | ||
>@{match}</a> | ||
)); | ||
|
||
// Match hashtags | ||
replacedText = reactStringReplace(replacedText, /(#[\w-]+)/g, (match, i) => ( | ||
<a | ||
href={`/search/projects?q=${match}`} | ||
key={match + i} | ||
>{match}</a> | ||
)); | ||
|
||
return replacedText; | ||
}; |
Oops, something went wrong.