-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Babel & Webpack added, components out
- Loading branch information
1 parent
1fbb1cf
commit 388082a
Showing
8 changed files
with
246 additions
and
161 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"presets": [ | ||
["env", { | ||
"debug": true, | ||
"targets": { | ||
"firefox": 45 | ||
}, | ||
"modules": false, | ||
"useBuiltIns": true | ||
}], | ||
"react" | ||
] | ||
} |
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,22 @@ | ||
import React from 'react'; | ||
|
||
const AnchorText = ({ children, link, text, type, className : defaultClasses = 'echofon-hyperlink', additionalClasses, style, screen_name, created_at, label }) => { | ||
const className = additionalClasses ? defaultClasses + ' ' + additionalClasses : defaultClasses; | ||
const setXULAttributes = (node) => { | ||
if (node) { | ||
node.setAttribute('text', text); | ||
node.setAttribute('tooltip', 'echofon-tooltip'); | ||
if (screen_name) node.setAttribute('screen_name', screen_name); | ||
if (created_at) node.setAttribute('created_at', created_at); | ||
if (label) node.setAttribute('label', label); | ||
} | ||
}; | ||
|
||
return ( | ||
<label style={style} className={className} href={link} type={type} ref={setXULAttributes}> | ||
{children} | ||
</label> | ||
); | ||
}; | ||
|
||
export default AnchorText; |
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,56 @@ | ||
import React from 'react'; | ||
|
||
// this should be elsewhere | ||
const DISPLAY_STYLE_BOTH = 0; | ||
const DISPLAY_STYLE_NAME = 1; | ||
const DISPLAY_STYLE_SCREEN_NAME = 2; | ||
|
||
class RichText extends React.Component { | ||
componentDidMount() { | ||
const { uid, msg, parent_elem } = this.props; | ||
|
||
if (msg.entities) { | ||
return EchofonCommon.convertLinksWithEntities(uid, msg, this.refs.node, parent_elem); | ||
} | ||
else { | ||
return EchofonCommon.convertLinksWithRegExp(uid, msg, this.refs.node, parent_elem); | ||
} | ||
} | ||
|
||
renderNameHeader() { | ||
const { user } = this.props; | ||
const style = EchofonCommon.pref().getIntPref("displayStyle"); | ||
|
||
const displayName = (style === DISPLAY_STYLE_NAME) ? user.name : user.screen_name; | ||
|
||
return ( | ||
<AnchorText | ||
additionalClasses="echofon-status-user" | ||
type="username" | ||
link={EchofonCommon.userViewURL(user.screen_name)} | ||
text={displayName} | ||
screen_name={user.screen_name} | ||
> | ||
{displayName} | ||
</AnchorText> | ||
); | ||
} | ||
|
||
render() { | ||
const style = EchofonCommon.pref().getIntPref("displayStyle"); | ||
|
||
// When display style is set to both screen_name and name, a new container is created | ||
// meanwhile when set to only one, it's rendered inline with the message body. | ||
// This will change as we refactor every component later. | ||
|
||
return ( | ||
<description className="echofon-status-body" ref="node"> | ||
{style !== DISPLAY_STYLE_BOTH && this.renderNameHeader()} | ||
{style !== DISPLAY_STYLE_BOTH && ' '} | ||
{/* appended when component mount, this will change */} | ||
</description> | ||
); | ||
} | ||
} | ||
|
||
export default RichText; |
Oops, something went wrong.