mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-28 12:36:35 +00:00
Abstract CharacterString for resuability
This commit is contained in:
parent
06482e6795
commit
389f5cb27d
3 changed files with 20 additions and 6 deletions
|
|
@ -6,3 +6,4 @@ module.exports = (props) => {
|
|||
return <div {...props} className={className}>{props.children}</div>;
|
||||
};
|
||||
|
||||
// TODO: Require that props.children be a string
|
||||
|
|
|
|||
14
js/CharacterString.jsx
Normal file
14
js/CharacterString.jsx
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import React from 'react';
|
||||
import Character from './Character.jsx';
|
||||
|
||||
module.exports = (props) => {
|
||||
const text = '' + props.children;
|
||||
const chars = text.split('');
|
||||
return <div {...props}>
|
||||
{chars.map(character => {
|
||||
return <Character>{character}</Character>;
|
||||
})};
|
||||
</div>;
|
||||
};
|
||||
|
||||
// TODO: Require that props.children be a string
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
import React from 'react';
|
||||
import {connect} from 'react-redux';
|
||||
|
||||
import Character from './Character.jsx';
|
||||
import CharacterString from './CharacterString.jsx';
|
||||
|
||||
|
||||
class Marquee extends React.Component {
|
||||
|
|
@ -45,11 +45,10 @@ class Marquee extends React.Component {
|
|||
// TODO: Use the spread operator
|
||||
chars = start.concat(end).slice(0, 30);
|
||||
}
|
||||
return <div onMouseDown={this.handleMouseDown}>
|
||||
{chars.map(character => {
|
||||
return <Character>{character}</Character>;
|
||||
})};
|
||||
</div>;
|
||||
const text = chars.join('');
|
||||
return <CharacterString onMouseDown={this.handleMouseDown}>
|
||||
{text}
|
||||
</CharacterString>;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue