Abstract Character componant

This commit is contained in:
Jordan Eldredge 2016-07-11 21:09:44 -07:00
parent 9558890d51
commit 130d18f072
2 changed files with 14 additions and 6 deletions

8
js/Character.jsx Normal file
View file

@ -0,0 +1,8 @@
import React from 'react';
module.exports = (props) => {
const char = '' + props.children;
const className = 'character character-' + char.toLowerCase().charCodeAt(0);
return <div {...props} className={className}>{props.children}</div>;
};

View file

@ -2,6 +2,8 @@
import React from 'react';
import {connect} from 'react-redux';
import Character from './Character.jsx';
class Marquee extends React.Component {
constructor(props) {
@ -44,12 +46,10 @@ class Marquee extends React.Component {
chars = start.concat(end).slice(0, 30);
}
return <div onMouseDown={this.handleMouseDown}>
{chars.map(character => {
// TODO: Standarize how we get a characer class name
const className = 'character character-' + character.toLowerCase().charCodeAt(0);
return <div className={className}>{character}</div>;
})}
</div>;
{chars.map(character => {
return <Character>{character}</Character>;
})};
</div>;
}
}