From 08dc86f2c91bd58d3535fe96a036c27389c31fd1 Mon Sep 17 00:00:00 2001 From: Giovani Date: Wed, 10 Apr 2019 13:35:38 -0400 Subject: [PATCH] Started on typing logic in the intro component --- src/components/shared/content/content.css | 3 + src/components/shared/content/content.js | 73 +++++++++++++++++++++-- 2 files changed, 71 insertions(+), 5 deletions(-) diff --git a/src/components/shared/content/content.css b/src/components/shared/content/content.css index e69de29..8b6c64d 100644 --- a/src/components/shared/content/content.css +++ b/src/components/shared/content/content.css @@ -0,0 +1,3 @@ +.align-text-top { + line-height: 100%; +} \ No newline at end of file diff --git a/src/components/shared/content/content.js b/src/components/shared/content/content.js index 0ed6c21..c5e7381 100644 --- a/src/components/shared/content/content.js +++ b/src/components/shared/content/content.js @@ -1,28 +1,91 @@ import React, {Component} from 'react'; import ProfilePicture from '../../../images/home/profilePicture.jpg'; +import "./content.css"; + +const lineOneText = 'Hi, my name is Giovani.'; +const lineTwoText = 'I am a software developer.'; class Content extends Component { - /* Create typing logic */ + constructor(props) { + super(props); - render() { + let typingInterval = this.startTyping(); + this.state = { + currentLineOne: '', + currentLineTwo: '', + currentCharLineOne: 0, + currentCharLineTwo: 0, + isCursorVisible: false, + typingInterval: typingInterval, + cursorBlinkingInterval: null + }; + } + + getLineOneText = () => { + return lineOneText; + } + + getLineTwoText = () => { + return lineTwoText; + } + + startTyping = () => { + let typingInterval = setInterval(this.type, 55); + return typingInterval; + } + + startBlinking = () => { + let blinkingInterval = setInterval(this.blink, 100); + } + + type = () => { + let { currentLineOne, + currentCharLineOne, + interval } = this.state; + + if (currentCharLineOne === 0 || currentCharLineOne !== this.getLineOneText().length) { + currentLineOne += this.getLineOneText()[currentCharLineOne]; + } else { + clearInterval(interval); + return; + } + + currentCharLineOne++; + this.setState({ currentLineOne: currentLineOne, + currentCharLineOne: currentCharLineOne }); + } + + blink = () => { + + } + + getCursorClasses = () => { + let isCursorVisible = this.state.isCursorVisible; + return `align-text-top ${isCursorVisible ? 'visible' : 'invisible'}`; + } + + render() { return (
- Giovani's Profile Picture + Giovani's Face
-

Hi, my name is Giovani.

-

I am a software developer.|

+

{this.state.currentLineOne}|

+

{this.state.currentLineTwo}

); } + + // componentDidUpdate() { + // } } export default Content; \ No newline at end of file