Skip to content

Commit

Permalink
Moved hide content style to stylesheet
Browse files Browse the repository at this point in the history
  • Loading branch information
Marvin Heilemann committed Feb 3, 2020
1 parent 01452c7 commit e2348ef
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 11 deletions.
16 changes: 5 additions & 11 deletions src/components/HideContent.jsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,25 @@
import React, { useState, useEffect } from 'react'

/* eslint-disable jsx-a11y/no-interactive-element-to-noninteractive-role */

const HideContent = ({ text }) => {
const [state, setState] = useState(null)
const [content, setContent] = useState(null)

useEffect(() => {
setState(window.btoa(text))
setContent(window.btoa(text))
}, [text])

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

return (
<button
className="tooltip inline reset"
className="hidden-content tooltip inline reset"
onKeyPress={decryptContent}
onClick={decryptContent}
aria-label="Click to reveal"
data-position="top"
style={{
cursor: 'default',
userSelect: 'all',
}}
>
{state}
{content}
</button>
)
}
Expand Down
1 change: 1 addition & 0 deletions src/styles/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
@import 'components/button';
@import 'components/dot';
@import 'components/footnote';
@import 'components/hidden-content';
@import 'components/icon';
@import 'components/language';
@import 'components/lightbox';
Expand Down
4 changes: 4 additions & 0 deletions src/styles/components/_hidden-content.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.hidden-content {
cursor: default;
user-select: all;
}
12 changes: 12 additions & 0 deletions src/styles/elements/_form.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
input {
&.inline {
display: inline-block;
}

&.reset {
width: auto;
border: 0;
background: transparent;
}
}

.form-control {
display: flex;
position: relative;
Expand Down

0 comments on commit e2348ef

Please sign in to comment.