Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a custom root component tag. #46

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
{
"name": "react-typist",
"version": "2.0.4",
"version": "2.0.5",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you remove these changes? I'll update the version when I publish a new version separately

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed in my last commit. Thank you

"description": "Typing animations with React",
"main": "dist/Typist.js",
"files": ["dist", "src"],
"files": [
"dist",
"src"
],
"scripts": {
"dist": "webpack --config webpack.dist.config.js",
"standalone": "webpack --config webpack.standalone.config.js",
Expand Down
9 changes: 6 additions & 3 deletions src/Typist.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default class Typist extends Component {
static propTypes = {
children: PropTypes.node,
className: PropTypes.string,
container: PropTypes.string,
avgTypingDelay: PropTypes.number,
stdTypingDelay: PropTypes.number,
startDelay: PropTypes.number,
Expand All @@ -24,6 +25,7 @@ export default class Typist extends Component {
}

static defaultProps = {
container: 'div',
className: '',
avgTypingDelay: 70,
stdTypingDelay: 25,
Expand Down Expand Up @@ -182,18 +184,19 @@ export default class Typist extends Component {
}

render() {
const { className, cursor } = this.props;
const { className, cursor, container } = this.props;
const { isDone } = this.state;
const ContainerTag = container;
const innerTree = utils.cloneElementWithSpecifiedText({
element: this.props.children,
textLines: this.state.textLines,
});

return (
<div className={`Typist ${className}`}>
<ContainerTag className={`Typist ${className}`}>
{innerTree}
<Cursor isDone={isDone} {...cursor} />
</div>
</ContainerTag>
);
}

Expand Down