Last active
June 24, 2019 04:26
-
-
Save BarthesSimpson/eff9a299da59900f163b55f8cbb5001c to your computer and use it in GitHub Desktop.
LetterInput with added characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Icon({ i, char, reverse = false }) { | |
const padding = Array.from({ length: i }, (_, i) => ( | |
<span key={i}> </span> | |
)) | |
return reverse ? [char, ...padding] : [...padding, char] | |
} | |
function Happy({ i }) { | |
return <Icon i={i} char="ᕕ( ᐛ )ᕗ" /> | |
} | |
function Neutral({ i }) { | |
return <Icon i={i} reverse={true} char="¯_(ツ)_/¯" /> | |
} | |
function Sad({ i }) { | |
return <Icon i={i} char="¯_(☯෴☯)_/¯" /> | |
} | |
function Dead({ i }) { | |
return <Icon i={i} reverse={true} char="(✖╭╮✖)" /> | |
} | |
//...Inside the render method of <FormInput/> | |
<span style={{ float: "right", width: "50%" }}> | |
{len < MAX_LENGTH / 4 ? ( | |
<Happy i={len} /> | |
) : len < MAX_LENGTH / 2 ? ( | |
<Neutral i={len} /> | |
) : len < (3 * MAX_LENGTH) / 4 ? ( | |
<Sad i={len} /> | |
) : ( | |
<Dead i={len} /> | |
)} | |
</span> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment