mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-26 11:34:14 +00:00
Abstract Character componant
This commit is contained in:
parent
9558890d51
commit
130d18f072
2 changed files with 14 additions and 6 deletions
8
js/Character.jsx
Normal file
8
js/Character.jsx
Normal 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>;
|
||||
};
|
||||
|
||||
|
|
@ -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>;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue