aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/components/FloatingLabel.js
diff options
context:
space:
mode:
authorRyan Mehri <[email protected]>2020-05-10 12:52:43 -0600
committerGitHub <[email protected]>2020-05-10 12:52:43 -0600
commit22a2e8b5d9ae005527bd23e8d6e31a765c690e80 (patch)
treef05d45608790aa29942caab5d30e39c2171d498d /frontend/src/components/FloatingLabel.js
parentMerge pull request #9 from jackyzha0/backend (diff)
parentadd focus opacity change, password input (diff)
downloadctrl-v-22a2e8b5d9ae005527bd23e8d6e31a765c690e80.tar.xz
ctrl-v-22a2e8b5d9ae005527bd23e8d6e31a765c690e80.zip
Merge pull request #10 from jackyzha0/react
add focus opacity change, password input
Diffstat (limited to 'frontend/src/components/FloatingLabel.js')
-rw-r--r--frontend/src/components/FloatingLabel.js34
1 files changed, 34 insertions, 0 deletions
diff --git a/frontend/src/components/FloatingLabel.js b/frontend/src/components/FloatingLabel.js
new file mode 100644
index 0000000..814790c
--- /dev/null
+++ b/frontend/src/components/FloatingLabel.js
@@ -0,0 +1,34 @@
+import React from 'react';
+import styled, { css } from 'styled-components'
+
+const StyledLabel = styled.label`
+ position: absolute;
+ top: 0.5em;
+ font-weight: 700;
+ font-size: 1em;
+ opacity: 0;
+ transition: all 0.5s cubic-bezier(.25,.8,.25,1);
+
+ ${props =>
+ (props.value.length > 0) &&
+ css`
+ top: 0em;
+ opacity: 1
+ `};
+`
+
+class FloatingLabel extends React.Component {
+ render() {
+ return (
+ <StyledLabel
+ label={this.props.label}
+ value={this.props.value}
+ className={this.props.id}
+ htmlFor={this.props.id}>
+ {this.props.label}
+ </StyledLabel>
+ );
+ }
+}
+
+export default FloatingLabel \ No newline at end of file