Skip to content

Commit

Permalink
Updated hide content to break long string
Browse files Browse the repository at this point in the history
  • Loading branch information
Marvin Heilemann committed Feb 4, 2020
1 parent 1ae90bf commit afecf44
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/components/HideContent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,26 @@ const HideContent = ({ text }) => {
const [content, setContent] = useState(null)

useEffect(() => {
setContent(window.btoa(text))
let encoded = window.btoa(text)
encoded = encoded.split('').map((v, i) => (i % 6 === 0 ? `${v}-` : v))
setContent(encoded)
}, [text])

const decryptContent = () => {
setContent(text)
}

/* eslint-disable jsx-a11y/no-static-element-interactions */
return (
<button
className="hidden-content tooltip inline reset"
<span
className="hidden-content tooltip"
onKeyPress={decryptContent}
onClick={decryptContent}
aria-label="Click to reveal"
data-position="top"
>
{content}
</button>
</span>
)
}

Expand Down

0 comments on commit afecf44

Please sign in to comment.